@sprucelabs/schema
Version:
Static and dynamic binding plus runtime validation and transformation to ensure your app is sound. 🤓
31 lines (30 loc) • 1.14 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const AbstractField_1 = __importDefault(require("./AbstractField"));
class RawField extends AbstractField_1.default {
static generateTemplateDetails(options) {
const { definition, language } = options;
const { isArray } = definition;
const { options: fieldOptions } = definition;
const { valueType } = fieldOptions;
const arrayNotation = isArray ? '[]' : '';
let resolvedType = valueType;
if (language === 'go') {
const goType = valueType === 'Record<string, any>'
? 'map[string]interface{}'
: 'interface{}';
resolvedType = `${arrayNotation}${goType}`;
}
else {
resolvedType = `(${valueType})${arrayNotation}`;
}
return {
valueType: resolvedType,
};
}
}
RawField.description = 'Set an interface directly.';
exports.default = RawField;