box-node-sdk
Version:
Official SDK for Box Platform APIs
230 lines • 9.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeAiExtractStructuredMetadataTemplateTypeField = serializeAiExtractStructuredMetadataTemplateTypeField;
exports.deserializeAiExtractStructuredMetadataTemplateTypeField = deserializeAiExtractStructuredMetadataTemplateTypeField;
exports.serializeAiExtractStructuredMetadataTemplateField = serializeAiExtractStructuredMetadataTemplateField;
exports.deserializeAiExtractStructuredMetadataTemplateField = deserializeAiExtractStructuredMetadataTemplateField;
exports.serializeAiExtractStructuredFieldsOptionsField = serializeAiExtractStructuredFieldsOptionsField;
exports.deserializeAiExtractStructuredFieldsOptionsField = deserializeAiExtractStructuredFieldsOptionsField;
exports.serializeAiExtractStructuredFieldsField = serializeAiExtractStructuredFieldsField;
exports.deserializeAiExtractStructuredFieldsField = deserializeAiExtractStructuredFieldsField;
exports.serializeAiExtractStructured = serializeAiExtractStructured;
exports.deserializeAiExtractStructured = deserializeAiExtractStructured;
const aiItemBase_1 = require("./aiItemBase");
const aiItemBase_2 = require("./aiItemBase");
const aiExtractStructuredAgent_1 = require("./aiExtractStructuredAgent");
const aiExtractStructuredAgent_2 = require("./aiExtractStructuredAgent");
const errors_1 = require("../box/errors");
const json_1 = require("../serialization/json");
const json_2 = require("../serialization/json");
const json_3 = require("../serialization/json");
function serializeAiExtractStructuredMetadataTemplateTypeField(val) {
return val;
}
function deserializeAiExtractStructuredMetadataTemplateTypeField(val) {
if (val == 'metadata_template') {
return val;
}
throw new errors_1.BoxSdkError({
message: "Can't deserialize AiExtractStructuredMetadataTemplateTypeField",
});
}
function serializeAiExtractStructuredMetadataTemplateField(val) {
return {
['template_key']: val.templateKey,
['type']: val.type == void 0
? val.type
: serializeAiExtractStructuredMetadataTemplateTypeField(val.type),
['scope']: val.scope,
};
}
function deserializeAiExtractStructuredMetadataTemplateField(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "AiExtractStructuredMetadataTemplateField"',
});
}
if (!(val.template_key == void 0) && !(0, json_1.sdIsString)(val.template_key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "template_key" of type "AiExtractStructuredMetadataTemplateField"',
});
}
const templateKey = val.template_key == void 0 ? void 0 : val.template_key;
const type = val.type == void 0
? void 0
: deserializeAiExtractStructuredMetadataTemplateTypeField(val.type);
if (!(val.scope == void 0) && !(0, json_1.sdIsString)(val.scope)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "scope" of type "AiExtractStructuredMetadataTemplateField"',
});
}
const scope = val.scope == void 0 ? void 0 : val.scope;
return {
templateKey: templateKey,
type: type,
scope: scope,
};
}
function serializeAiExtractStructuredFieldsOptionsField(val) {
return { ['key']: val.key };
}
function deserializeAiExtractStructuredFieldsOptionsField(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "AiExtractStructuredFieldsOptionsField"',
});
}
if (val.key == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "key" of type "AiExtractStructuredFieldsOptionsField" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "key" of type "AiExtractStructuredFieldsOptionsField"',
});
}
const key = val.key;
return { key: key };
}
function serializeAiExtractStructuredFieldsField(val) {
return {
['key']: val.key,
['description']: val.description,
['displayName']: val.displayName,
['prompt']: val.prompt,
['type']: val.type,
['options']: val.options == void 0
? val.options
: val.options.map(function (item) {
return serializeAiExtractStructuredFieldsOptionsField(item);
}),
};
}
function deserializeAiExtractStructuredFieldsField(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "AiExtractStructuredFieldsField"',
});
}
if (val.key == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "key" of type "AiExtractStructuredFieldsField" to be defined',
});
}
if (!(0, json_1.sdIsString)(val.key)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "key" of type "AiExtractStructuredFieldsField"',
});
}
const key = val.key;
if (!(val.description == void 0) && !(0, json_1.sdIsString)(val.description)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "description" of type "AiExtractStructuredFieldsField"',
});
}
const description = val.description == void 0 ? void 0 : val.description;
if (!(val.displayName == void 0) && !(0, json_1.sdIsString)(val.displayName)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "displayName" of type "AiExtractStructuredFieldsField"',
});
}
const displayName = val.displayName == void 0 ? void 0 : val.displayName;
if (!(val.prompt == void 0) && !(0, json_1.sdIsString)(val.prompt)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "prompt" of type "AiExtractStructuredFieldsField"',
});
}
const prompt = val.prompt == void 0 ? void 0 : val.prompt;
if (!(val.type == void 0) && !(0, json_1.sdIsString)(val.type)) {
throw new errors_1.BoxSdkError({
message: 'Expecting string for "type" of type "AiExtractStructuredFieldsField"',
});
}
const type = val.type == void 0 ? void 0 : val.type;
if (!(val.options == void 0) && !(0, json_2.sdIsList)(val.options)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "options" of type "AiExtractStructuredFieldsField"',
});
}
const options = val.options == void 0
? void 0
: (0, json_2.sdIsList)(val.options)
? val.options.map(function (itm) {
return deserializeAiExtractStructuredFieldsOptionsField(itm);
})
: [];
return {
key: key,
description: description,
displayName: displayName,
prompt: prompt,
type: type,
options: options,
};
}
function serializeAiExtractStructured(val) {
return {
['items']: val.items.map(function (item) {
return (0, aiItemBase_1.serializeAiItemBase)(item);
}),
['metadata_template']: val.metadataTemplate == void 0
? val.metadataTemplate
: serializeAiExtractStructuredMetadataTemplateField(val.metadataTemplate),
['fields']: val.fields == void 0
? val.fields
: val.fields.map(function (item) {
return serializeAiExtractStructuredFieldsField(item);
}),
['ai_agent']: val.aiAgent == void 0
? val.aiAgent
: (0, aiExtractStructuredAgent_1.serializeAiExtractStructuredAgent)(val.aiAgent),
};
}
function deserializeAiExtractStructured(val) {
if (!(0, json_3.sdIsMap)(val)) {
throw new errors_1.BoxSdkError({
message: 'Expecting a map for "AiExtractStructured"',
});
}
if (val.items == void 0) {
throw new errors_1.BoxSdkError({
message: 'Expecting "items" of type "AiExtractStructured" to be defined',
});
}
if (!(0, json_2.sdIsList)(val.items)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "items" of type "AiExtractStructured"',
});
}
const items = (0, json_2.sdIsList)(val.items)
? val.items.map(function (itm) {
return (0, aiItemBase_2.deserializeAiItemBase)(itm);
})
: [];
const metadataTemplate = val.metadata_template == void 0
? void 0
: deserializeAiExtractStructuredMetadataTemplateField(val.metadata_template);
if (!(val.fields == void 0) && !(0, json_2.sdIsList)(val.fields)) {
throw new errors_1.BoxSdkError({
message: 'Expecting array for "fields" of type "AiExtractStructured"',
});
}
const fields = val.fields == void 0
? void 0
: (0, json_2.sdIsList)(val.fields)
? val.fields.map(function (itm) {
return deserializeAiExtractStructuredFieldsField(itm);
})
: [];
const aiAgent = val.ai_agent == void 0
? void 0
: (0, aiExtractStructuredAgent_2.deserializeAiExtractStructuredAgent)(val.ai_agent);
return {
items: items,
metadataTemplate: metadataTemplate,
fields: fields,
aiAgent: aiAgent,
};
}
//# sourceMappingURL=aiExtractStructured.js.map