Where are the ColorConversionModel constants defined?

I’m trying to build a SolidColor from the return from the color picker, which I’m reading with:

async function doColorPicker() {
  try {
    const batchPlay = require('photoshop').action.batchPlay;
    const lastCustomSelected = await batchPlay([{
      '_obj': 'showColorPicker',
      'application': {
        '_class': 'null'
      'value': true,
      'color': {
        '_obj': 'rgbColor',
        'red': parseInt(lastCustomColour.substring(0,2), 16),
        'grain': parseInt(lastCustomColour.substring(2,4), 16),
        'blue': parseInt(lastCustomColour.substring(4,6), 16)
      'dontRecord': true,
      'forceNotify': true,
    }], {
      'synchronousExecution': true
    return lastCustomSelected;
  } catch(e) {
    console.log(`doColorPicker: ${e}`);

I can deal with all the values of lastCustomSelected._obj other than ‘bookColor’, which you get if the colour is chosen from a colour book instead of the basic picker.
I saw the core.convertColor call, and tried to use that, but it needs a constant such as ColorConversionModel.RGB. That’s not accessible under require("photoshop").constants.
Not sure where to look next.

My best bet would be to refer to the ColorModel constant, whose description says:

The color model representing the current color space of a SolidColor object.

Thanks, but … it needs a number rather than a string. So I just tried a few numbers:
1 - invalid
2 - invalid
3 - RGB
4 - HSB
5 - CMYK
6 - LAB

So I tried using 2 to convert from a colour book entry and it fails with “Error: Illegal data type. ByteArray is not supported for this operation”, just like every other method I’ve tried. The colour descriptor contains a ‘bookKey’ property with an ArrayBuffer value.

The colour book view shows the selected colour values in Lab or CMYK, but that’s not encoded into the bookKey array as far as I can see. I think it must be a unique ID to reference PS’s internal library of colour books.

I think I’m just going to bounce any attempt to use a colour book, but it’s all a bit frustrating, especially when .acb is such a trivial format to read if I had access.

You would better not use numbers. If someone responsible for DOM decides e.g. reorder enums by alphabet it will change all numbers and your code will break. If you use enums from constants it always will have the correct number under the hood. It just needs correct constant.

Also when getting a descriptor you get ByteArray. But when you want to play it back it has to be base64 string only.

Thanks Jarda. I’m only using numbers because the constants are not defined in require("photoshop").constants and I can’t see them anywhere else.
I just tried a probably rather simplistic conversion from array buffer to base64 string and I just get a Photoshop exception on the convertColor call.

function arrayBufferToBase64( buffer ) {
    var binary = '';
    var bytes = new Uint8Array( buffer );
    var len = bytes.byteLength;
    for (var i = 0; i < len; i++) {
        binary += String.fromCharCode( bytes[ i ] );
    return window.btoa( binary );

async function doColourPicker(pickerStartColour) {
  try {
    const bpres = await batchPlay([{
      '_obj': 'showColorPicker',
      'application': { '_class': 'null' },
      'value': true,
      'color': pickerStartColour,
      'dontRecord': true,
      'forceNotify': true,
       '_target': { _ref: 'application'} 
    }], { });
    if (!bpres[0].value) { return null; }
    const colourPicked = bpres[0].color;
    return colourPicked;
  } catch(e) {
    await showError('doColourPicker', e, translations, true, config, walkResult);

async function test7core(){
  const colourDesc = await doColourPicker({
    "_obj": "RGBColor",
    "red": 159.99610894941634,
    "grain": 69.00389105058366,
    "blue": 21.003891050583658
  if (colourDesc._obj == 'bookColor') {
    const base64String = arrayBufferToBase64(colourDesc.bookKey);
    colourDesc.bookKey = base64String;
  const rgbDesc = await core.convertColor(colourDesc, 3);
  console.log (rgbDesc);

async function test7() {
  try {
    await core.executeAsModal(test7core);
  } catch(e) {