<commit_before>import { createCMAHttpClient, ClientParams } from '../create-cma-http-client'
import * as endpoints from './endpoints'
import { wrap, wrapHttp, DefaultParams } from './wrappers/wrap'

export type { DefaultParams } from './wrappers/wrap'
export type PlainClientAPI = ReturnType<typeof createPlainClient>

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type RestParamsType<F> = F extends (p1: any, ...rest: infer REST) => any ? REST : never

export const createPlainClient = (params: ClientParams, defaults?: DefaultParams) => {
  const http = createCMAHttpClient(params, true)
  const wrapParams = { http, defaults }

  return {
    raw: {
      getDefaultParams: () => defaults,
      get: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.get>) =>
        endpoints.raw.get<T>(http, ...args),
      post: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.post>) =>
        endpoints.raw.post<T>(http, ...args),
      put: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.put>) =>
        endpoints.raw.put<T>(http, ...args),
      delete: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.del>) =>
        endpoints.raw.del<T>(http, ...args),
      http: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.http>) =>
        endpoints.raw.http<T>(http, ...args),
    },
    editorInterface: {
      get: wrap(wrapParams, endpoints.editorInterface.get),
      getMany: wrap(wrapParams, endpoints.editorInterface.getMany),
      update: wrap(wrapParams, endpoints.editorInterface.update),
    },
    space: {
      get: wrap(wrapParams, endpoints.space.get),
      getMany: wrap(wrapParams, endpoints.space.getMany),
      update: wrap(wrapParams, endpoints.space.update),
      delete: wrap(wrapParams, endpoints.space.del),
      create: wrap(wrapParams, endpoints.space.create),
    },
    environment: {
      get: wrap(wrapParams, endpoints.environment.get),
      getMany: wrap(wrapParams, endpoints.environment.getMany),
      create: wrap(wrapParams, endpoints.environment.create),
      createWithId: wrap(wrapParams, endpoints.environment.createWithId),
      update: wrap(wrapParams, endpoints.environment.update),
      delete: wrap(wrapParams, endpoints.environment.del),
    },
    environmentAlias: {
      get: wrap(wrapParams, endpoints.environmentAlias.get),
      getMany: wrap(wrapParams, endpoints.environmentAlias.getMany),
      createWithId: wrap(wrapParams, endpoints.environmentAlias.createWithId),
      update: wrap(wrapParams, endpoints.environmentAlias.update),
      delete: wrap(wrapParams, endpoints.environmentAlias.del),
    },
    contentType: {
      get: wrap(wrapParams, endpoints.contentType.get),
      getMany: wrap(wrapParams, endpoints.contentType.getMany),
      update: wrap(wrapParams, endpoints.contentType.update),
      delete: wrap(wrapParams, endpoints.contentType.del),
      publish: wrap(wrapParams, endpoints.contentType.publish),
      unpublish: wrap(wrapParams, endpoints.contentType.unpublish),
      omitAndDeleteField: wrap(wrapParams, endpoints.contentType.omitAndDeleteField),
    },
    user: {
      getManyForSpace: wrap(wrapParams, endpoints.user.getManyForSpace),
      getForSpace: wrap(wrapParams, endpoints.user.getForSpace),
      getCurrent: wrapHttp(http, endpoints.user.getCurrent),
      getForOrganization: wrap(wrapParams, endpoints.user.getForOrganization),
      getManyForOrganization: wrap(wrapParams, endpoints.user.getManyForOrganization),
    },
    entry: {
      getMany: wrap(wrapParams, endpoints.entry.getMany),
      get: wrap(wrapParams, endpoints.entry.get),
      update: wrap(wrapParams, endpoints.entry.update),
      delete: wrap(wrapParams, endpoints.entry.del),
      publish: wrap(wrapParams, endpoints.entry.publish),
      unpublish: wrap(wrapParams, endpoints.entry.unpublish),
      archive: wrap(wrapParams, endpoints.entry.archive),
      unarchive: wrap(wrapParams, endpoints.entry.unarchive),<commit_msg>feat: optional params for user.getCurrent() (#669)<commit_after>import { createCMAHttpClient, ClientParams } from '../create-cma-http-client'
import * as endpoints from './endpoints'
import { wrap, wrapHttp, DefaultParams } from './wrappers/wrap'

export type { DefaultParams } from './wrappers/wrap'
export type PlainClientAPI = ReturnType<typeof createPlainClient>

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type RestParamsType<F> = F extends (p1: any, ...rest: infer REST) => any ? REST : never

export const createPlainClient = (params: ClientParams, defaults?: DefaultParams) => {
  const http = createCMAHttpClient(params, true)
  const wrapParams = { http, defaults }

  return {
    raw: {
      getDefaultParams: () => defaults,
      get: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.get>) =>
        endpoints.raw.get<T>(http, ...args),
      post: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.post>) =>
        endpoints.raw.post<T>(http, ...args),
      put: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.put>) =>
        endpoints.raw.put<T>(http, ...args),
      delete: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.del>) =>
        endpoints.raw.del<T>(http, ...args),
      http: <T = unknown>(...args: RestParamsType<typeof endpoints.raw.http>) =>
        endpoints.raw.http<T>(http, ...args),
    },
    editorInterface: {
      get: wrap(wrapParams, endpoints.editorInterface.get),
      getMany: wrap(wrapParams, endpoints.editorInterface.getMany),
      update: wrap(wrapParams, endpoints.editorInterface.update),
    },
    space: {
      get: wrap(wrapParams, endpoints.space.get),
      getMany: wrap(wrapParams, endpoints.space.getMany),
      update: wrap(wrapParams, endpoints.space.update),
      delete: wrap(wrapParams, endpoints.space.del),
      create: wrap(wrapParams, endpoints.space.create),
    },
    environment: {
      get: wrap(wrapParams, endpoints.environment.get),
      getMany: wrap(wrapParams, endpoints.environment.getMany),
      create: wrap(wrapParams, endpoints.environment.create),
      createWithId: wrap(wrapParams, endpoints.environment.createWithId),
      update: wrap(wrapParams, endpoints.environment.update),
      delete: wrap(wrapParams, endpoints.environment.del),
    },
    environmentAlias: {
      get: wrap(wrapParams, endpoints.environmentAlias.get),
      getMany: wrap(wrapParams, endpoints.environmentAlias.getMany),
      createWithId: wrap(wrapParams, endpoints.environmentAlias.createWithId),
      update: wrap(wrapParams, endpoints.environmentAlias.update),
      delete: wrap(wrapParams, endpoints.environmentAlias.del),
    },
    contentType: {
      get: wrap(wrapParams, endpoints.contentType.get),
      getMany: wrap(wrapParams, endpoints.contentType.getMany),
      update: wrap(wrapParams, endpoints.contentType.update),
      delete: wrap(wrapParams, endpoints.contentType.del),
      publish: wrap(wrapParams, endpoints.contentType.publish),
      unpublish: wrap(wrapParams, endpoints.contentType.unpublish),
      omitAndDeleteField: wrap(wrapParams, endpoints.contentType.omitAndDeleteField),
    },
    user: {
      getManyForSpace: wrap(wrapParams, endpoints.user.getManyForSpace),
      getForSpace: wrap(wrapParams, endpoints.user.getForSpace),
      getCurrent: (...args: RestParamsType<typeof endpoints.user.getCurrent>) => {
        return endpoints.user.getCurrent(http, ...args)
      },
      getForOrganization: wrap(wrapParams, endpoints.user.getForOrganization),
      getManyForOrganization: wrap(wrapParams, endpoints.user.getManyForOrganization),
    },
    entry: {
      getMany: wrap(wrapParams, endpoints.entry.getMany),
      get: wrap(wrapParams, endpoints.entry.get),
      update: wrap(wrapParams, endpoints.entry.update),
      delete: wrap(wrapParams, endpoints.entry.del),
      publish: wrap(wrapParams, endpoints.entry.publish),
      unpublish: wrap(wrapParams, endpoints.entry.unpublish),
      archive: wrap(wrapParams, endpoints.entry.archive),
      unarchive: wrap(wrapParams, endpoints.entry.unarchive),
{'fraction_non_alphanumeric': 0.13287231415164238, 'fraction_numerical': 0.0006174364040503828, 'mean_word_length': 3.9565483476132193, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '87562', 'n_tokens_mistral': 2391, 'n_tokens_neox': 2292, 'n_words': 444}