@twin.org/ts-to-jsonld-context 0.0.3-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsToJsonLdContext.js","sourceRoot":"","sources":["../../../src/commands/tsToJsonLdContext.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAAC,OAAgB;IAC7D,OAAO;SACL,QAAQ,CACR,IAAI,CAAC,aAAa,CAAC,oDAAoD,CAAC,EACxE,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAC9E;SACA,QAAQ,CACR,IAAI,CAAC,aAAa,CAAC,yDAAyD,CAAC,EAC7E,IAAI,CAAC,aAAa,CAAC,+DAA+D,CAAC,CACnF;SACA,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;QAC1C,MAAM,8BAA8B,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CACnD,UAAkB,EAClB,UAAkB,EAClB,IAAa;IAEb,IAAI,MAA4C,CAAC;IAEjD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,U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AC,IAAI,CAAC;QACtC,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAC5B,CAAC;QACF,qEAAqE;QACrE,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IAED,8DAA8D;IAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is, ObjectHelper, StringHelper } from \"@twin.org/core\";\nimport type { Command } from \"commander\";\nimport ts from \"typescript\";\nimport type { IJsonLdProps } from \"../models/IJsonLdProps.js\";\nimport type { ITsToJsonLdContextConfig } from \"../models/ITsToJsonLdContextConfig.js\";\n\n/**\n * Build the root command to be consumed by the CLI.\n * @param program The command to build on.\n */\nexport function buildCommandTsToJsonLdContext(program: Command): void {\n\tprogram\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.options.config.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.options.config.description\")\n\t\t)\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.options.output-file.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.options.output-file.description\")\n\t\t)\n\t\t.action(async (config, outputFile, opts) => {\n\t\t\tawait actionCommandTsToJsonLdContext(config, outputFile, opts);\n\t\t});\n}\n\n/**\n * Action the root command.\n * @param configFile The optional configuration file.\n * @param outputFile The output file for the schema.\n * @param opts The options for the command.\n */\nexport async function actionCommandTsToJsonLdContext(\n\tconfigFile: string,\n\toutputFile: string,\n\topts: unknown\n): Promise<void> {\n\tlet config: ITsToJsonLdContextConfig | undefined;\n\n\tconst fullConfigFile = path.resolve(configFile);\n\tconst fullOutputFile = path.resolve(outputFile);\n\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.labels.configJson\"),\n\t\tfullConfigFile\n\t);\n\tCLIDisplay.value(\n\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.labels.outputFile\"),\n\t\tfullOutputFile\n\t);\n\tCLIDisplay.break();\n\n\ttry {\n\t\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-jsonld-context.progress.loadingConfigJson\"));\n\t\tCLIDisplay.break();\n\n\t\tconfig = await CLIUtils.readJsonFile<ITsToJsonLdContextConfig>(fullConfigFile);\n\t} catch (err) {\n\t\tthrow new GeneralError(\n\t\t\t\"commands\",\n\t\t\t\"commands.ts-to-jsonld-context.configFailed\",\n\t\t\tundefined,\n\t\t\terr\n\t\t);\n\t}\n\n\tif (Is.empty(config)) {\n\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-jsonld-context.configFailed\");\n\t}\n\n\tCLIDisplay.break();\n\n\tawait tsToJsonLdContext(config ?? {}, fullOutputFile);\n\n\tCLIDisplay.break();\n\tCLIDisplay.done();\n}\n\n/**\n * Convert the TypeScript definitions to JSON-LD Contexts.\n * @param config The configuration for the app.\n * @param outputFile The output file for the schema.\n */\nexport async function tsToJsonLdContext(\n\tconfig: ITsToJsonLdContextConfig,\n\toutputFile: string\n): Promise<void> {\n\tconst program = ts.createProgram(config.types, {});\n\tconst context: { types: string[]; namespaces: string[]; properties: { [id: string]: unknown } } =\n\t\t{\n\t\t\ttypes: [],\n\t\t\tnamespaces: [],\n\t\t\tproperties: {}\n\t\t};\n\n\tconst processedTypes: { [typeName: string]: IJsonLdProps } = {};\n\n\t// Walk the AST for each source file\n\tfor (const sourceFile of program.getSourceFiles()) {\n\t\tconst resolvedFilename = path.resolve(sourceFile.fileName);\n\t\tif (config.types.some(file => resolvedFilename.endsWith(path.resolve(file)))) {\n\t\t\tCLIDisplay.task(\"Processing\", resolvedFilename);\n\n\t\t\tvisit(config, sourceFile, sourceFile, context, program, processedTypes);\n\t\t\tCLIDisplay.break();\n\t\t}\n\t}\n\n\tconst finalObject: {\n\t\t\"@context\": { [key: string]: unknown; \"@version\": number; \"@protected\": boolean };\n\t} = {\n\t\t\"@context\": {\n\t\t\t\"@version\": 1.1,\n\t\t\t\"@protected\": true\n\t\t}\n\t};\n\n\tfinalObject[\"@context\"][config.prefix] = config.contextUrl;\n\n\tif (Is.objectValue(config.additionalContextUrls)) {\n\t\tfor (const [key, value] of Object.entries(config.additionalContextUrls)) {\n\t\t\tif (context.namespaces.includes(key)) {\n\t\t\t\tfinalObject[\"@context\"][key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (Is.objectValue(config.fixedMappings)) {\n\t\tfor (const [key, value] of Object.entries(config.fixedMappings)) {\n\t\t\tfinalObject[\"@context\"][key] = value;\n\t\t}\n\t}\n\n\tfor (const typeName of context.types) {\n\t\tconst noPrefixType = StringHelper.stripPrefix(typeName);\n\t\tfinalObject[\"@context\"][noPrefixType] = `${config.prefix}:${noPrefixType}`;\n\t}\n\n\tfor (const [propertyName, propertyValue] of Object.entries(context.properties).sort((a, b) =>\n\t\ta[0].localeCompare(b[0])\n\t)) {\n\t\tfinalObject[\"@context\"][propertyName] = propertyValue;\n\t}\n\n\tCLIDisplay.break();\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.labels.writingOutputFile\"),\n\t\toutputFile\n\t);\n\tawait writeFile(outputFile, `${JSON.stringify(finalObject, null, 2)}\\n`);\n}\n\n/**\n * Visit a node in the AST.\n * @param config The configuration for the app.\n * @param node The node to visit.\n * @param sourceFile The source file being processed.\n * @param context The JSON-LD context being built.\n * @param context.types The types collected in the context.\n * @param context.namespaces The namespaces collected in the context.\n * @param context.properties The properties collected in the context.\n * @param program The TypeScript program for resolving inherited interfaces.\n * @param processedTypes The types that have already been processed.\n */\nfunction visit(\n\tconfig: ITsToJsonLdContextConfig,\n\tnode: ts.Node,\n\tsourceFile: ts.SourceFile,\n\tcontext: { types: string[]; namespaces: string[]; properties: { [id: string]: unknown } },\n\tprogram: ts.Program,\n\tprocessedTypes: { [typeName: string]: IJsonLdProps }\n): void {\n\tlet jsonLdProps: IJsonLdProps = {};\n\n\t// Handle different node types\n\tif (ts.isInterfaceDeclaration(node)) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.labels.model\"),\n\t\t\tnode.name.text\n\t\t);\n\t\tcontext.types.push(node.name.text);\n\n\t\tif (Is.array(node.members)) {\n\t\t\tnode.members.forEach(member => {\n\t\t\t\tif (ts.isPropertySignature(member)) {\n\t\t\t\t\tconst propertyName = member.name?.getText(sourceFile).replace(/[\"']/g, \"\");\n\n\t\t\t\t\tif (Is.stringValue(propertyName)) {\n\t\t\t\t\t\tconst jsDocComments: string[] = extractComments(member);\n\n\t\t\t\t\t\tjsonLdProps = extractJsonLdProps(jsDocComments);\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t![\"@context\", \"type\", \"id\"].includes(propertyName) &&\n\t\t\t\t\t\t\t!Is.objectValue(jsonLdProps)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-jsonld-context.noJsonLdProps\", {\n\t\t\t\t\t\t\t\tpropertyName\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tIs.stringValue(jsonLdProps.namespace) &&\n\t\t\t\t\t\t\t!context.namespaces.includes(jsonLdProps.namespace)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcontext.namespaces.push(jsonLdProps.namespace);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (Is.objectValue(jsonLdProps.propertyType)) {\n\t\t\t\t\t\t\tlet fullType =\n\t\t\t\t\t\t\t\tjsonLdProps.propertyType.type === \"json\" ? \"@json\" : jsonLdProps.propertyType.type;\n\t\t\t\t\t\t\tif (Is.stringValue(jsonLdProps.propertyType.namespace)) {\n\t\t\t\t\t\t\t\tfullType = `${jsonLdProps.propertyType.namespace}:${jsonLdProps.propertyType.type}`;\n\n\t\t\t\t\t\t\t\tif (!context.namespaces.includes(jsonLdProps.propertyType.namespace)) {\n\t\t\t\t\t\t\t\t\tcontext.namespaces.push(jsonLdProps.propertyType.namespace);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcontext.properties[propertyName] = {\n\t\t\t\t\t\t\t\t\"@id\": `${config.prefix}:${propertyName}`,\n\t\t\t\t\t\t\t\t\"@type\": fullType\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t} else if (Is.boolean(jsonLdProps.idOnly)) {\n\t\t\t\t\t\t\tcontext.properties[propertyName] = {\n\t\t\t\t\t\t\t\t\"@id\": `${config.prefix}:${propertyName}`\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (Is.stringValue(jsonLdProps.container)) {\n\t\t\t\t\t\t\tcontext.properties[propertyName] = {\n\t\t\t\t\t\t\t\t\"@id\": `${config.prefix}:${propertyName}`,\n\t\t\t\t\t\t\t\t\"@container\": `@${jsonLdProps.container}`\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tCLIDisplay.value(\n\t\t\t\t\t\t\tI18n.formatMessage(\"commands.ts-to-jsonld-context.labels.property\"),\n\t\t\t\t\t\t\tpropertyName,\n\t\t\t\t\t\t\t1\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tprocessedTypes[node.name.text] = jsonLdProps;\n\n\t\tif (node.heritageClauses) {\n\t\t\tfor (const clause of node.heritageClauses) {\n\t\t\t\tif (clause.token === ts.SyntaxKind.ExtendsKeyword) {\n\t\t\t\t\tfor (const type of clause.types) {\n\t\t\t\t\t\tconst inheritedInterfaceName = extractBaseInterfaceName(type, sourceFile);\n\n\t\t\t\t\t\tif (!processedTypes[inheritedInterfaceName]) {\n\t\t\t\t\t\t\tconst result = findInterfaceByName(inheritedInterfaceName, program);\n\t\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\t\tvisit(\n\t\t\t\t\t\t\t\t\tconfig,\n\t\t\t\t\t\t\t\t\tresult.interfaceDeclaration,\n\t\t\t\t\t\t\t\t\tresult.sourceFile,\n\t\t\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\t\t\tprogram,\n\t\t\t\t\t\t\t\t\tprocessedTypes\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tts.forEachChild(node, child =>\n\t\tvisit(config, child, sourceFile, context, program, processedTypes)\n\t);\n}\n\n/**\n * Find an interface by name in the program.\n * @param interfaceName The name of the interface to find.\n * @param program The TypeScript program.\n * @returns The found interface declaration with its source file or undefined.\n */\nfunction findInterfaceByName(\n\tinterfaceName: string,\n\tprogram: ts.Program\n): { interfaceDeclaration: ts.InterfaceDeclaration; sourceFile: ts.SourceFile } | undefined {\n\tfor (const sourceFile of program.getSourceFiles()) {\n\t\tlet foundInterface: ts.InterfaceDeclaration | undefined;\n\n\t\tts.forEachChild(sourceFile, node => {\n\t\t\tif (ts.isInterfaceDeclaration(node) && node.name.text === interfaceName) {\n\t\t\t\tfoundInterface = node;\n\t\t\t}\n\t\t});\n\n\t\tif (foundInterface) {\n\t\t\treturn { interfaceDeclaration: foundInterface, sourceFile };\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Extract JSDoc comments from a property signature.\n * @param member The property signature member.\n * @returns The extracted comments.\n */\nfunction extractComments(member: ts.Node): string[] {\n\tconst jsDocComments: string[] = [];\n\tconst jsDocs = ObjectHelper.propertyGet<ts.JSDoc[] | undefined>(member, \"jsDoc\");\n\n\tif (Is.arrayValue(jsDocs)) {\n\t\tfor (const doc of jsDocs) {\n\t\t\tif (Is.string(doc.comment)) {\n\t\t\t\tjsDocComments.push(...doc.comment.split(\"\\n\").map(part => part.trim()));\n\t\t\t} else if (Is.arrayValue<string>(doc.comment)) {\n\t\t\t\tjsDocComments.push(...doc.comment.map(part => part.text));\n\t\t\t}\n\t\t}\n\t}\n\treturn jsDocComments;\n}\n\n/**\n * Extract JSON-LD properties from comments.\n * @param comments The comments to extract from.\n * @returns The extracted JSON-LD properties.\n */\nfunction extractJsonLdProps(comments: string[]): IJsonLdProps {\n\tconst jsonLdProps: IJsonLdProps = {};\n\n\tfor (const comment of comments) {\n\t\tconst idMatch = /json-ld id/.exec(comment);\n\t\tif (idMatch) {\n\t\t\tjsonLdProps.idOnly = true;\n\t\t} else {\n\t\t\tconst namespaceMatch = /json-ld namespace:(.*)/.exec(comment);\n\t\t\tif (namespaceMatch) {\n\t\t\t\tjsonLdProps.namespace = namespaceMatch[1];\n\t\t\t} else {\n\t\t\t\tconst containerMatch = /json-ld container:(.*)/.exec(comment);\n\t\t\t\tif (containerMatch) {\n\t\t\t\t\tjsonLdProps.container = containerMatch[1];\n\t\t\t\t} else {\n\t\t\t\t\tconst typeMatch = /json-ld type:(.*):(.*)/.exec(comment);\n\t\t\t\t\tif (typeMatch) {\n\t\t\t\t\t\tjsonLdProps.propertyType = {\n\t\t\t\t\t\t\tnamespace: typeMatch[1],\n\t\t\t\t\t\t\ttype: typeMatch[2]\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst typeMatch2 = /json-ld type:(.*)/.exec(comment);\n\t\t\t\t\t\tif (typeMatch2) {\n\t\t\t\t\t\t\tjsonLdProps.propertyType = {\n\t\t\t\t\t\t\t\ttype: typeMatch2[1]\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn jsonLdProps;\n}\n\n/**\n * Extract the base interface name from a type reference using the AST.\n * Handles utility types like Omit<InterfaceName, \"deleted\"> by extracting the first type argument.\n * @param type The type reference expression node.\n * @param sourceFile The source file for extracting text.\n * @returns The base interface name.\n */\nfunction extractBaseInterfaceName(type: ts.TypeReferenceType, sourceFile: ts.SourceFile): string {\n\t// Check if it's an expression with type arguments (e.g., Omit<Interface, \"deleted\">)\n\tif (\n\t\tts.isExpressionWithTypeArguments(type) &&\n\t\ttype.typeArguments &&\n\t\ttype.typeArguments.length > 0\n\t) {\n\t\t// Extract the first type argument which should be the interface name\n\t\tconst firstTypeArg = type.typeArguments[0];\n\t\treturn firstTypeArg.getText(sourceFile);\n\t}\n\n\t// Otherwise, treat the whole expression as the interface name\n\treturn type.getText(sourceFile);\n}\n"]}
@@ -0,0 +1,6 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export * from "./cli.js";
4
+ export * from "./commands/tsToJsonLdContext.js";
5
+ export * from "./models/ITsToJsonLdContextConfig.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./cli.js\";\nexport * from \"./commands/tsToJsonLdContext.js\";\nexport * from \"./models/ITsToJsonLdContextConfig.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IJsonLdProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IJsonLdProps.js","sourceRoot":"","sources":["../../../src/models/IJsonLdProps.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * JSON-LD property metadata.\n */\nexport interface IJsonLdProps {\n\t/**\n\t * Include only the property.\n\t */\n\tidOnly?: boolean;\n\n\t/**\n\t * The namespace of the property.\n\t */\n\tnamespace?: string;\n\n\t/**\n\t * The type information of the property.\n\t */\n\tpropertyType?: {\n\t\tnamespace?: string;\n\t\ttype?: string;\n\t};\n\n\t/**\n\t * The container type of the property.\n\t */\n\tcontainer?: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright 2026 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=ITsToJsonLdContextConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITsToJsonLdContextConfig.js","sourceRoot":"","sources":["../../../src/models/ITsToJsonLdContextConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the tool.\n */\nexport interface ITsToJsonLdContextConfig {\n\t/**\n\t * The prefix to use for the context e.g. twin-common.\n\t */\n\tprefix: string;\n\n\t/**\n\t * The base URL for the context e.g. https://schema.twindev.org/common/\n\t */\n\tcontextUrl: string;\n\n\t/**\n\t * Additional context URLs to include in the context.\n\t */\n\tadditionalContextUrls?: { [id: string]: string };\n\n\t/**\n\t * Fixed mappings to include in the context.\n\t */\n\tfixedMappings?: { [id: string]: string };\n\n\t/**\n\t * The source files to generate the types from.\n\t */\n\ttypes: string[];\n}\n"]}
@@ -0,0 +1,206 @@
1
+ {
2
+ "error": {
3
+ "commands": {
4
+ "common": {
5
+ "missingEnv": "The \"{option}\" option is configured as an environment variable, but there is no environment variable with the name \"{value}\" set.",
6
+ "optionInvalidHex": "The \"{option}\" does not appear to be hex. \"{value}\"",
7
+ "optionInvalidBase64": "The \"{option}\" does not appear to be base64. \"{value}\"",
8
+ "optionInvalidHexBase64": "The \"{option}\" does not appear to be hex or base64. \"{value}\"",
9
+ "optionMinValue": "The \"{option}\" option must be greater than or equal to {minValue}, it is {value}.",
10
+ "optionMaxValue": "The \"{option}\" option must be less than or equal to {maxValue}, it is {value}."
11
+ },
12
+ "ts-to-jsonld-context": {
13
+ "configFailed": "Configuration failed to load.",
14
+ "noJsonLdProps": "No JSON-LD properties found for property \"{propertyName}\"."
15
+ }
16
+ },
17
+ "validation": {
18
+ "beEmpty": "{fieldName} must be empty",
19
+ "beNotEmpty": "{fieldName} must not be empty",
20
+ "beText": "{fieldName} must be text",
21
+ "beTextValue": "{fieldName} must contain some text",
22
+ "beTextMinMax": "{fieldName} must be longer than {minLength} and shorter than {maxLength} characters",
23
+ "beTextMin": "{fieldName} must be longer than {minLength} characters",
24
+ "beTextMax": "{fieldName} must be shorter than {maxLength} characters",
25
+ "beTextBase58": "{fieldName} must be text formatted using Base58 characters",
26
+ "beTextBase64": "{fieldName} must be text formatted using Base64 characters",
27
+ "beTextHex": "{fieldName} must be text formatted using Hex characters",
28
+ "beTextRegExp": "{fieldName} must be text formatted using the matching pattern {format}",
29
+ "beNumber": "{fieldName} must be a number",
30
+ "beNumberMinMax": "{fieldName} must be >= {minValue} and <= {maxValue}",
31
+ "beNumberMin": "{fieldName} must be >= {minValue}",
32
+ "beNumberMax": "{fieldName} must be <= {maxValue}",
33
+ "beWholeNumber": "{fieldName} must be a whole number",
34
+ "beWholeNumberMinMax": "{fieldName} must be a whole number >= {minValue} and <= {maxValue}",
35
+ "beWholeNumberMin": "{fieldName} must be a whole number >= {minValue}",
36
+ "beWholeNumberMax": "{fieldName} must be a whole number <= {maxValue}",
37
+ "beBigInteger": "{fieldName} must be a bigint",
38
+ "beBigIntegerMinMax": "{fieldName} must be a bigint >= {minValue} and <= {maxValue}",
39
+ "beBigIntegerMin": "{fieldName} must be a bigint >= {minValue}",
40
+ "beBigIntegerMax": "{fieldName} must be a bigint <= {maxValue}",
41
+ "beBoolean": "{fieldName} must be true or false",
42
+ "beDate": "{fieldName} must be a date",
43
+ "beDateTime": "{fieldName} must be a date/time",
44
+ "beTime": "{fieldName} must be a time",
45
+ "beTimestampMilliseconds": "{fieldName} must be a timestamp in milliseconds",
46
+ "beTimestampSeconds": "{fieldName} must be a timestamp in seconds",
47
+ "beObject": "{fieldName} must be an object",
48
+ "beArray": "{fieldName} must be an array",
49
+ "beArrayValue": "{fieldName} must be an array with at least one item",
50
+ "beIncluded": "{fieldName} is unrecognised",
51
+ "beByteArray": "{fieldName} must be a byte array",
52
+ "beUrn": "{fieldName} must be a correctly formatted urn",
53
+ "beUrl": "{fieldName} must be a correctly formatted url",
54
+ "beJSON": "{fieldName} must be correctly formatted JSON",
55
+ "beEmail": "{fieldName} must be a correctly formatted e-mail address"
56
+ },
57
+ "guard": {
58
+ "undefined": "Property \"{property}\" must be defined, it is \"{value}\"",
59
+ "string": "Property \"{property}\" must be a string, it is \"{value}\"",
60
+ "stringEmpty": "Property \"{property}\" must have a value, it is empty",
61
+ "stringBase64": "Property \"{property}\" must be a base64 encoded string, it is \"{value}\"",
62
+ "stringBase64Url": "Property \"{property}\" must be a base64 url encoded string, it is \"{value}\"",
63
+ "stringBase58": "Property \"{property}\" must be a base58 encoded string, it is \"{value}\"",
64
+ "stringHex": "Property \"{property}\" must be a hex string, it is \"{value}\"",
65
+ "stringHexLength": "Property \"{property}\" must be a hex string of length \"{options}\", it is \"{value}\"",
66
+ "stringJson": "Property \"{property}\" must be a JSON string",
67
+ "number": "Property \"{property}\" must be a number, it is \"{value}\"",
68
+ "integer": "Property \"{property}\" must be an integer, it is \"{value}\"",
69
+ "bigint": "Property \"{property}\" must be a bigint, it is \"{value}\"",
70
+ "boolean": "Property \"{property}\" must be a boolean, it is \"{value}\"",
71
+ "date": "Property \"{property}\" must be a date, it is \"{value}\"",
72
+ "timestampMilliseconds": "Property \"{property}\" must be a timestamp in milliseconds, it is \"{value}\"",
73
+ "timestampSeconds": "Property \"{property}\" must be a timestamp in seconds, it is \"{value}\"",
74
+ "objectUndefined": "Property \"{property}\" must be an object, it is \"undefined\"",
75
+ "object": "Property \"{property}\" must be an object, it is \"{value}\"",
76
+ "objectValue": "Property \"{property}\" must be an object, with at least one property, it is \"{value}\"",
77
+ "array": "Property \"{property}\" must be an array, it is \"{value}\"",
78
+ "arrayValue": "Property \"{property}\" must be an array with at least one item",
79
+ "arrayOneOf": "Property \"{property}\" must be one of [{options}], it is \"{value}\"",
80
+ "arrayStartsWith": "Property \"{property}\" must be an array starting with [{startValues}], it is \"{value}\"",
81
+ "arrayEndsWith": "Property \"{property}\" must be an array ending with [{endValues}], it is \"{value}\"",
82
+ "uint8Array": "Property \"{property}\" must be a Uint8Array, it is \"{value}\"",
83
+ "function": "Property \"{property}\" must be a function, it is \"{value}\"",
84
+ "urn": "Property \"{property}\" must be a Urn formatted string, it is \"{value}\"",
85
+ "url": "Property \"{property}\" must be a Url formatted string, it is \"{value}\"",
86
+ "email": "Property \"{property}\" must be string in e-mail format, it is \"{value}\"",
87
+ "uuidV7": "Property \"{property}\" must be a UUIDv7 formatted string, it is \"{value}\"",
88
+ "uuidV7Compact": "Property \"{property}\" must be a UUIDv7 formatted string in compact mode, it is \"{value}\""
89
+ },
90
+ "objectHelper": {
91
+ "failedBytesToJSON": "Failed converting bytes to JSON",
92
+ "cannotSetArrayIndex": "Cannot set property \"{property}\" using index \"{index}\" as it is not an array",
93
+ "cannotSetProperty": "Cannot set property \"{property}\" when the target is not an object"
94
+ },
95
+ "common": {
96
+ "notImplementedMethod": "The method \"{method}\" has not been implemented",
97
+ "validation": "Validation failed"
98
+ },
99
+ "factory": {
100
+ "noUnregister": "There is no {typeName} registered with the name \"{name}\"",
101
+ "noGet": "The requested {typeName} \"{name}\" does not exist in the factory"
102
+ },
103
+ "bitString": {
104
+ "outOfRange": "The index should be >= 0 and less than the length of the bit string, the index is \"{index}\" and the number of bit is \"{numberBits}\""
105
+ },
106
+ "base32": {
107
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
108
+ },
109
+ "base64": {
110
+ "length4Multiple": "Invalid length should be a multiple of 4, it is \"{value}\""
111
+ },
112
+ "base58": {
113
+ "invalidCharacter": "Data contains a character \"{invalidCharacter}\" which is not in the charset"
114
+ },
115
+ "jsonHelper": {
116
+ "failedPatch": "Failed to patch the JSON object, patch index \"{index}\" failed"
117
+ }
118
+ },
119
+ "warn": {
120
+ "common": {
121
+ "devOnlyTool": "This tool is intended to be used for development purposes, it is not recommended for use in production scenarios."
122
+ }
123
+ },
124
+ "cli": {
125
+ "progress": {
126
+ "done": "Done.",
127
+ "error": "Error",
128
+ "loadingEnvFiles": "Loading env files",
129
+ "pleaseWait": "Please wait...",
130
+ "writingJsonFile": "Writing JSON file",
131
+ "writingEnvFile": "Writing env file",
132
+ "readingJsonFile": "Reading JSON file",
133
+ "readingEnvFile": "Reading env file"
134
+ },
135
+ "options": {
136
+ "lang": {
137
+ "param": "--lang '<'lang'>'",
138
+ "description": "The language to display the output in."
139
+ },
140
+ "load-env": {
141
+ "param": "--load-env [env...]",
142
+ "description": "Load the env files to initialise any environment variables."
143
+ },
144
+ "no-console": {
145
+ "param": "--no-console",
146
+ "description": "Hides the output in the console."
147
+ },
148
+ "json": {
149
+ "param": "--json '<'filename'>'",
150
+ "description": "Creates a JSON file containing the output."
151
+ },
152
+ "env": {
153
+ "param": "--env '<'filename'>'",
154
+ "description": "Creates an env file containing the output."
155
+ },
156
+ "merge-json": {
157
+ "param": "--merge-json",
158
+ "description": "If the JSON file already exists merge the data instead of overwriting."
159
+ },
160
+ "merge-env": {
161
+ "param": "--merge-env",
162
+ "description": "If the env file already exists merge the data instead of overwriting."
163
+ }
164
+ }
165
+ },
166
+ "errorNames": {
167
+ "error": "Error",
168
+ "generalError": "General",
169
+ "guardError": "Guard",
170
+ "conflictError": "Conflict",
171
+ "notFoundError": "Not Found",
172
+ "notSupportedError": "Not Supported",
173
+ "alreadyExistsError": "Already Exists",
174
+ "notImplementedError": "Not Implemented",
175
+ "validationError": "Validation",
176
+ "unprocessableError": "Unprocessable",
177
+ "unauthorizedError": "Unauthorized"
178
+ },
179
+ "validation": {
180
+ "defaultFieldName": "The field"
181
+ },
182
+ "commands": {
183
+ "ts-to-jsonld-context": {
184
+ "options": {
185
+ "config": {
186
+ "param": "'<'config'>'",
187
+ "description": "Path to the JSON configuration file."
188
+ },
189
+ "output-file": {
190
+ "param": "'<'output-file'>'",
191
+ "description": "The file to write the JSON-LD Context to."
192
+ }
193
+ },
194
+ "progress": {
195
+ "loadingConfigJson": "Loading Config JSON"
196
+ },
197
+ "labels": {
198
+ "configJson": "Config JSON",
199
+ "outputFile": "Output File",
200
+ "writingOutputFile": "Writing Output File",
201
+ "model": "Model",
202
+ "property": "Property"
203
+ }
204
+ }
205
+ }
206
+ }
@@ -0,0 +1,23 @@
1
+ import { CLIBase } from "@twin.org/cli-core";
2
+ import type { Command } from "commander";
3
+ /**
4
+ * The main entry point for the CLI.
5
+ */
6
+ export declare class CLI extends CLIBase {
7
+ /**
8
+ * Run the app.
9
+ * @param argv The process arguments.
10
+ * @param localesDirectory The directory for the locales, default to relative to the script.
11
+ * @param options Additional options.
12
+ * @param options.overrideOutputWidth Override the output width.
13
+ * @returns The exit code.
14
+ */
15
+ run(argv: string[], localesDirectory?: string, options?: {
16
+ overrideOutputWidth?: number;
17
+ }): Promise<number>;
18
+ /**
19
+ * Configure any options or actions at the root program level.
20
+ * @param program The root program command.
21
+ */
22
+ protected configureRoot(program: Command): void;
23
+ }
@@ -0,0 +1,20 @@
1
+ import type { Command } from "commander";
2
+ import type { ITsToJsonLdContextConfig } from "../models/ITsToJsonLdContextConfig.js";
3
+ /**
4
+ * Build the root command to be consumed by the CLI.
5
+ * @param program The command to build on.
6
+ */
7
+ export declare function buildCommandTsToJsonLdContext(program: Command): void;
8
+ /**
9
+ * Action the root command.
10
+ * @param configFile The optional configuration file.
11
+ * @param outputFile The output file for the schema.
12
+ * @param opts The options for the command.
13
+ */
14
+ export declare function actionCommandTsToJsonLdContext(configFile: string, outputFile: string, opts: unknown): Promise<void>;
15
+ /**
16
+ * Convert the TypeScript definitions to JSON-LD Contexts.
17
+ * @param config The configuration for the app.
18
+ * @param outputFile The output file for the schema.
19
+ */
20
+ export declare function tsToJsonLdContext(config: ITsToJsonLdContextConfig, outputFile: string): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export * from "./cli.js";
2
+ export * from "./commands/tsToJsonLdContext.js";
3
+ export * from "./models/ITsToJsonLdContextConfig.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * JSON-LD property metadata.
3
+ */
4
+ export interface IJsonLdProps {
5
+ /**
6
+ * Include only the property.
7
+ */
8
+ idOnly?: boolean;
9
+ /**
10
+ * The namespace of the property.
11
+ */
12
+ namespace?: string;
13
+ /**
14
+ * The type information of the property.
15
+ */
16
+ propertyType?: {
17
+ namespace?: string;
18
+ type?: string;
19
+ };
20
+ /**
21
+ * The container type of the property.
22
+ */
23
+ container?: string;
24
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Configuration for the tool.
3
+ */
4
+ export interface ITsToJsonLdContextConfig {
5
+ /**
6
+ * The prefix to use for the context e.g. twin-common.
7
+ */
8
+ prefix: string;
9
+ /**
10
+ * The base URL for the context e.g. https://schema.twindev.org/common/
11
+ */
12
+ contextUrl: string;
13
+ /**
14
+ * Additional context URLs to include in the context.
15
+ */
16
+ additionalContextUrls?: {
17
+ [id: string]: string;
18
+ };
19
+ /**
20
+ * Fixed mappings to include in the context.
21
+ */
22
+ fixedMappings?: {
23
+ [id: string]: string;
24
+ };
25
+ /**
26
+ * The source files to generate the types from.
27
+ */
28
+ types: string[];
29
+ }
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.6](https://github.com/twinfoundation/tools/compare/ts-to-jsonld-context-v0.0.3-next.5...ts-to-jsonld-context-v0.0.3-next.6) (2026-01-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * added ts-to-jsonld-context tool ([#67](https://github.com/twinfoundation/tools/issues/67)) ([c808e84](https://github.com/twinfoundation/tools/commit/c808e84741e5010a166520e39565f4933dceba59))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/tools-core bumped from 0.0.3-next.5 to 0.0.3-next.6
16
+
17
+ ## @twin.org/ts-to-jsonld-context - Changelog
@@ -0,0 +1,15 @@
1
+ # @twin.org/ts-to-jsonld-context - Examples
2
+
3
+ ## Command Line Tool
4
+
5
+ First install the tool with the following script.
6
+
7
+ ```shell
8
+ npm install @twin.org/ts-to-jsonld-context
9
+ ```
10
+
11
+ You can then run the tool from the command line e.g.
12
+
13
+ ```shell
14
+ ts-to-jsonld-context
15
+ ```
@@ -0,0 +1,83 @@
1
+ # Class: CLI
2
+
3
+ The main entry point for the CLI.
4
+
5
+ ## Extends
6
+
7
+ - `CLIBase`
8
+
9
+ ## Constructors
10
+
11
+ ### Constructor
12
+
13
+ > **new CLI**(): `CLI`
14
+
15
+ #### Returns
16
+
17
+ `CLI`
18
+
19
+ #### Inherited from
20
+
21
+ `CLIBase.constructor`
22
+
23
+ ## Methods
24
+
25
+ ### run()
26
+
27
+ > **run**(`argv`, `localesDirectory?`, `options?`): `Promise`\<`number`\>
28
+
29
+ Run the app.
30
+
31
+ #### Parameters
32
+
33
+ ##### argv
34
+
35
+ `string`[]
36
+
37
+ The process arguments.
38
+
39
+ ##### localesDirectory?
40
+
41
+ `string`
42
+
43
+ The directory for the locales, default to relative to the script.
44
+
45
+ ##### options?
46
+
47
+ Additional options.
48
+
49
+ ###### overrideOutputWidth?
50
+
51
+ `number`
52
+
53
+ Override the output width.
54
+
55
+ #### Returns
56
+
57
+ `Promise`\<`number`\>
58
+
59
+ The exit code.
60
+
61
+ ***
62
+
63
+ ### configureRoot()
64
+
65
+ > `protected` **configureRoot**(`program`): `void`
66
+
67
+ Configure any options or actions at the root program level.
68
+
69
+ #### Parameters
70
+
71
+ ##### program
72
+
73
+ `Command`
74
+
75
+ The root program command.
76
+
77
+ #### Returns
78
+
79
+ `void`
80
+
81
+ #### Overrides
82
+
83
+ `CLIBase.configureRoot`
@@ -0,0 +1,29 @@
1
+ # Function: actionCommandTsToJsonLdContext()
2
+
3
+ > **actionCommandTsToJsonLdContext**(`configFile`, `outputFile`, `opts`): `Promise`\<`void`\>
4
+
5
+ Action the root command.
6
+
7
+ ## Parameters
8
+
9
+ ### configFile
10
+
11
+ `string`
12
+
13
+ The optional configuration file.
14
+
15
+ ### outputFile
16
+
17
+ `string`
18
+
19
+ The output file for the schema.
20
+
21
+ ### opts
22
+
23
+ `unknown`
24
+
25
+ The options for the command.
26
+
27
+ ## Returns
28
+
29
+ `Promise`\<`void`\>
@@ -0,0 +1,17 @@
1
+ # Function: buildCommandTsToJsonLdContext()
2
+
3
+ > **buildCommandTsToJsonLdContext**(`program`): `void`
4
+
5
+ Build the root command to be consumed by the CLI.
6
+
7
+ ## Parameters
8
+
9
+ ### program
10
+
11
+ `Command`
12
+
13
+ The command to build on.
14
+
15
+ ## Returns
16
+
17
+ `void`
@@ -0,0 +1,23 @@
1
+ # Function: tsToJsonLdContext()
2
+
3
+ > **tsToJsonLdContext**(`config`, `outputFile`): `Promise`\<`void`\>
4
+
5
+ Convert the TypeScript definitions to JSON-LD Contexts.
6
+
7
+ ## Parameters
8
+
9
+ ### config
10
+
11
+ [`ITsToJsonLdContextConfig`](../interfaces/ITsToJsonLdContextConfig.md)
12
+
13
+ The configuration for the app.
14
+
15
+ ### outputFile
16
+
17
+ `string`
18
+
19
+ The output file for the schema.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`void`\>
@@ -0,0 +1,15 @@
1
+ # @twin.org/ts-to-jsonld-context
2
+
3
+ ## Classes
4
+
5
+ - [CLI](classes/CLI.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [ITsToJsonLdContextConfig](interfaces/ITsToJsonLdContextConfig.md)
10
+
11
+ ## Functions
12
+
13
+ - [buildCommandTsToJsonLdContext](functions/buildCommandTsToJsonLdContext.md)
14
+ - [actionCommandTsToJsonLdContext](functions/actionCommandTsToJsonLdContext.md)
15
+ - [tsToJsonLdContext](functions/tsToJsonLdContext.md)
@@ -0,0 +1,51 @@
1
+ # Interface: ITsToJsonLdContextConfig
2
+
3
+ Configuration for the tool.
4
+
5
+ ## Properties
6
+
7
+ ### prefix
8
+
9
+ > **prefix**: `string`
10
+
11
+ The prefix to use for the context e.g. twin-common.
12
+
13
+ ***
14
+
15
+ ### contextUrl
16
+
17
+ > **contextUrl**: `string`
18
+
19
+ The base URL for the context e.g. https://schema.twindev.org/common/
20
+
21
+ ***
22
+
23
+ ### additionalContextUrls?
24
+
25
+ > `optional` **additionalContextUrls**: `object`
26
+
27
+ Additional context URLs to include in the context.
28
+
29
+ #### Index Signature
30
+
31
+ \[`id`: `string`\]: `string`
32
+
33
+ ***
34
+
35
+ ### fixedMappings?
36
+
37
+ > `optional` **fixedMappings**: `object`
38
+
39
+ Fixed mappings to include in the context.
40
+
41
+ #### Index Signature
42
+
43
+ \[`id`: `string`\]: `string`
44
+
45
+ ***
46
+
47
+ ### types
48
+
49
+ > **types**: `string`[]
50
+
51
+ The source files to generate the types from.