chore: remove generated zod schema file as it's no longer needed

This commit is contained in:
Yuu Ottosoka
2025-07-20 23:16:44 +03:00
parent 0ceba57012
commit d59f0dd794
2 changed files with 111 additions and 338 deletions

View File

@@ -1,126 +1,126 @@
name: release-tag # name: release-tag
on: # on:
push: # push:
branches: # branches:
- main # - main
jobs: # jobs:
detect-changes: # detect-changes:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
outputs: # outputs:
bot: ${{ steps.filter.outputs.bot }} # bot: ${{ steps.filter.outputs.bot }}
api: ${{ steps.filter.outputs.api }} # api: ${{ steps.filter.outputs.api }}
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v4 # uses: actions/checkout@v4
- name: Check for changes # - name: Check for changes
uses: dorny/paths-filter@v2 # uses: dorny/paths-filter@v2
id: filter # id: filter
with: # with:
filters: | # filters: |
bot: # bot:
- 'apps/bot/**' # - 'apps/bot/**'
- 'packages/**' # - 'packages/**'
api: # api:
- 'apps/api/**' # - 'apps/api/**'
- 'packages/**' # - 'packages/**'
build-and-deploy-bot: # build-and-deploy-bot:
needs: detect-changes # needs: detect-changes
if: needs.detect-changes.outputs.bot == 'true' # if: needs.detect-changes.outputs.bot == 'true'
env: # env:
DOCKER_LATEST: latest # DOCKER_LATEST: latest
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v2 # uses: actions/checkout@v2
- name: Set up Docker Buildx # - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 # uses: docker/setup-buildx-action@v1
- name: Get Meta # - name: Get Meta
id: meta # id: meta
run: | # run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT # echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT # echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT
- name: Log in to Docker registry # - name: Log in to Docker registry
uses: docker/login-action@v3 # uses: docker/login-action@v3
with: # with:
registry: ${{ vars.DOCKER_REGISTRY }} # registry: ${{ vars.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} # username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} # password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push bot # - name: Build and push bot
uses: docker/build-push-action@v5 # uses: docker/build-push-action@v5
with: # with:
context: . # context: .
file: ./apps/bot/Dockerfile # file: ./apps/bot/Dockerfile
push: true # push: true
tags: | # tags: |
${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ steps.meta.outputs.REPO_VERSION }} # ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ steps.meta.outputs.REPO_VERSION }}
${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ env.DOCKER_LATEST }} # ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-bot:${{ env.DOCKER_LATEST }}
- name: Trigger Dokploy Bot Deployment # - name: Trigger Dokploy Bot Deployment
run: | # run: |
curl -X 'POST' \ # curl -X 'POST' \
'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \ # 'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \
-H 'accept: application/json' \ # -H 'accept: application/json' \
-H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \ # -H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \
-H 'Content-Type: application/json' \ # -H 'Content-Type: application/json' \
-d '{ # -d '{
"json":{ # "json":{
"applicationId": "${{ vars.DOKPLOY_BOT_APPLICATION_ID }}" # "applicationId": "${{ vars.DOKPLOY_BOT_APPLICATION_ID }}"
} # }
}' # }'
build-and-deploy-api: # build-and-deploy-api:
needs: detect-changes # needs: detect-changes
if: needs.detect-changes.outputs.api == 'true' # if: needs.detect-changes.outputs.api == 'true'
env: # env:
DOCKER_LATEST: latest # DOCKER_LATEST: latest
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v2 # uses: actions/checkout@v2
- name: Set up Docker Buildx # - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 # uses: docker/setup-buildx-action@v1
- name: Get Meta # - name: Get Meta
id: meta # id: meta
run: | # run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT # echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT # echo REPO_VERSION=${GITHUB_REF_NAME#v} >> $GITHUB_OUTPUT
- name: Log in to Docker registry # - name: Log in to Docker registry
uses: docker/login-action@v3 # uses: docker/login-action@v3
with: # with:
registry: ${{ vars.DOCKER_REGISTRY }} # registry: ${{ vars.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }} # username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} # password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push api # - name: Build and push api
uses: docker/build-push-action@v5 # uses: docker/build-push-action@v5
with: # with:
context: . # context: .
file: ./apps/api/Dockerfile # file: ./apps/api/Dockerfile
push: true # push: true
tags: | # tags: |
${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ steps.meta.outputs.REPO_VERSION }} # ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ steps.meta.outputs.REPO_VERSION }}
${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ env.DOCKER_LATEST }} # ${{ vars.DOCKER_REGISTRY }}/${{ steps.meta.outputs.REPO_NAME }}-api:${{ env.DOCKER_LATEST }}
- name: Trigger Dokploy API Deployment # - name: Trigger Dokploy API Deployment
run: | # run: |
curl -X 'POST' \ # curl -X 'POST' \
'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \ # 'https://${{ vars.DOKPLOY_DOMAIN }}/api/trpc/application.deploy' \
-H 'accept: application/json' \ # -H 'accept: application/json' \
-H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \ # -H 'x-api-key:${{ secrets.DOKPLOY_API_KEY }}' \
-H 'Content-Type: application/json' \ # -H 'Content-Type: application/json' \
-d '{ # -d '{
"json":{ # "json":{
"applicationId": "${{ vars.DOKPLOY_API_APPLICATION_ID }}" # "applicationId": "${{ vars.DOKPLOY_API_APPLICATION_ID }}"
} # }
}' # }'

View File

@@ -1,227 +0,0 @@
import { z } from 'zod';
import { Prisma } from '../prisma';
/////////////////////////////////////////
// HELPER FUNCTIONS
/////////////////////////////////////////
// JSON
//------------------------------------------------------
export type NullableJsonInput = Prisma.JsonValue | null | 'JsonNull' | 'DbNull' | Prisma.NullTypes.DbNull | Prisma.NullTypes.JsonNull;
export const transformJsonNull = (v?: NullableJsonInput) => {
if (!v || v === 'DbNull') return Prisma.DbNull;
if (v === 'JsonNull') return Prisma.JsonNull;
return v;
};
export const JsonValueSchema: z.ZodType<Prisma.JsonValue> = z.lazy(() =>
z.union([
z.string(),
z.number(),
z.boolean(),
z.literal(null),
z.record(z.lazy(() => JsonValueSchema.optional())),
z.array(z.lazy(() => JsonValueSchema)),
])
);
export type JsonValueType = z.infer<typeof JsonValueSchema>;
export const NullableJsonValue = z
.union([JsonValueSchema, z.literal('DbNull'), z.literal('JsonNull')])
.nullable()
.transform((v) => transformJsonNull(v));
export type NullableJsonValueType = z.infer<typeof NullableJsonValue>;
export const InputJsonValueSchema: z.ZodType<Prisma.InputJsonValue> = z.lazy(() =>
z.union([
z.string(),
z.number(),
z.boolean(),
z.object({ toJSON: z.function(z.tuple([]), z.any()) }),
z.record(z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),
z.array(z.lazy(() => z.union([InputJsonValueSchema, z.literal(null)]))),
])
);
export type InputJsonValueType = z.infer<typeof InputJsonValueSchema>;
// DECIMAL
//------------------------------------------------------
export const DecimalJsLikeSchema: z.ZodType<Prisma.DecimalJsLike> = z.object({
d: z.array(z.number()),
e: z.number(),
s: z.number(),
toFixed: z.function(z.tuple([]), z.string()),
})
export const DECIMAL_STRING_REGEX = /^(?:-?Infinity|NaN|-?(?:0[bB][01]+(?:\.[01]+)?(?:[pP][-+]?\d+)?|0[oO][0-7]+(?:\.[0-7]+)?(?:[pP][-+]?\d+)?|0[xX][\da-fA-F]+(?:\.[\da-fA-F]+)?(?:[pP][-+]?\d+)?|(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?))$/;
export const isValidDecimalInput =
(v?: null | string | number | Prisma.DecimalJsLike): v is string | number | Prisma.DecimalJsLike => {
if (v === undefined || v === null) return false;
return (
(typeof v === 'object' && 'd' in v && 'e' in v && 's' in v && 'toFixed' in v) ||
(typeof v === 'string' && DECIMAL_STRING_REGEX.test(v)) ||
typeof v === 'number'
)
};
/////////////////////////////////////////
// ENUMS
/////////////////////////////////////////
export const TransactionIsolationLevelSchema = z.enum(['ReadUncommitted','ReadCommitted','RepeatableRead','Serializable']);
export const TelegramSessionScalarFieldEnumSchema = z.enum(['id','data','createdAt','updatedAt']);
export const TelegramUserScalarFieldEnumSchema = z.enum(['id','username','isBlocked','firstName','lastName','languageCode','isPremium','createdAt','updatedAt']);
export const PaymentScalarFieldEnumSchema = z.enum(['id','telegramUserId','amount','currency','status','provider','providerId','metadata','createdAt','updatedAt']);
export const PlanScalarFieldEnumSchema = z.enum(['id','code','name','description','durationDays','dailyGenerations','price','currency']);
export const SubscriptionScalarFieldEnumSchema = z.enum(['id','telegramUserId','planId','startedAt','expiresAt','canceledAt','createdAt','updatedAt']);
export const FileScalarFieldEnumSchema = z.enum(['id','filename','originalName','mimeType','size','path','createdAt','updatedAt']);
export const FileLinkScalarFieldEnumSchema = z.enum(['id','fileId','relationId','createdAt','updatedAt']);
export const SortOrderSchema = z.enum(['asc','desc']);
export const JsonNullValueInputSchema = z.enum(['JsonNull',]).transform((value) => (value === 'JsonNull' ? Prisma.JsonNull : value));
export const NullableJsonNullValueInputSchema = z.enum(['DbNull','JsonNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.DbNull : value);
export const QueryModeSchema = z.enum(['default','insensitive']);
export const JsonNullValueFilterSchema = z.enum(['DbNull','JsonNull','AnyNull',]).transform((value) => value === 'JsonNull' ? Prisma.JsonNull : value === 'DbNull' ? Prisma.JsonNull : value === 'AnyNull' ? Prisma.AnyNull : value);
export const NullsOrderSchema = z.enum(['first','last']);
export const PaymentStatusSchema = z.enum(['PENDING','COMPLETED','FAILED','REFUNDED']);
export type PaymentStatusType = `${z.infer<typeof PaymentStatusSchema>}`
/////////////////////////////////////////
// MODELS
/////////////////////////////////////////
/////////////////////////////////////////
// TELEGRAM SESSION SCHEMA
/////////////////////////////////////////
export const TelegramSessionSchema = z.object({
id: z.string(),
data: JsonValueSchema,
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type TelegramSession = z.infer<typeof TelegramSessionSchema>
/////////////////////////////////////////
// TELEGRAM USER SCHEMA
/////////////////////////////////////////
export const TelegramUserSchema = z.object({
id: z.string(),
username: z.string().nullable(),
isBlocked: z.boolean(),
firstName: z.string().nullable(),
lastName: z.string().nullable(),
languageCode: z.string().nullable(),
isPremium: z.boolean().nullable(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type TelegramUser = z.infer<typeof TelegramUserSchema>
/////////////////////////////////////////
// PAYMENT SCHEMA
/////////////////////////////////////////
export const PaymentSchema = z.object({
status: PaymentStatusSchema,
id: z.string().cuid(),
telegramUserId: z.string(),
amount: z.instanceof(Prisma.Decimal, { message: "Field 'amount' must be a Decimal. Location: ['Models', 'Payment']"}),
currency: z.string(),
provider: z.string(),
providerId: z.string().nullable(),
metadata: JsonValueSchema.nullable(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type Payment = z.infer<typeof PaymentSchema>
/////////////////////////////////////////
// PLAN SCHEMA
/////////////////////////////////////////
export const PlanSchema = z.object({
id: z.string().uuid(),
code: z.string(),
name: z.string(),
description: z.string().nullable(),
durationDays: z.number().int(),
dailyGenerations: z.number().int(),
price: z.number().int(),
currency: z.string(),
})
export type Plan = z.infer<typeof PlanSchema>
/////////////////////////////////////////
// SUBSCRIPTION SCHEMA
/////////////////////////////////////////
export const SubscriptionSchema = z.object({
id: z.string().uuid(),
telegramUserId: z.string(),
planId: z.string(),
startedAt: z.coerce.date(),
expiresAt: z.coerce.date(),
canceledAt: z.coerce.date().nullable(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type Subscription = z.infer<typeof SubscriptionSchema>
/////////////////////////////////////////
// FILE SCHEMA
/////////////////////////////////////////
export const FileSchema = z.object({
id: z.string().uuid(),
filename: z.string(),
originalName: z.string(),
mimeType: z.string(),
size: z.number().int(),
path: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type File = z.infer<typeof FileSchema>
/////////////////////////////////////////
// FILE LINK SCHEMA
/////////////////////////////////////////
export const FileLinkSchema = z.object({
id: z.string().uuid(),
fileId: z.string(),
relationId: z.string(),
createdAt: z.coerce.date(),
updatedAt: z.coerce.date(),
})
export type FileLink = z.infer<typeof FileLinkSchema>