chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jCreateContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import {
|
||||
convertNeo4jTypesToJSON,
|
||||
createNeo4jDriver,
|
||||
validateCypherQuery,
|
||||
} from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jCreateAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j create attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jCreateContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j create on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const records = result.records.map((record) => {
|
||||
const obj: Record<string, unknown> = {}
|
||||
record.keys.forEach((key) => {
|
||||
if (typeof key === 'string') {
|
||||
obj[key] = convertNeo4jTypesToJSON(record.get(key))
|
||||
}
|
||||
})
|
||||
return obj
|
||||
})
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Create executed successfully, created ${summary.counters.nodesCreated} nodes and ${summary.counters.relationshipsCreated} relationships, returned ${records.length} records`
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Created ${summary.counters.nodesCreated} nodes and ${summary.counters.relationshipsCreated} relationships`,
|
||||
records,
|
||||
recordCount: records.length,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j create failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j create failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,94 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jDeleteContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createNeo4jDriver, validateCypherQuery } from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jDeleteAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j delete attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jDeleteContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j delete on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Delete executed successfully, deleted ${summary.counters.nodesDeleted} nodes and ${summary.counters.relationshipsDeleted} relationships`
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Deleted ${summary.counters.nodesDeleted} nodes and ${summary.counters.relationshipsDeleted} relationships`,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j delete failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j delete failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,108 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jExecuteContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import {
|
||||
convertNeo4jTypesToJSON,
|
||||
createNeo4jDriver,
|
||||
validateCypherQuery,
|
||||
} from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jExecuteAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j execute attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jExecuteContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j query on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const records = result.records.map((record) => {
|
||||
const obj: Record<string, unknown> = {}
|
||||
record.keys.forEach((key) => {
|
||||
if (typeof key === 'string') {
|
||||
obj[key] = convertNeo4jTypesToJSON(record.get(key))
|
||||
}
|
||||
})
|
||||
return obj
|
||||
})
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(`[${requestId}] Query executed successfully, returned ${records.length} records`)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Query executed successfully, returned ${records.length} records`,
|
||||
records,
|
||||
recordCount: records.length,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j execute failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j execute failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,193 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jIntrospectContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import { createNeo4jDriver } from '@/app/api/tools/neo4j/utils'
|
||||
import type { Neo4jNodeSchema, Neo4jRelationshipSchema } from '@/tools/neo4j/types'
|
||||
|
||||
const logger = createLogger('Neo4jIntrospectAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j introspect attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jIntrospectContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Introspecting Neo4j database at ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const labelsResult = await session.run(
|
||||
'CALL db.labels() YIELD label RETURN label ORDER BY label'
|
||||
)
|
||||
const labels: string[] = labelsResult.records.map((record) => record.get('label') as string)
|
||||
|
||||
const relationshipTypesResult = await session.run(
|
||||
'CALL db.relationshipTypes() YIELD relationshipType RETURN relationshipType ORDER BY relationshipType'
|
||||
)
|
||||
const relationshipTypes: string[] = relationshipTypesResult.records.map(
|
||||
(record) => record.get('relationshipType') as string
|
||||
)
|
||||
|
||||
const nodeSchemas: Neo4jNodeSchema[] = []
|
||||
try {
|
||||
const nodePropertiesResult = await session.run(
|
||||
'CALL db.schema.nodeTypeProperties() YIELD nodeLabels, propertyName, propertyTypes RETURN nodeLabels, propertyName, propertyTypes'
|
||||
)
|
||||
|
||||
const nodePropertiesMap = new Map<string, Array<{ name: string; types: string[] }>>()
|
||||
|
||||
for (const record of nodePropertiesResult.records) {
|
||||
const nodeLabels = record.get('nodeLabels') as string[]
|
||||
const propertyName = record.get('propertyName') as string
|
||||
const propertyTypes = record.get('propertyTypes') as string[]
|
||||
|
||||
const labelKey = nodeLabels.join(':')
|
||||
if (!nodePropertiesMap.has(labelKey)) {
|
||||
nodePropertiesMap.set(labelKey, [])
|
||||
}
|
||||
nodePropertiesMap.get(labelKey)!.push({ name: propertyName, types: propertyTypes })
|
||||
}
|
||||
|
||||
for (const [labelKey, properties] of nodePropertiesMap) {
|
||||
nodeSchemas.push({
|
||||
label: labelKey,
|
||||
properties,
|
||||
})
|
||||
}
|
||||
} catch (nodePropsError) {
|
||||
logger.warn(
|
||||
`[${requestId}] Could not fetch node properties (may not be supported in this Neo4j version): ${nodePropsError}`
|
||||
)
|
||||
}
|
||||
|
||||
const relationshipSchemas: Neo4jRelationshipSchema[] = []
|
||||
try {
|
||||
const relPropertiesResult = await session.run(
|
||||
'CALL db.schema.relTypeProperties() YIELD relationshipType, propertyName, propertyTypes RETURN relationshipType, propertyName, propertyTypes'
|
||||
)
|
||||
|
||||
const relPropertiesMap = new Map<string, Array<{ name: string; types: string[] }>>()
|
||||
|
||||
for (const record of relPropertiesResult.records) {
|
||||
const relType = record.get('relationshipType') as string
|
||||
const propertyName = record.get('propertyName') as string | null
|
||||
const propertyTypes = record.get('propertyTypes') as string[]
|
||||
|
||||
if (!relPropertiesMap.has(relType)) {
|
||||
relPropertiesMap.set(relType, [])
|
||||
}
|
||||
if (propertyName) {
|
||||
relPropertiesMap.get(relType)!.push({ name: propertyName, types: propertyTypes })
|
||||
}
|
||||
}
|
||||
|
||||
for (const [relType, properties] of relPropertiesMap) {
|
||||
relationshipSchemas.push({
|
||||
type: relType,
|
||||
properties,
|
||||
})
|
||||
}
|
||||
} catch (relPropsError) {
|
||||
logger.warn(
|
||||
`[${requestId}] Could not fetch relationship properties (may not be supported in this Neo4j version): ${relPropsError}`
|
||||
)
|
||||
}
|
||||
|
||||
const constraints: Array<{
|
||||
name: string
|
||||
type: string
|
||||
entityType: string
|
||||
properties: string[]
|
||||
}> = []
|
||||
try {
|
||||
const constraintsResult = await session.run('SHOW CONSTRAINTS')
|
||||
|
||||
for (const record of constraintsResult.records) {
|
||||
const name = record.get('name') as string
|
||||
const type = record.get('type') as string
|
||||
const entityType = record.get('entityType') as string
|
||||
const properties = (record.get('properties') as string[]) || []
|
||||
|
||||
constraints.push({ name, type, entityType, properties })
|
||||
}
|
||||
} catch (constraintsError) {
|
||||
logger.warn(
|
||||
`[${requestId}] Could not fetch constraints (may not be supported in this Neo4j version): ${constraintsError}`
|
||||
)
|
||||
}
|
||||
|
||||
const indexes: Array<{ name: string; type: string; entityType: string; properties: string[] }> =
|
||||
[]
|
||||
try {
|
||||
const indexesResult = await session.run('SHOW INDEXES')
|
||||
|
||||
for (const record of indexesResult.records) {
|
||||
const name = record.get('name') as string
|
||||
const type = record.get('type') as string
|
||||
const entityType = record.get('entityType') as string
|
||||
const properties = (record.get('properties') as string[]) || []
|
||||
|
||||
indexes.push({ name, type, entityType, properties })
|
||||
}
|
||||
} catch (indexesError) {
|
||||
logger.warn(
|
||||
`[${requestId}] Could not fetch indexes (may not be supported in this Neo4j version): ${indexesError}`
|
||||
)
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Introspection completed: ${labels.length} labels, ${relationshipTypes.length} relationship types, ${constraints.length} constraints, ${indexes.length} indexes`
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Database introspection completed: found ${labels.length} labels, ${relationshipTypes.length} relationship types, ${nodeSchemas.length} node schemas, ${relationshipSchemas.length} relationship schemas, ${constraints.length} constraints, ${indexes.length} indexes`,
|
||||
labels,
|
||||
relationshipTypes,
|
||||
nodeSchemas,
|
||||
relationshipSchemas,
|
||||
constraints,
|
||||
indexes,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j introspection failed:`, error)
|
||||
|
||||
return NextResponse.json(
|
||||
{ error: `Neo4j introspection failed: ${errorMessage}` },
|
||||
{ status: 500 }
|
||||
)
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,110 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jMergeContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import {
|
||||
convertNeo4jTypesToJSON,
|
||||
createNeo4jDriver,
|
||||
validateCypherQuery,
|
||||
} from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jMergeAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j merge attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jMergeContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j merge on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const records = result.records.map((record) => {
|
||||
const obj: Record<string, unknown> = {}
|
||||
record.keys.forEach((key) => {
|
||||
if (typeof key === 'string') {
|
||||
obj[key] = convertNeo4jTypesToJSON(record.get(key))
|
||||
}
|
||||
})
|
||||
return obj
|
||||
})
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Merge executed successfully, created ${summary.counters.nodesCreated} nodes, ${summary.counters.relationshipsCreated} relationships, returned ${records.length} records`
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Merge completed: ${summary.counters.nodesCreated} nodes created, ${summary.counters.relationshipsCreated} relationships created`,
|
||||
records,
|
||||
recordCount: records.length,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j merge failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j merge failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,108 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jQueryContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import {
|
||||
convertNeo4jTypesToJSON,
|
||||
createNeo4jDriver,
|
||||
validateCypherQuery,
|
||||
} from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jQueryAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j query attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jQueryContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j query on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const records = result.records.map((record) => {
|
||||
const obj: Record<string, unknown> = {}
|
||||
record.keys.forEach((key) => {
|
||||
if (typeof key === 'string') {
|
||||
obj[key] = convertNeo4jTypesToJSON(record.get(key))
|
||||
}
|
||||
})
|
||||
return obj
|
||||
})
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(`[${requestId}] Query executed successfully, returned ${records.length} records`)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Found ${records.length} records`,
|
||||
records,
|
||||
recordCount: records.length,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j query failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j query failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,110 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { getErrorMessage } from '@sim/utils/errors'
|
||||
import { generateId } from '@sim/utils/id'
|
||||
import { type NextRequest, NextResponse } from 'next/server'
|
||||
import { neo4jUpdateContract } from '@/lib/api/contracts/tools/databases/neo4j'
|
||||
import { parseToolRequest } from '@/lib/api/server'
|
||||
import { checkInternalAuth } from '@/lib/auth/hybrid'
|
||||
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
|
||||
import {
|
||||
convertNeo4jTypesToJSON,
|
||||
createNeo4jDriver,
|
||||
validateCypherQuery,
|
||||
} from '@/app/api/tools/neo4j/utils'
|
||||
|
||||
const logger = createLogger('Neo4jUpdateAPI')
|
||||
|
||||
export const POST = withRouteHandler(async (request: NextRequest) => {
|
||||
const requestId = generateId().slice(0, 8)
|
||||
let driver = null
|
||||
let session = null
|
||||
|
||||
const auth = await checkInternalAuth(request)
|
||||
if (!auth.success || !auth.userId) {
|
||||
logger.warn(`[${requestId}] Unauthorized Neo4j update attempt`)
|
||||
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = await parseToolRequest(neo4jUpdateContract, request, { logger })
|
||||
if (!parsed.success) return parsed.response
|
||||
const params = parsed.data.body
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Executing Neo4j update on ${params.host}:${params.port}/${params.database}`
|
||||
)
|
||||
|
||||
const validation = validateCypherQuery(params.cypherQuery)
|
||||
if (!validation.isValid) {
|
||||
logger.warn(`[${requestId}] Cypher query validation failed: ${validation.error}`)
|
||||
return NextResponse.json(
|
||||
{ error: `Query validation failed: ${validation.error}` },
|
||||
{ status: 400 }
|
||||
)
|
||||
}
|
||||
|
||||
driver = await createNeo4jDriver({
|
||||
host: params.host,
|
||||
port: params.port,
|
||||
database: params.database,
|
||||
username: params.username,
|
||||
password: params.password,
|
||||
encryption: params.encryption,
|
||||
})
|
||||
|
||||
session = driver.session({ database: params.database })
|
||||
|
||||
const result = await session.run(params.cypherQuery, params.parameters)
|
||||
|
||||
const records = result.records.map((record) => {
|
||||
const obj: Record<string, unknown> = {}
|
||||
record.keys.forEach((key) => {
|
||||
if (typeof key === 'string') {
|
||||
obj[key] = convertNeo4jTypesToJSON(record.get(key))
|
||||
}
|
||||
})
|
||||
return obj
|
||||
})
|
||||
|
||||
const summary = {
|
||||
resultAvailableAfter: result.summary.resultAvailableAfter.toNumber(),
|
||||
resultConsumedAfter: result.summary.resultConsumedAfter.toNumber(),
|
||||
counters: {
|
||||
nodesCreated: result.summary.counters.updates().nodesCreated,
|
||||
nodesDeleted: result.summary.counters.updates().nodesDeleted,
|
||||
relationshipsCreated: result.summary.counters.updates().relationshipsCreated,
|
||||
relationshipsDeleted: result.summary.counters.updates().relationshipsDeleted,
|
||||
propertiesSet: result.summary.counters.updates().propertiesSet,
|
||||
labelsAdded: result.summary.counters.updates().labelsAdded,
|
||||
labelsRemoved: result.summary.counters.updates().labelsRemoved,
|
||||
indexesAdded: result.summary.counters.updates().indexesAdded,
|
||||
indexesRemoved: result.summary.counters.updates().indexesRemoved,
|
||||
constraintsAdded: result.summary.counters.updates().constraintsAdded,
|
||||
constraintsRemoved: result.summary.counters.updates().constraintsRemoved,
|
||||
},
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`[${requestId}] Update executed successfully, ${summary.counters.propertiesSet} properties set, returned ${records.length} records`
|
||||
)
|
||||
|
||||
return NextResponse.json({
|
||||
message: `Updated ${summary.counters.propertiesSet} properties`,
|
||||
records,
|
||||
recordCount: records.length,
|
||||
summary,
|
||||
})
|
||||
} catch (error) {
|
||||
const errorMessage = getErrorMessage(error, 'Unknown error occurred')
|
||||
logger.error(`[${requestId}] Neo4j update failed:`, error)
|
||||
|
||||
return NextResponse.json({ error: `Neo4j update failed: ${errorMessage}` }, { status: 500 })
|
||||
} finally {
|
||||
if (session) {
|
||||
await session.close()
|
||||
}
|
||||
if (driver) {
|
||||
await driver.close()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,147 @@
|
||||
import neo4j from 'neo4j-driver'
|
||||
import { validateDatabaseHost } from '@/lib/core/security/input-validation.server'
|
||||
import type { Neo4jConnectionConfig } from '@/tools/neo4j/types'
|
||||
|
||||
export async function createNeo4jDriver(config: Neo4jConnectionConfig) {
|
||||
const hostValidation = await validateDatabaseHost(config.host, 'host')
|
||||
if (!hostValidation.isValid) {
|
||||
throw new Error(hostValidation.error)
|
||||
}
|
||||
|
||||
const isAuraHost =
|
||||
config.host === 'databases.neo4j.io' || config.host.endsWith('.databases.neo4j.io')
|
||||
|
||||
let protocol: string
|
||||
if (isAuraHost) {
|
||||
protocol = 'neo4j+s'
|
||||
} else {
|
||||
protocol = config.encryption === 'enabled' ? 'bolt+s' : 'bolt'
|
||||
}
|
||||
|
||||
const useIPPinning = !protocol.endsWith('+s')
|
||||
const resolvedIP = hostValidation.resolvedIP ?? config.host
|
||||
const uriHost = useIPPinning
|
||||
? resolvedIP.includes(':')
|
||||
? `[${resolvedIP}]`
|
||||
: resolvedIP
|
||||
: config.host
|
||||
const uri = `${protocol}://${uriHost}:${config.port}`
|
||||
|
||||
const driverConfig: any = {
|
||||
maxConnectionPoolSize: 1,
|
||||
connectionTimeout: 10000,
|
||||
}
|
||||
|
||||
if (!protocol.endsWith('+s')) {
|
||||
driverConfig.encrypted = config.encryption === 'enabled' ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
|
||||
}
|
||||
|
||||
const driver = neo4j.driver(uri, neo4j.auth.basic(config.username, config.password), driverConfig)
|
||||
|
||||
await driver.verifyConnectivity()
|
||||
|
||||
return driver
|
||||
}
|
||||
|
||||
export function validateCypherQuery(query: string): { isValid: boolean; error?: string } {
|
||||
if (!query || typeof query !== 'string') {
|
||||
return {
|
||||
isValid: false,
|
||||
error: 'Query must be a non-empty string',
|
||||
}
|
||||
}
|
||||
|
||||
const trimmedQuery = query.trim()
|
||||
if (trimmedQuery.length === 0) {
|
||||
return {
|
||||
isValid: false,
|
||||
error: 'Query cannot be empty',
|
||||
}
|
||||
}
|
||||
|
||||
return { isValid: true }
|
||||
}
|
||||
|
||||
export function sanitizeLabelName(name: string): string {
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(name)) {
|
||||
throw new Error(
|
||||
'Invalid label name. Must start with a letter and contain only letters, numbers, and underscores.'
|
||||
)
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
export function sanitizePropertyKey(key: string): string {
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(key)) {
|
||||
throw new Error(
|
||||
'Invalid property key. Must start with a letter and contain only letters, numbers, and underscores.'
|
||||
)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
export function sanitizeRelationshipType(type: string): string {
|
||||
if (!/^[A-Z][A-Z0-9_]*$/.test(type)) {
|
||||
throw new Error(
|
||||
'Invalid relationship type. Must start with an uppercase letter and contain only uppercase letters, numbers, and underscores.'
|
||||
)
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
export function convertNeo4jTypesToJSON(value: unknown): unknown {
|
||||
if (value === null || value === undefined) {
|
||||
return value
|
||||
}
|
||||
|
||||
if (typeof value === 'object' && value !== null && 'toNumber' in value) {
|
||||
return (value as any).toNumber()
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(convertNeo4jTypesToJSON)
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
const obj = value as any
|
||||
|
||||
if (obj.labels && obj.properties && obj.identity) {
|
||||
return {
|
||||
identity: obj.identity.toNumber ? obj.identity.toNumber() : obj.identity,
|
||||
labels: obj.labels,
|
||||
properties: convertNeo4jTypesToJSON(obj.properties),
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.type && obj.properties && obj.identity && obj.start && obj.end) {
|
||||
return {
|
||||
identity: obj.identity.toNumber ? obj.identity.toNumber() : obj.identity,
|
||||
start: obj.start.toNumber ? obj.start.toNumber() : obj.start,
|
||||
end: obj.end.toNumber ? obj.end.toNumber() : obj.end,
|
||||
type: obj.type,
|
||||
properties: convertNeo4jTypesToJSON(obj.properties),
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.start && obj.end && obj.segments) {
|
||||
return {
|
||||
start: convertNeo4jTypesToJSON(obj.start),
|
||||
end: convertNeo4jTypesToJSON(obj.end),
|
||||
segments: obj.segments.map((seg: any) => ({
|
||||
start: convertNeo4jTypesToJSON(seg.start),
|
||||
relationship: convertNeo4jTypesToJSON(seg.relationship),
|
||||
end: convertNeo4jTypesToJSON(seg.end),
|
||||
})),
|
||||
length: obj.length,
|
||||
}
|
||||
}
|
||||
|
||||
const result: Record<string, unknown> = {}
|
||||
for (const [key, val] of Object.entries(obj)) {
|
||||
result[key] = convertNeo4jTypesToJSON(val)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user