Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-generator

Package Overview
Dependencies
Maintainers
1
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-generator - npm Package Compare versions

Comparing version 2.55.0 to 2.56.0

9

dist/factory_code_generator.js

@@ -10,7 +10,7 @@ "use strict";

// tslint:disable:max-depth
const os = require("os");
const path = require("path");
const fs = require("fs");
const node_opcua_assert_1 = require("node-opcua-assert");
const node_opcua_factory_1 = require("node-opcua-factory");
const os = require("os");
const path = require("path");
const node_opcua_constants_1 = require("node-opcua-constants");

@@ -49,2 +49,3 @@ const node_opcua_debug_1 = require("node-opcua-debug");

else if (typeof obj === "function") {
/** */
}

@@ -129,3 +130,3 @@ else {

if (field.isArray) {
if (field.hasOwnProperty("defaultValue")) {
if (Object.prototype.hasOwnProperty.call(field, "defaultValue")) {
// todo: fix me => should call field defaultValue in the live version

@@ -765,3 +766,3 @@ write(` this.${member} = []; // should default`);

for (const field of complexTypes) {
if (tmpMap.hasOwnProperty(field.fieldType)) {
if (Object.prototype.hasOwnProperty.call(tmpMap, field.fieldType)) {
continue;

@@ -768,0 +769,0 @@ }

@@ -13,2 +13,3 @@ "use strict";

exports.generate = void 0;
/* eslint-disable max-statements */
/* istanbul ignore file */

@@ -21,4 +22,4 @@ /**

//
const fs = require("fs");
const chalk = require("chalk");
const fs = require("fs");
// node 14 onward : import { readFile } from "fs/promises";

@@ -40,2 +41,3 @@ const { readFile } = fs.promises;

const write = (0, write_func_1.makeWrite)(f);
// eslint-disable-next-line max-statements
function writeEnumeratedType(enumerationSchema) {

@@ -53,3 +55,3 @@ const arrayValues = Object.keys(enumerationSchema.enumValues)

// make sure there is a Invalid key in the enum => else insert one (but only if not flaggable)
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid");
const hasInvalid = Object.prototype.hasOwnProperty.call(enumerationSchema.enumValues, "Invalid");
if (!hasInvalid && !isFlaggable) {

@@ -130,32 +132,31 @@ enumerationSchema.enumValues[(enumerationSchema.enumValues.Invalid = 0xffffffff)] = "Invalid";

return __awaiter(this, void 0, void 0, function* () {
try {
const content = yield readFile(filename, "ascii");
const idProvider = {
getDataTypeAndEncodingId(name) {
const dataType = node_opcua_constants_1.DataTypeIds[name] || 0;
const binEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultBinary"] || 0;
const xmlEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultXml"] || 0;
const jsonEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultJson"] || 0;
if (dataType === undefined) {
return null;
}
const dataTypeNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, dataType, 0);
const binaryEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, binEncoding, 0);
const xmlEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, xmlEncoding, 0);
const jsonEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, jsonEncoding, 0);
const data = {
binaryEncodingNodeId,
dataTypeNodeId,
jsonEncodingNodeId,
xmlEncodingNodeId
};
if (doDebug) {
debugLog(" data=", chalk.cyan(name.padEnd(43, " ")), data.dataTypeNodeId.toString().padEnd(43, " "), data.binaryEncodingNodeId.toString().padEnd(43, " "));
}
return data;
const content = yield readFile(filename, "ascii");
const idProvider = {
getDataTypeAndEncodingId(name) {
const dataType = node_opcua_constants_1.DataTypeIds[name] || 0;
const binEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultBinary"] || 0;
const xmlEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultXml"] || 0;
const jsonEncoding = node_opcua_constants_1.ObjectIds[name + "_Encoding_DefaultJson"] || 0;
if (dataType === undefined) {
return null;
}
};
const dataTypeFactory = new node_opcua_factory_1.DataTypeFactory([(0, node_opcua_factory_1.getStandardDataTypeFactory)()]);
yield (0, node_opcua_schemas_1.parseBinaryXSDAsync)(content, idProvider, dataTypeFactory);
write(`// tslint:disable:no-this-assignment
const dataTypeNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, dataType, 0);
const binaryEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, binEncoding, 0);
const xmlEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, xmlEncoding, 0);
const jsonEncodingNodeId = new node_opcua_nodeid_1.NodeId(node_opcua_nodeid_1.NodeId.NodeIdType.NUMERIC, jsonEncoding, 0);
const data = {
binaryEncodingNodeId,
dataTypeNodeId,
jsonEncodingNodeId,
xmlEncodingNodeId
};
if (doDebug) {
debugLog(" data=", chalk.cyan(name.padEnd(43, " ")), data.dataTypeNodeId.toString().padEnd(43, " "), data.binaryEncodingNodeId.toString().padEnd(43, " "));
}
return data;
}
};
const dataTypeFactory = new node_opcua_factory_1.DataTypeFactory([(0, node_opcua_factory_1.getStandardDataTypeFactory)()]);
yield (0, node_opcua_schemas_1.parseBinaryXSDAsync)(content, idProvider, dataTypeFactory);
write(`// tslint:disable:no-this-assignment
// tslint:disable:max-classes-per-file

@@ -240,74 +241,74 @@ // tslint:disable:no-empty-interface

} from "node-opcua-variant";`);
write(``);
write(`export class DataTypeDefinition extends BaseUAObject {`);
write(` constructor(options: any) {`);
write(` options = options; // do not remove`);
write(` super();`);
write(` }`);
write(`}`);
write(``);
const alreadyDone = {};
/* tslint:disable:no-string-literal */
alreadyDone["ExtensionObject"] = true;
alreadyDone["NodeId"] = true;
alreadyDone["ExpandedNodeId"] = true;
alreadyDone["Variant"] = true;
alreadyDone["XmlElement"] = true;
alreadyDone["NodeIdType"] = true;
alreadyDone["TwoByteNodeId"] = true;
alreadyDone["FourByteNodeId"] = true;
alreadyDone["NumericNodeId"] = true;
alreadyDone["StringNodeId"] = true;
alreadyDone["GuidNodeId"] = true;
alreadyDone["ByteStringNodeId"] = true;
alreadyDone["DiagnosticInfo"] = true;
alreadyDone["Variant"] = true;
alreadyDone["DataValue"] = true;
alreadyDone["LocalizedText"] = true;
alreadyDone["QualifiedName"] = true;
alreadyDone["BrowseDirection"] = true;
alreadyDone["TimestampsToReturn"] = true;
function processEnumeratedType(enumerationSchema) {
if (alreadyDone[enumerationSchema.name]) {
return;
}
alreadyDone[enumerationSchema.name] = enumerationSchema;
writeEnumeratedType(enumerationSchema);
write(``);
write(`export class DataTypeDefinition extends BaseUAObject {`);
write(` constructor(options: any) {`);
write(` options = options; // do not remove`);
write(` super();`);
write(` }`);
write(`}`);
write(``);
const alreadyDone = {};
/* tslint:disable:no-string-literal */
alreadyDone["ExtensionObject"] = true;
alreadyDone["NodeId"] = true;
alreadyDone["ExpandedNodeId"] = true;
alreadyDone["Variant"] = true;
alreadyDone["XmlElement"] = true;
alreadyDone["NodeIdType"] = true;
alreadyDone["TwoByteNodeId"] = true;
alreadyDone["FourByteNodeId"] = true;
alreadyDone["NumericNodeId"] = true;
alreadyDone["StringNodeId"] = true;
alreadyDone["GuidNodeId"] = true;
alreadyDone["ByteStringNodeId"] = true;
alreadyDone["DiagnosticInfo"] = true;
alreadyDone["Variant"] = true;
alreadyDone["DataValue"] = true;
alreadyDone["LocalizedText"] = true;
alreadyDone["QualifiedName"] = true;
alreadyDone["BrowseDirection"] = true;
alreadyDone["TimestampsToReturn"] = true;
function processEnumeratedType(enumerationSchema) {
if (alreadyDone[enumerationSchema.name]) {
return;
}
function processStructuredType(structuredType) {
if (alreadyDone[structuredType.name]) {
return;
alreadyDone[enumerationSchema.name] = enumerationSchema;
writeEnumeratedType(enumerationSchema);
}
function processStructuredType(structuredType) {
if (alreadyDone[structuredType.name]) {
return;
}
alreadyDone[structuredType.name] = structuredType;
// make sure
if (dataTypeFactory.hasStructuredType(structuredType.baseType)) {
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structuredType.baseType));
}
for (const field of structuredType.fields) {
if (field.category === node_opcua_factory_1.FieldCategory.complex) {
const fieldSchema = dataTypeFactory.getStructuredTypeSchema(field.fieldType);
processStructuredType(fieldSchema);
}
alreadyDone[structuredType.name] = structuredType;
// make sure
if (dataTypeFactory.hasStructuredType(structuredType.baseType)) {
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structuredType.baseType));
if (field.category === node_opcua_factory_1.FieldCategory.enumeration) {
const fieldSchema = dataTypeFactory.getEnumeration(field.fieldType);
processEnumeratedType(fieldSchema);
}
for (const field of structuredType.fields) {
if (field.category === node_opcua_factory_1.FieldCategory.complex) {
const fieldSchema = dataTypeFactory.getStructuredTypeSchema(field.fieldType);
processStructuredType(fieldSchema);
}
if (field.category === node_opcua_factory_1.FieldCategory.enumeration) {
const fieldSchema = dataTypeFactory.getEnumeration(field.fieldType);
processEnumeratedType(fieldSchema);
}
}
writeStructuredTypeWithSchema(structuredType);
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation"));
// processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("SimpleAttributeOperand"));
for (const structureType of [...dataTypeFactory.structuredTypesNames()].sort()) {
if (!dataTypeFactory.hasStructuredType(structureType)) {
continue;
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structureType));
// if (++i > 250) { break; }
writeStructuredTypeWithSchema(structuredType);
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation"));
// processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("SimpleAttributeOperand"));
for (const structureType of [...dataTypeFactory.structuredTypesNames()].sort()) {
if (!dataTypeFactory.hasStructuredType(structureType)) {
continue;
}
write(``);
f.saveFormat(generatedTypescriptFilename, (code) => {
return code;
/*
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structureType));
// if (++i > 250) { break; }
}
write(``);
f.saveFormat(generatedTypescriptFilename, (code) => {
return code;
/*
const options: prettier.Options = {

@@ -321,7 +322,3 @@ bracketSpacing: true,

*/
});
}
catch (err) {
throw err;
}
});
});

@@ -328,0 +325,0 @@ }

@@ -6,2 +6,4 @@ import { ConstructorFunc } from "node-opcua-factory";

export declare function registerObject(schema: string, generateCodeFolder?: string): Promise<ConstructorFunc | null>;
export declare function unregisterObject(schema: any, folder: string): void;
export declare function unregisterObject(schema: {
name: string;
}, folder: string): void;

@@ -25,5 +25,3 @@ "use strict";

}
main()
.then()
.catch();
main().then().catch();
//# sourceMappingURL=opcua_code_generator.js.map

@@ -7,2 +7,2 @@ import { LineFile1 } from "./line_file";

}
export declare const makeWrite: (f: LineFile1) => any;
export declare const makeWrite: (f: LineFile1) => WriteFunc;

@@ -5,3 +5,3 @@ "use strict";

const makeWrite = (f) => {
const _f = (...args) => f.write.apply(f, args);
const _f = (...args) => f.write(...args);
_f.indent = () => {

@@ -8,0 +8,0 @@ /** */

{
"name": "node-opcua-generator",
"version": "2.55.0",
"version": "2.56.0",
"description": "pure nodejs OPCUA SDK - module -generator",

@@ -9,2 +9,4 @@ "main": "./dist/index.js",

"build": "tsc -b",
"lint": "eslint source test",
"format": "prettier --write source test",
"clean": "node -e \"require('rimraf').sync('dist');\"",

@@ -16,24 +18,24 @@ "test": "mocha"

"node-opcua-assert": "2.55.0",
"node-opcua-basic-types": "2.55.0",
"node-opcua-basic-types": "2.56.0",
"node-opcua-buffer-utils": "2.55.0",
"node-opcua-constants": "2.52.0",
"node-opcua-data-model": "2.55.0",
"node-opcua-data-value": "2.55.0",
"node-opcua-data-model": "2.56.0",
"node-opcua-data-value": "2.56.0",
"node-opcua-date-time": "2.55.0",
"node-opcua-debug": "2.55.0",
"node-opcua-enum": "2.55.0",
"node-opcua-factory": "2.55.0",
"node-opcua-factory": "2.56.0",
"node-opcua-guid": "2.55.0",
"node-opcua-nodeid": "2.55.0",
"node-opcua-numeric-range": "2.55.0",
"node-opcua-schemas": "2.55.0",
"node-opcua-status-code": "2.55.0",
"node-opcua-utils": "2.55.0",
"node-opcua-variant": "2.55.0",
"node-opcua-xml2json": "2.55.0"
"node-opcua-numeric-range": "2.56.0",
"node-opcua-schemas": "2.56.0",
"node-opcua-status-code": "2.56.0",
"node-opcua-utils": "2.56.0",
"node-opcua-variant": "2.56.0",
"node-opcua-xml2json": "2.56.0"
},
"devDependencies": {
"node-opcua-binary-stream": "2.55.0",
"node-opcua-extension-object": "2.55.0",
"node-opcua-packet-analyzer": "2.55.0",
"node-opcua-extension-object": "2.56.0",
"node-opcua-packet-analyzer": "2.56.0",
"prettier": "^2.4.1",

@@ -59,3 +61,3 @@ "should": "^13.2.3",

"homepage": "http://node-opcua.github.io/",
"gitHead": "28fdbfe1c5306fd0e69758ccacfa2c6d1722115c"
"gitHead": "9f6eac1c658c0d182fbe03cf58f799af468615eb"
}

@@ -9,3 +9,6 @@ /* istanbul ignore file */

import * as os from "os";
import * as path from "path";
import * as fs from "fs";
import { assert } from "node-opcua-assert";

@@ -20,4 +23,2 @@ import {

} from "node-opcua-factory";
import * as os from "os";
import * as path from "path";

@@ -63,2 +64,3 @@ import { DataTypeIds, ObjectIds } from "node-opcua-constants";

} else if (typeof obj === "function") {
/** */
} else {

@@ -153,3 +155,3 @@ lines.push(JSON.stringify(obj));

if (field.isArray) {
if (field.hasOwnProperty("defaultValue")) {
if (Object.prototype.hasOwnProperty.call(field, "defaultValue")) {
// todo: fix me => should call field defaultValue in the live version

@@ -681,3 +683,3 @@ write(` this.${member} = []; // should default`);

export function writeStructuredType(write: WriteFunc, schema: StructuredTypeSchema) {
export function writeStructuredType(write: WriteFunc, schema: StructuredTypeSchema): void {
const className = schema.name;

@@ -790,3 +792,7 @@ const baseClass = schema.baseType;

/* eslint complexity:[0,50], max-statements: [1, 254]*/
export function produce_TScript_code(schema: StructuredTypeSchema, localSchemaFile: string, generatedTypescriptFilename: string) {
export function produce_TScript_code(
schema: StructuredTypeSchema,
localSchemaFile: string,
generatedTypescriptFilename: string
): void {
const className = schema.name;

@@ -850,3 +856,3 @@

for (const field of complexTypes) {
if (tmpMap.hasOwnProperty(field.fieldType)) {
if (Object.prototype.hasOwnProperty.call(tmpMap, field.fieldType)) {
continue;

@@ -853,0 +859,0 @@ }

@@ -0,1 +1,2 @@

/* eslint-disable max-statements */
/* istanbul ignore file */

@@ -8,6 +9,6 @@ /**

//
import * as fs from "fs";
import * as chalk from "chalk";
import * as fs from "fs";
// node 14 onward : import { readFile } from "fs/promises";
const { readFile }= fs.promises;
const { readFile } = fs.promises;

@@ -36,3 +37,2 @@ // import * as prettier from "prettier";

const f = new LineFile1();

@@ -42,3 +42,4 @@

function writeEnumeratedType(enumerationSchema: EnumerationDefinitionSchema) {
// eslint-disable-next-line max-statements
function writeEnumeratedType(enumerationSchema: EnumerationDefinitionSchema): void {
const arrayValues = Object.keys(enumerationSchema.enumValues)

@@ -57,3 +58,3 @@ .filter((a: string) => a.match("[0-9]+"))

// make sure there is a Invalid key in the enum => else insert one (but only if not flaggable)
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid");
const hasInvalid = Object.prototype.hasOwnProperty.call(enumerationSchema.enumValues, "Invalid");
if (!hasInvalid && !isFlaggable) {

@@ -144,42 +145,41 @@ enumerationSchema.enumValues[(enumerationSchema.enumValues.Invalid = 0xffffffff)] = "Invalid";

export async function generate(filename: string, generatedTypescriptFilename: string) {
try {
const content = await readFile(filename, "ascii");
export async function generate(filename: string, generatedTypescriptFilename: string): Promise<void> {
const content = await readFile(filename, "ascii");
const idProvider: MapDataTypeAndEncodingIdProvider = {
getDataTypeAndEncodingId(name: string): DataTypeAndEncodingId | null {
const dataType = (DataTypeIds as any)[name] || 0;
const binEncoding = (ObjectIds as any)[name + "_Encoding_DefaultBinary"] || 0;
const xmlEncoding = (ObjectIds as any)[name + "_Encoding_DefaultXml"] || 0;
const jsonEncoding = (ObjectIds as any)[name + "_Encoding_DefaultJson"] || 0;
if (dataType === undefined) {
return null;
}
const dataTypeNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, dataType, 0);
const binaryEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, binEncoding, 0);
const xmlEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, xmlEncoding, 0);
const jsonEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, jsonEncoding, 0);
const data: DataTypeAndEncodingId = {
binaryEncodingNodeId,
dataTypeNodeId,
jsonEncodingNodeId,
xmlEncodingNodeId
};
if (doDebug) {
debugLog(
" data=",
chalk.cyan(name.padEnd(43, " ")),
data.dataTypeNodeId.toString().padEnd(43, " "),
data.binaryEncodingNodeId.toString().padEnd(43, " ")
);
}
return data;
const idProvider: MapDataTypeAndEncodingIdProvider = {
getDataTypeAndEncodingId(name: string): DataTypeAndEncodingId | null {
const dataType = (DataTypeIds as any)[name] || 0;
const binEncoding = (ObjectIds as any)[name + "_Encoding_DefaultBinary"] || 0;
const xmlEncoding = (ObjectIds as any)[name + "_Encoding_DefaultXml"] || 0;
const jsonEncoding = (ObjectIds as any)[name + "_Encoding_DefaultJson"] || 0;
if (dataType === undefined) {
return null;
}
};
const dataTypeNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, dataType, 0);
const binaryEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, binEncoding, 0);
const xmlEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, xmlEncoding, 0);
const jsonEncodingNodeId = new NodeId(NodeId.NodeIdType.NUMERIC, jsonEncoding, 0);
const data: DataTypeAndEncodingId = {
binaryEncodingNodeId,
dataTypeNodeId,
jsonEncodingNodeId,
xmlEncodingNodeId
};
if (doDebug) {
debugLog(
" data=",
chalk.cyan(name.padEnd(43, " ")),
data.dataTypeNodeId.toString().padEnd(43, " "),
data.binaryEncodingNodeId.toString().padEnd(43, " ")
);
}
return data;
}
};
const dataTypeFactory = new DataTypeFactory([getStandardDataTypeFactory()]);
await parseBinaryXSDAsync(content, idProvider, dataTypeFactory);
const dataTypeFactory = new DataTypeFactory([getStandardDataTypeFactory()]);
await parseBinaryXSDAsync(content, idProvider, dataTypeFactory);
write(
`// tslint:disable:no-this-assignment
write(
`// tslint:disable:no-this-assignment
// tslint:disable:max-classes-per-file

@@ -264,87 +264,87 @@ // tslint:disable:no-empty-interface

} from "node-opcua-variant";`
);
);
write(``);
write(``);
write(`export class DataTypeDefinition extends BaseUAObject {`);
write(` constructor(options: any) {`);
write(` options = options; // do not remove`);
write(` super();`);
write(` }`);
write(`}`);
write(``);
write(`export class DataTypeDefinition extends BaseUAObject {`);
write(` constructor(options: any) {`);
write(` options = options; // do not remove`);
write(` super();`);
write(` }`);
write(`}`);
write(``);
const alreadyDone: { [key: string]: any } = {};
/* tslint:disable:no-string-literal */
alreadyDone["ExtensionObject"] = true;
alreadyDone["NodeId"] = true;
const alreadyDone: { [key: string]: any } = {};
/* tslint:disable:no-string-literal */
alreadyDone["ExtensionObject"] = true;
alreadyDone["NodeId"] = true;
alreadyDone["ExpandedNodeId"] = true;
alreadyDone["Variant"] = true;
alreadyDone["XmlElement"] = true;
alreadyDone["ExpandedNodeId"] = true;
alreadyDone["Variant"] = true;
alreadyDone["XmlElement"] = true;
alreadyDone["NodeIdType"] = true;
alreadyDone["TwoByteNodeId"] = true;
alreadyDone["FourByteNodeId"] = true;
alreadyDone["NumericNodeId"] = true;
alreadyDone["StringNodeId"] = true;
alreadyDone["GuidNodeId"] = true;
alreadyDone["ByteStringNodeId"] = true;
alreadyDone["NodeIdType"] = true;
alreadyDone["TwoByteNodeId"] = true;
alreadyDone["FourByteNodeId"] = true;
alreadyDone["NumericNodeId"] = true;
alreadyDone["StringNodeId"] = true;
alreadyDone["GuidNodeId"] = true;
alreadyDone["ByteStringNodeId"] = true;
alreadyDone["DiagnosticInfo"] = true;
alreadyDone["Variant"] = true;
alreadyDone["DataValue"] = true;
alreadyDone["LocalizedText"] = true;
alreadyDone["QualifiedName"] = true;
alreadyDone["BrowseDirection"] = true;
alreadyDone["TimestampsToReturn"] = true;
alreadyDone["DiagnosticInfo"] = true;
alreadyDone["Variant"] = true;
alreadyDone["DataValue"] = true;
alreadyDone["LocalizedText"] = true;
alreadyDone["QualifiedName"] = true;
alreadyDone["BrowseDirection"] = true;
alreadyDone["TimestampsToReturn"] = true;
function processEnumeratedType(enumerationSchema: EnumerationDefinitionSchema): void {
if (alreadyDone[enumerationSchema.name]) {
return;
}
alreadyDone[enumerationSchema.name] = enumerationSchema;
writeEnumeratedType(enumerationSchema);
function processEnumeratedType(enumerationSchema: EnumerationDefinitionSchema): void {
if (alreadyDone[enumerationSchema.name]) {
return;
}
alreadyDone[enumerationSchema.name] = enumerationSchema;
writeEnumeratedType(enumerationSchema);
}
function processStructuredType(structuredType: StructuredTypeSchema): void {
if (alreadyDone[structuredType.name]) {
return;
}
alreadyDone[structuredType.name] = structuredType;
function processStructuredType(structuredType: StructuredTypeSchema): void {
if (alreadyDone[structuredType.name]) {
return;
}
alreadyDone[structuredType.name] = structuredType;
// make sure
if (dataTypeFactory.hasStructuredType(structuredType.baseType)) {
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structuredType.baseType));
// make sure
if (dataTypeFactory.hasStructuredType(structuredType.baseType)) {
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structuredType.baseType));
}
for (const field of structuredType.fields) {
if (field.category === FieldCategory.complex) {
const fieldSchema = dataTypeFactory.getStructuredTypeSchema(field.fieldType);
processStructuredType(fieldSchema);
}
for (const field of structuredType.fields) {
if (field.category === FieldCategory.complex) {
const fieldSchema = dataTypeFactory.getStructuredTypeSchema(field.fieldType);
processStructuredType(fieldSchema);
}
if (field.category === FieldCategory.enumeration) {
const fieldSchema = dataTypeFactory.getEnumeration(field.fieldType)!;
processEnumeratedType(fieldSchema);
}
if (field.category === FieldCategory.enumeration) {
const fieldSchema = dataTypeFactory.getEnumeration(field.fieldType)!;
processEnumeratedType(fieldSchema);
}
writeStructuredTypeWithSchema(structuredType);
}
writeStructuredTypeWithSchema(structuredType);
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation"));
// processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("SimpleAttributeOperand"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("LocalizedText"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("AxisInformation"));
// processStructuredType(dataTypeFactory.getStructuredTypeSchema("DiagnosticInfo"));
processStructuredType(dataTypeFactory.getStructuredTypeSchema("SimpleAttributeOperand"));
for (const structureType of [...dataTypeFactory.structuredTypesNames()].sort()) {
if (!dataTypeFactory.hasStructuredType(structureType)) {
continue;
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structureType));
// if (++i > 250) { break; }
for (const structureType of [...dataTypeFactory.structuredTypesNames()].sort()) {
if (!dataTypeFactory.hasStructuredType(structureType)) {
continue;
}
processStructuredType(dataTypeFactory.getStructuredTypeSchema(structureType));
// if (++i > 250) { break; }
}
write(``);
f.saveFormat(generatedTypescriptFilename, (code) => {
return code;
/*
write(``);
f.saveFormat(generatedTypescriptFilename, (code) => {
return code;
/*
const options: prettier.Options = {

@@ -358,6 +358,3 @@ bracketSpacing: true,

*/
});
} catch (err) {
throw err;
}
});
}

@@ -9,3 +9,3 @@ /* istanbul ignore file */

// node 14 onward : import { mkdir } from "fs/promises";
const { mkdir }= fs.promises;
const { mkdir } = fs.promises;

@@ -84,3 +84,3 @@ import * as path from "path";

export async function generateCode(schemaName: string, localSchemaFile: string, generatedCodeFolder?: string) {
export async function generateCode(schemaName: string, localSchemaFile: string, generatedCodeFolder?: string): Promise<void> {
const schemaTypescriptFile = schemaName + "_Schema.ts";

@@ -148,3 +148,3 @@

export async function generateTypeScriptCodeFromSchema(schemaName: string) {
export async function generateTypeScriptCodeFromSchema(schemaName: string): Promise<void> {
const currentFolder = process.cwd();

@@ -188,3 +188,3 @@ const schemaFilename = path.join(currentFolder, "schemas", schemaName + "_schema.ts");

export function unregisterObject(schema: any, folder: string) {
export function unregisterObject(schema: { name: string }, folder: string): void {
const generateTypeScriptSource = get_class_TScript_filename(schema.name, folder);

@@ -191,0 +191,0 @@ if (fs.existsSync(generateTypeScriptSource)) {

@@ -15,4 +15,2 @@ /* istanbul ignore file */

main()
.then()
.catch();
main().then().catch();

@@ -9,4 +9,4 @@ import { LineFile1 } from "./line_file";

export const makeWrite = (f: LineFile1) => {
const _f: any = (...args: string[]) => f.write.apply(f, args);
export const makeWrite = (f: LineFile1): WriteFunc => {
const _f: WriteFunc = (...args: string[]) => f.write(...args);
_f.indent = () => {

@@ -13,0 +13,0 @@ /** */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc