Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | 1x 79x 67x 27x 27x 9x 9x 9x 9x 9x 9x 9x 9x 9x 2x 1x 8x 8x 8x 2x 1x | "use strict";
const _ = require("lodash");
function defineProperty(element, prop, value) {
Object.defineProperty(element, prop, {
get: () => value,
});
}
function defineOptionalNumber(element, prop) {
let value = _.has(element.raw.$, prop)
? Number(element.raw.$[prop])
: undefined;
defineProperty(element, _.lowerFirst(prop), value);
}
/**
* Envelops an function import parameter.
*
* There are substantial differences between MC-CSLD and OASIS-CSDL. SAP implementation follows MS-CSDL.
* OASIS-CSDL doesn't have function import parameters, it has action and function parameters (~ model function parameters).
*
* https://docs.microsoft.com/en-us/openspecs/windows_protocols/mc-csdl/2d7f0f3e-1333-4309-8194-a0148a9c946c
*
* @class FunctionImportParameter
*/
class FunctionImportParameter {
/**
* Creates an instance of FunctionImportParameter.
* @param {Object} rawMetadata raw metadata object for the function import
* @param {CsdlSchema} schema to resolve model references
* @memberof FunctionImportParameter
*/
constructor(rawMetadata, schema) {
let mode = rawMetadata.$.Mode;
defineProperty(this, "raw", rawMetadata);
defineProperty(this, "name", rawMetadata.$.Name);
defineProperty(this, "type", schema.getType(rawMetadata.$.Type));
defineOptionalNumber(this, "MaxLength");
defineProperty(this, "nullable", rawMetadata.$.Nullable !== "false");
defineOptionalNumber(this, "Precision");
defineOptionalNumber(this, "Scale");
if (!["In", "Out", "InOut"].includes(mode)) {
Iif (schema.settings.strict !== false) {
throw new Error(
`Unknown mode '${this.mode} for function import parameter '${this.name}`
);
} else {
mode = "In";
}
}
defineProperty(this, "mode", mode);
let extensions = [];
defineProperty(this, "extensions", extensions);
}
/**
* Gets legacy api object. (XML casing, maybe some other changes.)
*
* @returns {Object} legacy api object
* @memberof FunctionImport
*/
getLegacyApiObject() {
return {
MaxLength: this.maxLength,
Mode: this.mode,
Name: this.name,
Nullable: this.nullable,
Precision: this.precision,
Scale: this.scale,
Type: this.type.namespaceQualifiedName,
};
}
}
module.exports = FunctionImportParameter;
|