wip Fix API validation
This commit is contained in:
parent
5b29d32cfa
commit
0d101d4237
|
@ -23,6 +23,8 @@
|
|||
"main": "functions/src/index.js",
|
||||
"dependencies": {
|
||||
"@amplitude/node": "1.10.0",
|
||||
"@tiptap/core": "^2.0.0-beta.181",
|
||||
"@tiptap/starter-kit": "^2.0.0-beta.190",
|
||||
"fetch": "1.1.0",
|
||||
"firebase-admin": "10.0.0",
|
||||
"firebase-functions": "3.21.2",
|
||||
|
|
|
@ -5,7 +5,6 @@ import {
|
|||
CPMMBinaryContract,
|
||||
Contract,
|
||||
FreeResponseContract,
|
||||
MAX_DESCRIPTION_LENGTH,
|
||||
MAX_QUESTION_LENGTH,
|
||||
MAX_TAG_LENGTH,
|
||||
NumericContract,
|
||||
|
@ -28,10 +27,34 @@ import { getNewContract } from '../../common/new-contract'
|
|||
import { NUMERIC_BUCKET_COUNT } from '../../common/numeric-constants'
|
||||
import { User } from '../../common/user'
|
||||
import { Group, MAX_ID_LENGTH } from '../../common/group'
|
||||
import { JSONContent } from '@tiptap/core'
|
||||
|
||||
const descScehma: z.ZodType<JSONContent> = z.lazy(() =>
|
||||
z.intersection(
|
||||
z.record(z.any()),
|
||||
z.object({
|
||||
type: z.string().optional(),
|
||||
attrs: z.record(z.any()).optional(),
|
||||
content: z.array(descScehma).optional(),
|
||||
marks: z
|
||||
.array(
|
||||
z.intersection(
|
||||
z.record(z.any()),
|
||||
z.object({
|
||||
type: z.string(),
|
||||
attrs: z.record(z.any()).optional(),
|
||||
})
|
||||
)
|
||||
)
|
||||
.optional(),
|
||||
text: z.string().optional(),
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
const bodySchema = z.object({
|
||||
question: z.string().min(1).max(MAX_QUESTION_LENGTH),
|
||||
description: z.string().max(MAX_DESCRIPTION_LENGTH),
|
||||
description: descScehma.optional(),
|
||||
tags: z.array(z.string().min(1).max(MAX_TAG_LENGTH)).optional(),
|
||||
closeTime: zTimestamp().refine(
|
||||
(date) => date.getTime() > new Date().getTime(),
|
||||
|
@ -114,7 +137,7 @@ export const createmarket = newEndpoint(['POST'], async (req, auth) => {
|
|||
user,
|
||||
question,
|
||||
outcomeType,
|
||||
description,
|
||||
description ?? {},
|
||||
initialProb ?? 0,
|
||||
ante,
|
||||
closeTime.getTime(),
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as functions from 'firebase-functions'
|
|||
import { getUser } from './utils'
|
||||
import { createNotification } from './create-notification'
|
||||
import { Contract } from '../../common/contract'
|
||||
import { richTextToString } from 'common/util/parse'
|
||||
import { richTextToString } from '../../common/util/parse'
|
||||
|
||||
export const onCreateContract = functions.firestore
|
||||
.document('contracts/{contractId}')
|
||||
|
|
Loading…
Reference in New Issue
Block a user