PHP 8.2.30
Preview: prepare-params.ts Size: 1.47 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/src/utils/param-converter/prepare-params.ts

import { BaseResource } from '../../backend/adapters/resource/index.js'
import { flat } from '../flat/index.js'
import { convertNestedParam } from './convert-nested-param.js'
import { convertParam } from './convert-param.js'

const prepareParams = (
  params: Record<string, any>,
  resource: BaseResource,
): Record<string, any> => {
  const properties = resource.properties()
  const preparedParams: Record<string, any> = {}

  for (const property of properties) {
    let param = flat.get(params, property.path())
    const key = property.path()
    const propertyDecorator = resource._decorated?.properties[key].toJSON()

    // eslint-disable-next-line no-continue
    if (param === undefined || param === null) continue

    if (property.type() !== 'mixed') {
      if (propertyDecorator?.isArray) {
        preparedParams[key] = param.map((p) => convertParam(p, property.type()))
      } else {
        preparedParams[key] = convertParam(param, property.type())
      }
    } else {
      if (param !== null && propertyDecorator?.subProperties.length) {
        const { subProperties } = propertyDecorator
        for (const subProperty of subProperties) {
          if (propertyDecorator.isArray) {
            param = param.map((p) => convertNestedParam(p, subProperty))
          } else {
            param = convertNestedParam(param, subProperty)
          }
        }
      }

      preparedParams[key] = param
    }
  }

  return { ...params, ...preparedParams }
}

export { prepareParams }

Directory Contents

Dirs: 0 × Files: 9

Name Size Perms Modified Actions
44 B lrw-r--r-- 2026-02-28 00:32:02
Edit Download
1.91 KB lrw-r--r-- 2026-02-28 00:32:02
Edit Download
990 B lrw-r--r-- 2026-02-28 00:32:02
Edit Download
819 B lrw-r--r-- 2026-02-28 00:32:02
Edit Download
403 B lrw-r--r-- 2026-02-28 00:32:02
Edit Download
44 B lrw-r--r-- 2026-02-28 00:32:28
Edit Download
537 B lrw-r--r-- 2026-02-28 00:32:40
Edit Download
1.47 KB lrw-r--r-- 2026-02-28 00:32:40
Edit Download
1.18 KB lrw-r--r-- 2026-02-28 00:32:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).