diff --git a/package-lock.json b/package-lock.json index a2d397d9..6613a74e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,8 @@ "mkdirp": "3.0.1", "nyc": "17.1.0", "semver": "^7.6.3", - "traverse": "^0.6.10" + "traverse": "^0.6.10", + "typescript": "^5.4.5" }, "engines": { "node": ">=18", @@ -240,7 +241,6 @@ "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -2415,7 +2415,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" }, @@ -2438,7 +2437,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18" } @@ -3305,7 +3303,6 @@ "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/linkify-it": "^5", "@types/mdurl": "^2" @@ -3602,7 +3599,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3649,7 +3645,6 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -3679,19 +3674,6 @@ } } }, - "node_modules/ajv-keywords": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", - "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3" - }, - "peerDependencies": { - "ajv": "^8.8.2" - } - }, "node_modules/ansi-colors": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", @@ -4452,7 +4434,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -4687,7 +4668,6 @@ "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.2", @@ -5797,7 +5777,6 @@ "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -8374,26 +8353,27 @@ } }, "node_modules/jsdoc": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.4.tgz", - "integrity": "sha512-zeFezwyXeG4syyYHbvh1A967IAqq/67yXtXvuL5wnqCkFZe8I0vKfm+EO+YEvLguo6w9CDUbrAXVtJSHh2E8rw==", + "version": "3.6.11", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.11.tgz", + "integrity": "sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { - "@babel/parser": "^7.20.15", - "@jsdoc/salty": "^0.2.1", - "@types/markdown-it": "^14.1.1", + "@babel/parser": "^7.9.4", + "@types/markdown-it": "^12.2.3", "bluebird": "^3.7.2", "catharsis": "^0.9.0", "escape-string-regexp": "^2.0.0", "js2xmlparser": "^4.0.2", "klaw": "^3.0.0", - "markdown-it": "^14.1.0", - "markdown-it-anchor": "^8.6.7", + "markdown-it": "^12.3.2", + "markdown-it-anchor": "^8.4.1", "marked": "^4.0.10", "mkdirp": "^1.0.4", "requizzle": "^0.2.3", "strip-json-comments": "^3.1.0", + "taffydb": "2.6.2", "underscore": "~1.13.2" }, "bin": { @@ -8403,22 +8383,84 @@ "node": ">=12.0.0" } }, + "node_modules/jsdoc/node_modules/@types/markdown-it": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", + "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "node_modules/jsdoc/node_modules/entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "dev": true, + "license": "BSD-2-Clause", + "peer": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/jsdoc/node_modules/escape-string-regexp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=8" } }, + "node_modules/jsdoc/node_modules/linkify-it": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.3.tgz", + "integrity": "sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "uc.micro": "^1.0.1" + } + }, + "node_modules/jsdoc/node_modules/markdown-it": { + "version": "12.3.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-12.3.2.tgz", + "integrity": "sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "argparse": "^2.0.1", + "entities": "~2.1.0", + "linkify-it": "^3.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + }, + "bin": { + "markdown-it": "bin/markdown-it.js" + } + }, + "node_modules/jsdoc/node_modules/mdurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", + "integrity": "sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/jsdoc/node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "dev": true, "license": "MIT", + "peer": true, "bin": { "mkdirp": "bin/cmd.js" }, @@ -8426,6 +8468,14 @@ "node": ">=10" } }, + "node_modules/jsdoc/node_modules/uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", + "dev": true, + "license": "MIT", + "peer": true + }, "node_modules/jsdom": { "version": "25.0.1", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-25.0.1.tgz", @@ -8884,7 +8934,6 @@ "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.1.tgz", "integrity": "sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==", "license": "MIT", - "peer": true, "dependencies": { "argparse": "^2.0.1", "entities": "^4.4.0", @@ -10279,7 +10328,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -10836,24 +10884,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/semver": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", - "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "fast-deep-equal": "^3.1.3", - "fast-uri": "^3.0.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, "node_modules/schema-utils/node_modules/ajv-keywords": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", @@ -10867,15 +10897,9 @@ "ajv": "^8.8.2" } }, - "node_modules/schema-utils/node_modules/json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", - "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", - "dev": true, - "license": "MIT" - }, "node_modules/semver": { "version": "7.6.3", + "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -11484,6 +11508,13 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "license": "MIT" }, + "node_modules/taffydb": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", + "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==", + "dev": true, + "peer": true + }, "node_modules/tapable": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", @@ -11742,6 +11773,20 @@ "jsdoc": "^3.6.3" } }, + "node_modules/tsd-jsdoc/node_modules/typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -11896,9 +11941,9 @@ } }, "node_modules/typescript": { - "version": "3.9.10", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", - "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -11906,7 +11951,7 @@ "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, "node_modules/uc.micro": { @@ -12145,7 +12190,6 @@ "integrity": "sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.6", @@ -12193,7 +12237,6 @@ "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", @@ -12275,7 +12318,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -12824,13 +12866,67 @@ "jest": "^29.7.0", "jest-diff": "^29.7.0", "jsdoc": "4.0.4", - "license-check-and-add": "2.3.6" + "license-check-and-add": "2.3.6", + "typescript": "5.7.2" }, "engines": { "node": ">=18", "npm": ">=9" } }, + "packages/markdown-cicero/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-cicero/node_modules/jsdoc": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.4.tgz", + "integrity": "sha512-zeFezwyXeG4syyYHbvh1A967IAqq/67yXtXvuL5wnqCkFZe8I0vKfm+EO+YEvLguo6w9CDUbrAXVtJSHh2E8rw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-cicero/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/markdown-cicero/node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -12843,6 +12939,20 @@ "node": ">=10" } }, + "packages/markdown-cicero/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-cli": { "name": "@accordproject/markdown-cli", "version": "0.16.25", @@ -12862,13 +12972,28 @@ "eslint": "8.57.1", "license-check-and-add": "2.3.6", "mocha": "10.8.2", - "nyc": "17.1.0" + "nyc": "17.1.0", + "typescript": "5.7.2" }, "engines": { "node": ">=18", "npm": ">=9" } }, + "packages/markdown-cli/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-common": { "name": "@accordproject/markdown-common", "version": "0.16.25", @@ -12883,13 +13008,81 @@ "jest": "^29.7.0", "jest-diff": "^29.7.0", "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6" + "license-check-and-add": "2.3.6", + "typescript": "5.7.2" }, "engines": { "node": ">=15", "npm": ">=9" } }, + "packages/markdown-common/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-common/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-common/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/markdown-common/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-html": { "name": "@accordproject/markdown-html", "version": "0.16.25", @@ -12919,6 +13112,7 @@ "stream-browserify": "3.0.0", "stream-http": "3.2.0", "tsd-jsdoc": "^2.5.0", + "typescript": "5.7.2", "vm-browserify": "^1.1.2", "webpack": "5.96.1", "webpack-cli": "5.1.4" @@ -12934,7 +13128,6 @@ "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.26.0", @@ -12997,10 +13190,20 @@ "node": ">=12" } }, - "packages/markdown-html/node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "packages/markdown-html/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-html/node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", "dev": true, "license": "MIT", "dependencies": { @@ -13029,6 +13232,36 @@ "node": ">=8" } }, + "packages/markdown-html/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, "packages/markdown-html/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -13058,6 +13291,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "packages/markdown-html/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/markdown-html/node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -13125,7 +13371,6 @@ "integrity": "sha512-IWrosm/yrn43eiKqkfkHis7QioDleaXQHdDVPKg0FSwwd/DuvyX79TZnFOnYpB7dcsFAMmtFztZuXPDvSePkFw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -13164,6 +13409,20 @@ "semver": "bin/semver.js" } }, + "packages/markdown-html/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-it-cicero": { "name": "@accordproject/markdown-it-cicero", "version": "0.16.25", @@ -13180,13 +13439,81 @@ "jsdoc": "^4.0.4", "license-check-and-add": "2.3.6", "mocha": "10.8.2", - "nyc": "17.1.0" + "nyc": "17.1.0", + "typescript": "5.7.2" }, "engines": { "node": ">=18", "npm": ">=9" } }, + "packages/markdown-it-cicero/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-it-cicero/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-it-cicero/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/markdown-it-cicero/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-it-template": { "name": "@accordproject/markdown-it-template", "version": "0.16.25", @@ -13203,13 +13530,81 @@ "jsdoc": "^4.0.4", "license-check-and-add": "2.3.6", "mocha": "10.8.2", - "nyc": "17.1.0" + "nyc": "17.1.0", + "typescript": "5.7.2" }, "engines": { "node": ">=18", "npm": ">=9" } }, + "packages/markdown-it-template/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-it-template/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-it-template/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "packages/markdown-it-template/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-template": { "name": "@accordproject/markdown-template", "version": "0.16.25", @@ -13242,6 +13637,7 @@ "raw-loader": "^4.0.2", "stream-browserify": "3.0.0", "tsd-jsdoc": "^2.5.0", + "typescript": "5.7.2", "webpack": "5.96.1", "webpack-cli": "5.1.4" }, @@ -13298,6 +13694,59 @@ "node": ">=12" } }, + "packages/markdown-template/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-template/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-template/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/markdown-template/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -13308,6 +13757,20 @@ "semver": "bin/semver.js" } }, + "packages/markdown-template/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "packages/markdown-transform": { "name": "@accordproject/markdown-transform", "version": "0.16.25", @@ -13346,6 +13809,7 @@ "stream-browserify": "3.0.0", "stream-http": "^3.2.0", "tsd-jsdoc": "^2.5.0", + "typescript": "5.7.2", "webpack": "^5.96.1", "webpack-cli": "5.1.4" }, @@ -13360,7 +13824,6 @@ "integrity": "sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.26.0", @@ -13589,6 +14052,59 @@ "@babel/core": "^7.0.0-0" } }, + "packages/markdown-transform/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "packages/markdown-transform/node_modules/jsdoc": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.5.tgz", + "integrity": "sha512-P4C6MWP9yIlMiK8nwoZvxN84vb6MsnXcHuy7XzVOvQoCizWX5JFCBsWIIWKXBltpoRZXddUOVQmCTOZt9yDj9g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "packages/markdown-transform/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "packages/markdown-transform/node_modules/semver": { "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", @@ -13598,6 +14114,20 @@ "bin": { "semver": "bin/semver.js" } + }, + "packages/markdown-transform/node_modules/typescript": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } } } } diff --git a/package.json b/package.json index d7c3684a..4d2ca47a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "mkdirp": "3.0.1", "nyc": "17.1.0", "semver": "^7.6.3", - "traverse": "^0.6.10" + "traverse": "^0.6.10", + "typescript": "^5.4.5" }, "engines": { "node": ">=18", diff --git a/packages/markdown-cicero/package.json b/packages/markdown-cicero/package.json index 8dfbc6b6..fb06fcc5 100644 --- a/packages/markdown-cicero/package.json +++ b/packages/markdown-cicero/package.json @@ -1,124 +1,129 @@ { - "name": "@accordproject/markdown-cicero", - "version": "0.16.25", - "description": "A framework for transforming markdown", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "lib" - ], - "main": "index.js", - "scripts": { - "pretest": "npm run lint", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "jest --timeOut=10000 --silent", - "test:updateSnapshot": "jest --updateSnapshot --silent", - "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", - "jsdoc": "jsdoc -c jsdoc.json package.json" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-cicero" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform", - "devDependencies": { - "eslint": "8.57.1", - "jest": "^29.7.0", - "jest-diff": "^29.7.0", - "jsdoc": "4.0.4", - "license-check-and-add": "2.3.6" - }, - "dependencies": { - "@accordproject/concerto-core": "3.25.7", - "@accordproject/markdown-common": "*", - "@accordproject/markdown-it-cicero": "*", - "markdown-it": "^14.1.0", - "semver": "7.6.3", - "winston": "3.17.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-cicero", + "version": "0.16.25", + "description": "A framework for transforming markdown", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "scripts": { + "build": "npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "jest --timeOut=10000 --silent", + "test:updateSnapshot": "jest --updateSnapshot --silent", + "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", + "jsdoc": "jsdoc -c jsdoc.json package.json" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-cicero" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform", + "devDependencies": { + "eslint": "8.57.1", + "jest": "^29.7.0", + "jest-diff": "^29.7.0", + "jsdoc": "4.0.4", + "license-check-and-add": "2.3.6", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/concerto-core": "3.25.7", + "@accordproject/markdown-common": "*", + "@accordproject/markdown-it-cicero": "*", + "markdown-it": "^14.1.0", + "semver": "7.6.3", + "winston": "3.17.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 90, + "branches": 71, + "functions": 88, + "lines": 90 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 90, - "branches": 71, - "functions": 88, - "lines": 90 - } } diff --git a/packages/markdown-cicero/types/index.d.ts b/packages/markdown-cicero/types/index.d.ts new file mode 100644 index 00000000..c9528b41 --- /dev/null +++ b/packages/markdown-cicero/types/index.d.ts @@ -0,0 +1,4 @@ +export const CiceroMarkTransformer: typeof import("./lib/CiceroMarkTransformer"); +export const FromCiceroEditVisitor: typeof import("./lib/FromCiceroEditVisitor"); +export const ToCommonMarkVisitor: typeof import("./lib/ToCommonMarkVisitor"); +export const Decorators: typeof import("./lib/Decorators"); diff --git a/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts b/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts new file mode 100644 index 00000000..ca9e5dc9 --- /dev/null +++ b/packages/markdown-cicero/types/lib/CiceroMarkTransformer.d.ts @@ -0,0 +1,107 @@ +export = CiceroMarkTransformer; +/** + * Converts a CiceroMark DOM to/from a + * CommonMark DOM. + * + * Converts a CiceroMark DOM to/from a markdown string. + */ +declare class CiceroMarkTransformer { + commonMark: import("@accordproject/markdown-common/types/lib/CommonMarkTransformer"); + modelManager: ModelManager; + serializer: Serializer; + /** + * Obtain the Clause text for a Clause node + * @param {*} input CiceroMark DOM + * @returns {*} markdown_cicero string + */ + getClauseText(input: any): any; + /** + * Retrieve the serializer used by the parser + * + * @returns {*} a serializer capable of dealing with the Concerto + * object returns by parse + */ + getSerializer(): any; + /** + * Converts a CiceroEdit string to a CiceroMark DOM + * @param {*} input - ciceroedit string + * @returns {*} CiceroMark DOM + */ + fromCiceroEdit(input: any): any; + /** + * Converts a CiceroMark DOM to a CiceroMark Unwrapped DOM + * @param {object} input - CiceroMark DOM (JSON) + * @param {object} [options] configuration options + * @param {boolean} [options.unquoteVariables] if true variable quotations are removed + * @returns {*} CiceroMark DOM + */ + toCiceroMarkUnwrapped(input: object, options?: { + unquoteVariables?: boolean; + }): any; + /** + * Converts a CommonMark DOM to a CiceroMark DOM + * @param {*} input - CommonMark DOM (in JSON) + * @returns {*} CiceroMark DOM + */ + fromCommonMark(input: any): any; + /** + * Converts a markdown string to a CiceroMark DOM + * @param {string} markdown a markdown string + * @returns {object} ciceromark object (JSON) + */ + fromMarkdown(markdown: string): object; + /** + * Converts a CiceroMark DOM to a markdown string + * @param {*} input CiceroMark DOM + * @param {object} [options] configuration options + * @returns {*} markdown string + */ + toMarkdown(input: any, options?: object): any; + /** + * Converts a cicero markdown string to a CiceroMark DOM + * @param {string} markdown a cicero markdown string + * @param {object} [options] configuration options + * @returns {object} ciceromark object (JSON) + */ + fromMarkdownCicero(markdown: string, options?: object): object; + /** + * Converts a CiceroMark DOM to a cicero markdown string + * @param {object} input CiceroMark DOM + * @returns {string} json commonmark object + */ + toMarkdownCicero(input: object): string; + /** + * Converts a CiceroMark DOM to a CommonMark DOM + * @param {*} input CiceroMark DOM + * @param {object} [options] configuration options + * @param {boolean} [options.removeFormatting] if true the formatting nodes are removed + * @param {boolean} [options.unquoteVariables] if true variable quotations are removed + * @returns {*} json commonmark object + */ + toCommonMark(input: any, options?: { + removeFormatting?: boolean; + unquoteVariables?: boolean; + }): any; + /** + * Unquotes a CiceroMark DOM + * @param {object} input CiceroMark DOM + * @returns {object} unquoted CiceroMark DOM + */ + unquote(input: object): object; + /** + * Converts a ciceromark string into a token stream + * + * @param {string} input the string to parse + * @returns {*} a markdown-it token stream + */ + toTokens(input: string): any; + /** + * Converts a token stream into a CiceroMark DOM object. + * + * @param {object} tokenStream the token stream + * @returns {*} the CiceroMark DOM (JSON) + */ + fromTokens(tokenStream: object): any; +} +import { ModelManager } from "@accordproject/concerto-core"; +import { Serializer } from "@accordproject/concerto-core"; diff --git a/packages/markdown-cicero/types/lib/Decorators.d.ts b/packages/markdown-cicero/types/lib/Decorators.d.ts new file mode 100644 index 00000000..260e8380 --- /dev/null +++ b/packages/markdown-cicero/types/lib/Decorators.d.ts @@ -0,0 +1,35 @@ +export = Decorators; +/** + * A class to retrieve decorators on CiceroMark nodes + */ +declare class Decorators { + /** + * Construct an instance, based on a CiceroMark node + * Note that decorator arguments must be specified as an + * array of [name (string),value] pairs, even though this is + * not enforced by the Concerto grammar. + * @param {object} node the CiceroMark node + */ + constructor(node: object); + data: {}; + /** + * Returns true is the decorator is present + * @param {string} decoratorName the name of the decorator + * @returns {boolean} true is the decorator is present + */ + hasDecorator(decoratorName: string): boolean; + /** + * Get the arguments for a named decorator + * @param {string} decoratorName the name of the decorator + * @returns {array} an array of arguments, or null + */ + getArguments(decoratorName: string): any[]; + /** + * Get the arguments for a named decorator + * @param {string} decoratorName the name of the decorator + * @param {string} argumentName the name of the decorator argument + * @returns {object} the value of the argument or null if the decorator + * is missing or undefined if the argument is missing + */ + getDecoratorValue(decoratorName: string, argumentName: string): object; +} diff --git a/packages/markdown-cicero/types/lib/FromCiceroEditVisitor.d.ts b/packages/markdown-cicero/types/lib/FromCiceroEditVisitor.d.ts new file mode 100644 index 00000000..749f03bf --- /dev/null +++ b/packages/markdown-cicero/types/lib/FromCiceroEditVisitor.d.ts @@ -0,0 +1,33 @@ +export = FromCiceroEditVisitor; +/** + * Converts a CommonMark DOM to a CiceroMark DOM + */ +declare class FromCiceroEditVisitor { + /** + * Visits a sub-tree and return CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + */ + static visitChildren(visitor: any, thing: any, parameters?: any): void; + /** + * Visits a list of nodes and return the CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} things the list node to visit + * @param {*} [parameters] optional parameters + */ + static visitNodes(visitor: any, things: any, parameters?: any): void; + /** + * Find an attribute from its name + * @param {*} attributes - the array of attributes + * @param {string} name - the name of the attributes + * @return {*} the attribute or undefined + */ + static getAttribute(attributes: any, name: string): any; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + */ + visit(thing: any, parameters: any): void; +} diff --git a/packages/markdown-cicero/types/lib/ToCiceroMarkUnwrappedVisitor.d.ts b/packages/markdown-cicero/types/lib/ToCiceroMarkUnwrappedVisitor.d.ts new file mode 100644 index 00000000..075b9086 --- /dev/null +++ b/packages/markdown-cicero/types/lib/ToCiceroMarkUnwrappedVisitor.d.ts @@ -0,0 +1,20 @@ +export = ToCiceroMarkUnwrappedVisitor; +/** + * Converts a CiceroMark DOM to a CiceroMark unwrapped DOM + */ +declare class ToCiceroMarkUnwrappedVisitor { + /** + * Visits a sub-tree and return the CommonMark DOM + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + */ + static visitChildren(visitor: any, thing: any, parameters?: any): void; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + * @return {*[]} result nodes + */ + visit(thing: any, parameters: any): any[]; +} diff --git a/packages/markdown-cicero/types/lib/ToCommonMarkVisitor.d.ts b/packages/markdown-cicero/types/lib/ToCommonMarkVisitor.d.ts new file mode 100644 index 00000000..c54c7a79 --- /dev/null +++ b/packages/markdown-cicero/types/lib/ToCommonMarkVisitor.d.ts @@ -0,0 +1,20 @@ +export = ToCommonMarkVisitor; +/** + * Converts a CiceroMark DOM to a CommonMark DOM + */ +declare class ToCommonMarkVisitor { + /** + * Visits a sub-tree and return the CommonMark DOM + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + */ + static visitChildren(visitor: any, thing: any, parameters?: any): void; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + * @return {*[]} result nodes + */ + visit(thing: any, parameters: any): any[]; +} diff --git a/packages/markdown-cicero/types/lib/ToMarkdownCiceroVisitor.d.ts b/packages/markdown-cicero/types/lib/ToMarkdownCiceroVisitor.d.ts new file mode 100644 index 00000000..16231561 --- /dev/null +++ b/packages/markdown-cicero/types/lib/ToMarkdownCiceroVisitor.d.ts @@ -0,0 +1,20 @@ +export = ToMarkdownCiceroVisitor; +declare const ToMarkdownCiceroVisitor_base: typeof import("@accordproject/markdown-common/types/lib/FromCommonMarkVisitor"); +/** + * Converts a CiceroMark DOM to a cicero markdown string. + */ +declare class ToMarkdownCiceroVisitor extends ToMarkdownCiceroVisitor_base { + /** + * Construct the visitor. + * @param {object} [options] configuration options + * @param {*} resultSeq how to sequentially combine results + * @param {object} rules how to process each node type + */ + constructor(options?: object); + /** + * Converts a CiceroMark DOM to a cicero markdown string. + * @param {*} input - CiceroMark DOM (JSON) + * @returns {string} the cicero markdown string + */ + toMarkdownCicero(input: any): string; +} diff --git a/packages/markdown-cicero/types/lib/UnquoteVariables.d.ts b/packages/markdown-cicero/types/lib/UnquoteVariables.d.ts new file mode 100644 index 00000000..0cfc4880 --- /dev/null +++ b/packages/markdown-cicero/types/lib/UnquoteVariables.d.ts @@ -0,0 +1,8 @@ +export = unquoteVariables; +/** +* Replaces variable and formulas with text nodes +* @param {*} input input object +* @param {*} options options object +* @returns {*} the modified object +*/ +declare function unquoteVariables(input: any): any; diff --git a/packages/markdown-cicero/types/lib/cicerorules.d.ts b/packages/markdown-cicero/types/lib/cicerorules.d.ts new file mode 100644 index 00000000..d24072be --- /dev/null +++ b/packages/markdown-cicero/types/lib/cicerorules.d.ts @@ -0,0 +1,38 @@ +declare namespace formulaRule { + let tag: string; + let leaf: boolean; + let open: boolean; + let close: boolean; + function enter(node: any, token: any, callback: any): void; + let skipEmpty: boolean; +} +declare namespace clauseOpenRule { + let tag_1: string; + export { tag_1 as tag }; + let leaf_1: boolean; + export { leaf_1 as leaf }; + let open_1: boolean; + export { open_1 as open }; + let close_1: boolean; + export { close_1 as close }; + export function enter_1(node: any, token: any, callback: any): void; + export { enter_1 as enter }; +} +declare namespace clauseCloseRule { + let tag_2: string; + export { tag_2 as tag }; + let leaf_2: boolean; + export { leaf_2 as leaf }; + let open_2: boolean; + export { open_2 as open }; + let close_2: boolean; + export { close_2 as close }; +} +export namespace inlines { + export { formulaRule as formula }; +} +export namespace blocks { + export { clauseOpenRule as block_clause_open }; + export { clauseCloseRule as block_clause_close }; +} +export {}; diff --git a/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts b/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts new file mode 100644 index 00000000..d37e1105 --- /dev/null +++ b/packages/markdown-cicero/types/lib/fromciceromarkrules.d.ts @@ -0,0 +1,2 @@ +export function Formula(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Clause(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; diff --git a/packages/markdown-cli/package.json b/packages/markdown-cli/package.json index aa0a75f4..daf13ec7 100644 --- a/packages/markdown-cli/package.json +++ b/packages/markdown-cli/package.json @@ -1,124 +1,129 @@ { - "name": "@accordproject/markdown-cli", - "version": "0.16.25", - "description": "A framework for transforming markdown", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "bin": { - "markus": "index.js" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "scripts": { - "pretest": "npm run lint", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "mocha --exclude test/extension --timeout 30000", - "test:cov": "npm run lint && nyc mocha --timeout 30000" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-cli" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "devDependencies": { - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-things": "0.2.0", - "eslint": "8.57.1", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "nyc": "17.1.0" - }, - "dependencies": { - "@accordproject/concerto-util": "3.25.7", - "@accordproject/markdown-transform": "*", - "yargs": "17.7.2" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-cli", + "version": "0.16.25", + "description": "A framework for transforming markdown", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "bin": { + "markus": "index.js" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "scripts": { + "build": "npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "mocha --exclude test/extension --timeout 30000", + "test:cov": "npm run lint && nyc mocha --timeout 30000" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-cli" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "devDependencies": { + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-things": "0.2.0", + "eslint": "8.57.1", + "license-check-and-add": "2.3.6", + "mocha": "10.8.2", + "nyc": "17.1.0", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/concerto-util": "3.25.7", + "@accordproject/markdown-transform": "*", + "yargs": "17.7.2" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 78, + "branches": 61, + "functions": 77, + "lines": 77 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 78, - "branches": 61, - "functions": 77, - "lines": 77 - } } diff --git a/packages/markdown-cli/types/index.d.ts b/packages/markdown-cli/types/index.d.ts new file mode 100644 index 00000000..b7988016 --- /dev/null +++ b/packages/markdown-cli/types/index.d.ts @@ -0,0 +1,2 @@ +#!/usr/bin/env node +export {}; diff --git a/packages/markdown-cli/types/lib/commands.d.ts b/packages/markdown-cli/types/lib/commands.d.ts new file mode 100644 index 00000000..35e84b8d --- /dev/null +++ b/packages/markdown-cli/types/lib/commands.d.ts @@ -0,0 +1,66 @@ +export = Commands; +/** + * Utility class that implements the commands exposed by the CLI. + * @class + */ +declare class Commands { + /** + * Load an input file + * @param {*} engine - the transformation engine + * @param {string} filePath - the file name + * @param {string} format - the format + * @returns {*} the content - of the file + */ + static loadFormatFromFile(engine: any, filePath: string, format: string): any; + /** + * Prints a format to string + * @param {*} engine - the transformation engine + * @param {*} input - the input + * @param {string} format - the format + * @returns {string} the string representation + */ + static printFormatToString(engine: any, input: any, format: string): string; + /** + * Prints a format to file + * @param {*} engine - the transformation engine + * @param {*} input the input + * @param {string} format the format + * @param {string} filePath the file name + */ + static printFormatToFile(engine: any, input: any, format: string, filePath: string): void; + /** + * Set a default for a file argument + * + * @param {object} argv the inbound argument values object + * @param {string} argName the argument name + * @param {string} argDefaultName the argument default name + * @param {Function} argDefaultFun how to compute the argument default + * @returns {object} a modified argument object + */ + static setDefaultFileArg(argv: object, argName: string, argDefaultName: string, argDefaultFun: Function): object; + /** + * Set default params before we transform + * + * @param {object} argv the inbound argument values object + * @returns {object} a modfied argument object + */ + static validateTransformArgs(argv: object): object; + /** + * Transform between formats + * + * @param {string} inputPath to the input file + * @param {string} from the source format + * @param {string[]} via intermediate formats + * @param {string} to the target format + * @param {string} outputPath to an output file + * @param {object} parameters the transform parameters + * @param {object} [options] configuration options + * @param {boolean} [options.verbose] verbose output + * @param {boolean} [options.roundtrip] roundtrip transform back to source format + * @returns {object} Promise to the result of parsing + */ + static transform(inputPath: string, from: string, via: string[], to: string, outputPath: string, parameters: object, options?: { + verbose?: boolean; + roundtrip?: boolean; + }): object; +} diff --git a/packages/markdown-common/index.js b/packages/markdown-common/index.js index 2c7f917e..36e07cd0 100644 --- a/packages/markdown-common/index.js +++ b/packages/markdown-common/index.js @@ -29,6 +29,7 @@ module.exports.TemplateMarkModel = require('./lib/externalModels/TemplateMarkMod module.exports.CommonMarkUtils = require('./lib/CommonMarkUtils'); module.exports.FromCommonMarkVisitor = require('./lib/FromCommonMarkVisitor'); +/** @type {Record} */ module.exports.fromcommonmarkrules = require('./lib/fromcommonmarkrules'); module.exports.CommonMarkTransformer = require('./lib/CommonMarkTransformer'); diff --git a/packages/markdown-common/lib/FromCommonMarkVisitor.js b/packages/markdown-common/lib/FromCommonMarkVisitor.js index 664d4587..e9520849 100644 --- a/packages/markdown-common/lib/FromCommonMarkVisitor.js +++ b/packages/markdown-common/lib/FromCommonMarkVisitor.js @@ -22,7 +22,7 @@ const CommonMarkUtils = require('./CommonMarkUtils'); class FromCommonMarkVisitor { /** * Construct the visitor. - * @param {object} [options] configuration options + * @param {object} options configuration options * @param {*} resultString how to create a result from a string * @param {*} resultSeq how to sequentially combine results * @param {object} rules how to process each node type diff --git a/packages/markdown-common/package.json b/packages/markdown-common/package.json index eebf67b6..1cc0e9cd 100644 --- a/packages/markdown-common/package.json +++ b/packages/markdown-common/package.json @@ -1,97 +1,102 @@ { - "name": "@accordproject/markdown-common", - "version": "0.16.25", - "description": "A framework for transforming markdown", - "engines": { - "node": ">=15", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "lib" - ], - "main": "index.js", - "scripts": { - "pretest": "npm run lint", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "jest --timeOut=10000 --silent", - "test:updateSnapshot": "jest --updateSnapshot --silent", - "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", - "jsdoc": "jsdoc -c jsdoc.json package.json" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-common" - }, - "keywords": [ - "accord-project", - "markdown", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform", - "devDependencies": { - "eslint": "8.57.1", - "jest": "^29.7.0", - "jest-diff": "^29.7.0", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6" - }, - "dependencies": { - "@accordproject/concerto-core": "3.25.7", - "@xmldom/xmldom": "^0.9.5", - "markdown-it": "^14.1.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-common", + "version": "0.16.25", + "description": "A framework for transforming markdown", + "engines": { + "node": ">=15", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "lib", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "scripts": { + "build": "npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "jest --timeOut=10000 --silent", + "test:updateSnapshot": "jest --updateSnapshot --silent", + "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", + "jsdoc": "jsdoc -c jsdoc.json package.json" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-common" + }, + "keywords": [ + "accord-project", + "markdown", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform", + "devDependencies": { + "eslint": "8.57.1", + "jest": "^29.7.0", + "jest-diff": "^29.7.0", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/concerto-core": "3.25.7", + "@xmldom/xmldom": "^0.9.5", + "markdown-it": "^14.1.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } } - } } diff --git a/packages/markdown-common/types/index.d.ts b/packages/markdown-common/types/index.d.ts new file mode 100644 index 00000000..c0af9e69 --- /dev/null +++ b/packages/markdown-common/types/index.d.ts @@ -0,0 +1,11 @@ +export const Stack: typeof import("./lib/Stack"); +export const CommonMarkModel: typeof import("./lib/externalModels/CommonMarkModel"); +export const CiceroMarkModel: typeof import("./lib/externalModels/CiceroMarkModel"); +export const ConcertoMetaModel: typeof import("./lib/externalModels/ConcertoMetaModel"); +export const TemplateMarkModel: typeof import("./lib/externalModels/TemplateMarkModel"); +export const CommonMarkUtils: typeof import("./lib/CommonMarkUtils"); +export const FromCommonMarkVisitor: typeof import("./lib/FromCommonMarkVisitor"); +export const fromcommonmarkrules: Record; +export const CommonMarkTransformer: typeof import("./lib/CommonMarkTransformer"); +export const ToMarkdownVisitor: typeof import("./lib/ToMarkdownVisitor"); +export const FromMarkdownIt: typeof import("./lib/FromMarkdownIt"); diff --git a/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts b/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts new file mode 100644 index 00000000..3788fca9 --- /dev/null +++ b/packages/markdown-common/types/lib/CommonMarkTransformer.d.ts @@ -0,0 +1,49 @@ +export = CommonMarkTransformer; +/** + * Parses markdown using the commonmark parser into the + * intermediate representation: a JSON object that adheres to + * the 'org.accordproject.commonmark' Concerto model. + */ +declare class CommonMarkTransformer { + serializer: Serializer; + /** + * Converts a CommonMark DOM to a markdown string + * @param {*} input - CommonMark DOM (in JSON) + * @returns {string} the markdown string + */ + toMarkdown(input: any): string; + /** + * Converts a CommonMark DOM to a CommonMark DOM with formatting removed + * @param {*} input - CommonMark DOM (in JSON) + * @returns {string} the CommonMark DOM with formatting nodes removed + */ + removeFormatting(input: any): string; + /** + * Converts a markdown string into a token stream + * + * @param {string} markdown the string to parse + * @returns {*} a markdown-it token stream + */ + toTokens(markdown: string): any; + /** + * Converts a token stream into a CommonMark DOM object. + * + * @param {object} tokenStream the token stream + * @returns {*} a Concerto object (DOM) for the markdown content + */ + fromTokens(tokenStream: object): any; + /** + * Converts a markdown string into a CommonMark DOM object. + * + * @param {string} markdown the string to parse + * @returns {object} a CommonMark DOM (JSON) for the markdown content + */ + fromMarkdown(markdown: string): object; + /** + * Retrieve the serializer used by the parser + * + * @returns {*} a serializer capable of dealing with the Concerto + */ + getSerializer(): any; +} +import { Serializer } from "@accordproject/concerto-core"; diff --git a/packages/markdown-common/types/lib/CommonMarkUtils.d.ts b/packages/markdown-common/types/lib/CommonMarkUtils.d.ts new file mode 100644 index 00000000..d829a9fd --- /dev/null +++ b/packages/markdown-common/types/lib/CommonMarkUtils.d.ts @@ -0,0 +1,108 @@ +/** + * CommonMark Utilities + */ +/** + * Initial block stack + * @return {*} the block stack + */ +export function blocksInit(): any; +/** + * Next node + * @param {*} parameters the current parameters + */ +export function nextNode(parameters: any): void; +/** + * Set parameters for general blocks + * @param {*} ast - the current ast node + * @param {*} parametersOut - the current parameters + * @param {*} init - initial result value + * @param {*} setFirst whether entering this block should set first + * @return {*} the new parameters with block quote level incremented + */ +export function mkParameters(ast: any, parametersOut: any, init: any, setFirst: any): any; +/** + * Create a single new line + * @param {*} parameters - the parameters + * @return {string} the prefix + */ +export function mkNewLine(parameters: any): string; +/** + * Create a line prefix + * @param {*} parameters - the parameters + * @param {*} nb - number of newlines + * @return {string} the prefix + */ +export function mkPrefix(parameters: any, nb: any): string; +/** + * Create Setext heading + * @param {number} level - the heading level + * @return {string} the markup for the heading + */ +export function mkSetextHeading(level: number): string; +/** + * Create ATX heading + * @param {number} level - the heading level + * @return {string} the markup for the heading + */ +export function mkATXHeading(level: number): string; +/** + * Create table heading + * @param {number} col - the number of columns + * @return {string} the markup for the table heading + */ +export function mkTableHeading(col: number): string; +/** + * Adding escapes for text nodes + * @param {string} input - unescaped + * @return {string} escaped + */ +export function escapeText(input: string): string; +/** + * Adding escapes for code blocks + * @param {string} input - unescaped + * @return {string} escaped + */ +export function escapeCodeBlock(input: string): string; +/** + * Removing escapes + * @param {string} input - escaped + * @return {string} unescaped + */ +export function unescapeCodeBlock(input: string): string; +/** + * Parses an HTML block and extracts the attributes, tag name and tag contents. + * Note that this will return null for strings like this: + * @param {string} string - the HTML block to parse + * @return {Object} - a tag object that holds the data for the html block + */ +export function parseHtmlBlock(string: string): any; +/** + * Merge adjacent Html nodes in a list of nodes + * @param {[*]} nodes - a list of nodes + * @param {boolean} tagInfo - whether to extract Html tags + * @returns {*} a new list of nodes with open/closed Html nodes merged + */ +export function mergeAdjacentHtmlNodes(nodes: [any], tagInfo: boolean): any; +/** + * Determine the heading level + * + * @param {string} tag the heading tag + * @returns {string} the heading level + */ +export function headingLevel(tag: string): string; +/** + * Get an attribute value + * + * @param {*} attrs open ordered list attributes + * @param {string} name attribute name + * @param {*} def a default value + * @returns {string} the initial index + */ +export function getAttr(attrs: any, name: string, def: any): string; +/** + * Trim single ending newline + * + * @param {string} text the input text + * @returns {string} the trimmed text + */ +export function trimEndline(text: string): string; diff --git a/packages/markdown-common/types/lib/FromCommonMarkVisitor.d.ts b/packages/markdown-common/types/lib/FromCommonMarkVisitor.d.ts new file mode 100644 index 00000000..46135ff5 --- /dev/null +++ b/packages/markdown-common/types/lib/FromCommonMarkVisitor.d.ts @@ -0,0 +1,35 @@ +export = FromCommonMarkVisitor; +/** + * Converts a CommonMark DOM to something else + */ +declare class FromCommonMarkVisitor { + /** + * Construct the visitor. + * @param {object} options configuration options + * @param {*} resultString how to create a result from a string + * @param {*} resultSeq how to sequentially combine results + * @param {object} rules how to process each node type + * @param {*} setFirst whether entering this block should set first + */ + constructor(options: object, resultString: any, resultSeq: any, rules: object, setFirst: any); + options: any; + resultString: any; + resultSeq: any; + rules: any; + setFirst: any; + /** + * Visits a sub-tree + * @param {*} visitor - the visitor to use + * @param {*} thing - the node to visit + * @param {*} parameters - the current parameters + * @param {string} field - where to find the children nodes + * @returns {*} the result for the sub tree + */ + visitChildren(visitor: any, thing: any, parameters: any, field?: string): any; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + */ + visit(thing: any, parameters: any): void; +} diff --git a/packages/markdown-common/types/lib/FromMarkdownIt.d.ts b/packages/markdown-common/types/lib/FromMarkdownIt.d.ts new file mode 100644 index 00000000..e78f6104 --- /dev/null +++ b/packages/markdown-common/types/lib/FromMarkdownIt.d.ts @@ -0,0 +1,55 @@ +export = FromMarkdownIt; +/** + * Converts a markdown-it token stream to a CommonMark DOM + */ +declare class FromMarkdownIt { + /** + * Takes the stack of constructed inline nodes + * properly closing them (if the close token is missing in the markdown) + * returns the final root node for the inline + * + * @param {*[]} rules - the rules for each kind of markdown-it tokens + * @param {*[]} stack - the stack of constructed nodes + * @returns {*} the final inline node + */ + static closeInlines(rules: any[], stack: any[]): any; + /** + * Create a callback for inlines + * + * @param {*[]} rules - the rules for each kind of markdown-it tokens + * @returns {*} the callback + */ + static inlineCallback(rules: any[]): any; + /** + * Process an inline node to CommonMark DOM + * + * @param {*[]} rules - the rules for each kind of markdown-it tokens + * @param {*} tokens - the content of the inline node + * @param {*[]} stack - the stack of constructed nodes + */ + static inlineToCommonMark(rules: any[], tokens: any, stack: any[]): void; + /** + * Transform a block token stream to CommonMark DOM + * + * @param {*[]} rules - the rules for each kind of markdown-it tokens + * @param {*} tokens - the markdown-it token stream + * @returns {*} the CommonMark nodes + */ + static blockToCommonMark(rules: any[], tokens: any): any; + /** + * Construct the transformer + * @param {*[]} rules - the rules for each kind of markdown-it tokens + */ + constructor(rules: any[]); + rules: { + inlines: {}; + blocks: {}; + }; + /** + * Transform a token stream to CommonMark DOM + * + * @param {*} tokens - the markdown-it token stream + * @returns {*} the CommonMark nodes + */ + toCommonMark(tokens: any): any; +} diff --git a/packages/markdown-common/types/lib/Stack.d.ts b/packages/markdown-common/types/lib/Stack.d.ts new file mode 100644 index 00000000..b3acfdc3 --- /dev/null +++ b/packages/markdown-common/types/lib/Stack.d.ts @@ -0,0 +1,33 @@ +export = Stack; +/** + * Manages a stack of objects + */ +declare class Stack { + /** + * Clears the stack + */ + clear(): void; + stack: any[]; + /** + * Returns the top of the stack or null if the stack is empty + * @return {*} the top of the stack + */ + peek(): any; + /** + * Pushes a new object to the top of the stack + * @param {*} obj the node to push + * @param {boolean} appendItem whether the item is also appended as a child to + * the item at the top of the stack + */ + push(obj: any, appendItem?: boolean): void; + /** + * Appends an object to the 'nodes' array of the item at the top of the stack + * @param {*} obj the item to append to the top node + */ + append(obj: any): void; + /** + * Pops the top of the stack. + * @return {*} the top of the stack + */ + pop(): any; +} diff --git a/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts b/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts new file mode 100644 index 00000000..e57beb3c --- /dev/null +++ b/packages/markdown-common/types/lib/ToMarkdownVisitor.d.ts @@ -0,0 +1,24 @@ +export = ToMarkdownVisitor; +/** + * Converts a CommonMark DOM to a markdown string. + * + * Note that there are multiple ways of representing the same CommonMark DOM as text, + * so this transformation is not guaranteed to equivalent if you roundtrip + * markdown content. For example an H1 can be specified using either '#' or '=' + * notation. + * + * The resulting AST *should* be equivalent however. + */ +declare class ToMarkdownVisitor extends FromCommonMarkVisitor { + /** + * Construct the visitor. + */ + constructor(); + /** + * Converts a CommonMark DOM to a markdown string + * @param {*} input - CommonMark DOM (as a Concerto object) + * @returns {string} the markdown string + */ + toMarkdown(input: any): string; +} +import FromCommonMarkVisitor = require("./FromCommonMarkVisitor"); diff --git a/packages/markdown-common/types/lib/externalModels/CiceroMarkModel.d.ts b/packages/markdown-common/types/lib/externalModels/CiceroMarkModel.d.ts new file mode 100644 index 00000000..ce12b16d --- /dev/null +++ b/packages/markdown-common/types/lib/externalModels/CiceroMarkModel.d.ts @@ -0,0 +1,2 @@ +export const NAMESPACE: "org.accordproject.ciceromark@0.6.0"; +export const MODEL: "\n/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconcerto version \"^3.0.0\"\nnamespace org.accordproject.ciceromark@0.6.0\n\nimport org.accordproject.commonmark@0.5.0.Child from https://models.accordproject.org/markdown/commonmark@0.5.0.cto\nimport concerto.metamodel@1.0.0.Decorator from https://models.accordproject.org/concerto/metamodel@1.0.0.cto\n\n/**\n * A model for Accord Project extensions to commonmark\n */\n\nabstract concept Element extends Child {\n o String name\n o String elementType optional\n o Decorator[] decorators optional\n}\n\nconcept Variable extends Element {\n o String value\n o String identifiedBy optional\n}\n\nconcept FormattedVariable extends Variable {\n o String format\n}\n\nconcept EnumVariable extends Variable {\n o String[] enumValues\n}\n\nconcept Formula extends Element {\n o String value\n o String[] dependencies optional\n o String code optional\n}\n\nabstract concept Block extends Element {\n}\n\nconcept Clause extends Block {\n o String src optional\n}\n\nconcept Contract extends Block {\n o String src optional\n}\n\nconcept Conditional extends Block {\n o Boolean isTrue\n o Child[] whenTrue\n o Child[] whenFalse\n}\n\nconcept Optional extends Block {\n o Boolean hasSome\n o Child[] whenSome\n o Child[] whenNone\n}\n\nconcept ListBlock extends Block {\n o String type\n o String tight\n o String start optional\n o String delimiter optional\n}\n\n"; diff --git a/packages/markdown-common/types/lib/externalModels/CommonMarkModel.d.ts b/packages/markdown-common/types/lib/externalModels/CommonMarkModel.d.ts new file mode 100644 index 00000000..60d7610f --- /dev/null +++ b/packages/markdown-common/types/lib/externalModels/CommonMarkModel.d.ts @@ -0,0 +1,2 @@ +export const NAMESPACE: "org.accordproject.commonmark@0.5.0"; +export const MODEL: "\n/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconcerto version \"^3.0.0\"\nnamespace org.accordproject.commonmark@0.5.0\n\n/**\n * A model for a commonmark format markdown file\n */\n\nabstract concept Node {\n o String text optional\n o Node[] nodes optional\n o Integer startLine optional\n o Integer endLine optional\n}\n\nabstract concept Root extends Node {\n}\n\nabstract concept Child extends Node {\n}\n\nconcept Text extends Child {\n}\n\nconcept Attribute {\n o String name\n o String value\n}\nconcept TagInfo {\n o String tagName\n o String attributeString\n o Attribute[] attributes\n o String content\n o Boolean closed\n}\n\nconcept CodeBlock extends Child {\n o String info optional\n o TagInfo tag optional\n}\n\nconcept Code extends Child {\n o String info optional\n}\n\nconcept HtmlInline extends Child {\n o TagInfo tag optional\n}\n\nconcept HtmlBlock extends Child {\n o TagInfo tag optional\n}\n\nconcept Emph extends Child {\n}\n\nconcept Strong extends Child {\n}\n\nconcept BlockQuote extends Child {\n}\n\nconcept Heading extends Child {\n o String level\n}\n\nconcept ThematicBreak extends Child {\n}\n\nconcept Softbreak extends Child {\n}\n\nconcept Linebreak extends Child {\n}\n\nconcept Link extends Child {\n o String destination\n o String title\n}\n\nconcept Image extends Child {\n o String destination\n o String title\n}\n\nconcept Paragraph extends Child {\n}\n\nconcept List extends Child {\n o String type\n o String start optional\n o String tight\n o String delimiter optional\n}\n\nconcept Item extends Child {\n}\n\nconcept Document extends Root {\n o String xmlns\n}\n\nconcept Table extends Child{ \n}\n\nconcept TableHead extends Child{\n}\n\nconcept TableBody extends Child{\n}\n\nconcept TableRow extends Child{\n} \n\nconcept HeaderCell extends Child{\n}\n\nconcept TableCell extends Child{\n}\n"; diff --git a/packages/markdown-common/types/lib/externalModels/ConcertoMetaModel.d.ts b/packages/markdown-common/types/lib/externalModels/ConcertoMetaModel.d.ts new file mode 100644 index 00000000..3b9ecd24 --- /dev/null +++ b/packages/markdown-common/types/lib/externalModels/ConcertoMetaModel.d.ts @@ -0,0 +1,2 @@ +export const NAMESPACE: "concerto.metamodel@1.0.0"; +export const MODEL: "\n/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconcerto version \"^3.0.0\"\n\n@DotNetNamespace(\"AccordProject.Concerto.Metamodel\")\nnamespace concerto.metamodel@1.0.0\n\nconcept Position {\n o Integer line\n o Integer column\n o Integer offset\n}\n\nconcept Range {\n o Position start\n o Position end\n o String source optional\n}\n\nconcept TypeIdentifier {\n o String name\n o String namespace optional\n}\n\nabstract concept DecoratorLiteral {\n o Range location optional\n}\n\nconcept DecoratorString extends DecoratorLiteral {\n o String value\n}\n\nconcept DecoratorNumber extends DecoratorLiteral {\n o Double value\n}\n\nconcept DecoratorBoolean extends DecoratorLiteral {\n o Boolean value\n}\n\nconcept DecoratorTypeReference extends DecoratorLiteral {\n o TypeIdentifier type\n o Boolean isArray default=false\n}\n\nconcept Decorator {\n o String name\n o DecoratorLiteral[] arguments optional\n o Range location optional\n}\n\nconcept Identified {\n}\n\nconcept IdentifiedBy extends Identified {\n o String name\n}\n\nabstract concept Declaration {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapKeyType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nabstract concept MapValueType {\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept MapDeclaration extends Declaration {\n o MapKeyType key\n o MapValueType value\n}\n\nconcept StringMapKeyType extends MapKeyType {}\nconcept DateTimeMapKeyType extends MapKeyType {}\n\nconcept ObjectMapKeyType extends MapKeyType {\n o TypeIdentifier type\n}\n\nconcept BooleanMapValueType extends MapValueType {}\nconcept DateTimeMapValueType extends MapValueType {}\nconcept StringMapValueType extends MapValueType {}\nconcept IntegerMapValueType extends MapValueType {}\nconcept LongMapValueType extends MapValueType {}\nconcept DoubleMapValueType extends MapValueType {}\n\nconcept ObjectMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept RelationshipMapValueType extends MapValueType {\n o TypeIdentifier type\n}\n\nconcept EnumDeclaration extends Declaration {\n o EnumProperty[] properties\n}\n\nconcept EnumProperty {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept ConceptDeclaration extends Declaration {\n o Boolean isAbstract default=false\n o Identified identified optional\n o TypeIdentifier superType optional\n o Property[] properties\n}\n\nconcept AssetDeclaration extends ConceptDeclaration {\n}\n\nconcept ParticipantDeclaration extends ConceptDeclaration {\n}\n\nconcept TransactionDeclaration extends ConceptDeclaration {\n}\n\nconcept EventDeclaration extends ConceptDeclaration {\n}\n\nabstract concept Property {\n o String name regex=/^(\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4})(?:\\p{Lu}|\\p{Ll}|\\p{Lt}|\\p{Lm}|\\p{Lo}|\\p{Nl}|\\$|_|\\\\u[0-9A-Fa-f]{4}|\\p{Mn}|\\p{Mc}|\\p{Nd}|\\p{Pc}|\\u200C|\\u200D)*$/u\n o Boolean isArray default=false\n o Boolean isOptional default=false\n o Decorator[] decorators optional\n o Range location optional\n}\n\nconcept RelationshipProperty extends Property {\n o TypeIdentifier type\n}\n\nconcept ObjectProperty extends Property {\n o String defaultValue optional\n o TypeIdentifier type\n}\n\nconcept BooleanProperty extends Property {\n o Boolean defaultValue optional\n}\n\nconcept DateTimeProperty extends Property {\n}\n\nconcept StringProperty extends Property {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept StringRegexValidator {\n o String pattern\n o String flags\n}\n\nconcept StringLengthValidator {\n o Integer minLength optional\n o Integer maxLength optional\n}\n\nconcept DoubleProperty extends Property {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept DoubleDomainValidator {\n o Double lower optional\n o Double upper optional\n}\n\nconcept IntegerProperty extends Property {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept IntegerDomainValidator {\n o Integer lower optional\n o Integer upper optional\n}\n\nconcept LongProperty extends Property {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept LongDomainValidator {\n o Long lower optional\n o Long upper optional\n}\n\nconcept AliasedType{\n o String name\n o String aliasedName\n}\nabstract concept Import {\n o String namespace\n o String uri optional\n}\n\nconcept ImportAll extends Import {\n}\n\nconcept ImportType extends Import {\n o String name\n}\n\nconcept ImportTypes extends Import {\n o String[] types\n o AliasedType[] aliasedTypes optional\n}\n\nconcept Model {\n o String namespace\n o String sourceUri optional\n o String concertoVersion optional\n o Import[] imports optional\n o Declaration[] declarations optional\n o Decorator[] decorators optional\n}\n\nconcept Models {\n o Model[] models\n}\n\nabstract concept ScalarDeclaration extends Declaration {\n}\n\nconcept BooleanScalar extends ScalarDeclaration {\n o Boolean defaultValue optional\n}\n\nconcept IntegerScalar extends ScalarDeclaration {\n o Integer defaultValue optional\n o IntegerDomainValidator validator optional\n}\n\nconcept LongScalar extends ScalarDeclaration {\n o Long defaultValue optional\n o LongDomainValidator validator optional\n}\n\nconcept DoubleScalar extends ScalarDeclaration {\n o Double defaultValue optional\n o DoubleDomainValidator validator optional\n}\n\nconcept StringScalar extends ScalarDeclaration {\n o String defaultValue optional\n o StringRegexValidator validator optional\n o StringLengthValidator lengthValidator optional\n}\n\nconcept DateTimeScalar extends ScalarDeclaration {\n o String defaultValue optional\n}\n\n"; diff --git a/packages/markdown-common/types/lib/externalModels/TemplateMarkModel.d.ts b/packages/markdown-common/types/lib/externalModels/TemplateMarkModel.d.ts new file mode 100644 index 00000000..d4fdf80c --- /dev/null +++ b/packages/markdown-common/types/lib/externalModels/TemplateMarkModel.d.ts @@ -0,0 +1,2 @@ +export const NAMESPACE: "org.accordproject.templatemark@0.5.0"; +export const MODEL: "\n/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconcerto version \"^3.0.0\"\nnamespace org.accordproject.templatemark@0.5.0\n\nimport org.accordproject.commonmark@0.5.0.Child from https://models.accordproject.org/markdown/commonmark@0.5.0.cto\nimport concerto.metamodel@1.0.0.Decorator from https://models.accordproject.org/concerto/metamodel@1.0.0.cto\n\n/**\n * A model for Accord Project template extensions to commonmark\n */\n\n/**\n * Identifiers for code strings in Formula Definition nodes\n */\nenum CodeType {\n o TYPESCRIPT\n o ES_2020\n}\n\n/**\n * User provided code, along with a code language identifier\n */\nconcept Code {\n o CodeType type\n o String contents\n}\n\nabstract concept ElementDefinition extends Child {\n o String name\n o String elementType optional\n o Decorator[] decorators optional\n}\n\nconcept VariableDefinition extends ElementDefinition {\n o String identifiedBy optional\n}\n\nconcept FormattedVariableDefinition extends VariableDefinition {\n o String format\n}\n\nconcept EnumVariableDefinition extends VariableDefinition {\n o String[] enumValues\n}\n\nconcept FormulaDefinition extends ElementDefinition {\n o String[] dependencies optional // name of variables on which the formula depends\n o Code code\n}\n\nabstract concept BlockDefinition extends ElementDefinition {\n}\n\nconcept ClauseDefinition extends BlockDefinition {\n o Code condition optional\n}\n\nconcept ContractDefinition extends BlockDefinition {\n}\n\nconcept WithDefinition extends BlockDefinition {\n}\n\nconcept ConditionalDefinition extends BlockDefinition {\n o Child[] whenTrue\n o Child[] whenFalse\n o Code condition optional\n o String[] dependencies optional\n}\n\nconcept OptionalDefinition extends BlockDefinition {\n o Child[] whenSome\n o Child[] whenNone\n}\nconcept JoinDefinition extends BlockDefinition {\n // if separator is set, we just use that\n o String separator optional\n // if separator is not set, we use the Intl.ListFormat, paramaterized by locale, type and style\n o String locale optional\n o String type optional\n o String style optional\n}\n\nconcept ListBlockDefinition extends BlockDefinition {\n o String type\n o String tight\n o String start optional\n o String delimiter optional\n}\n\nconcept ForeachBlockDefinition extends BlockDefinition {\n}\n\nconcept WithBlockDefinition extends BlockDefinition {\n}\n\nconcept ConditionalBlockDefinition extends BlockDefinition {\n o Child[] whenTrue\n o Child[] whenFalse\n o Code condition optional\n}\n\nconcept OptionalBlockDefinition extends BlockDefinition {\n o Child[] whenSome\n o Child[] whenNone\n}\n\n"; diff --git a/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts b/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts new file mode 100644 index 00000000..ebc1c78d --- /dev/null +++ b/packages/markdown-common/types/lib/fromcommonmarkrules.d.ts @@ -0,0 +1,24 @@ +export function Code(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Emph(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Strong(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Link(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Image(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function HtmlInline(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Linebreak(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Softbreak(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Text(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function ThematicBreak(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Heading(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function CodeBlock(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function HtmlBlock(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Paragraph(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function BlockQuote(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Item(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function List(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Document(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function Table(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function TableBody(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function TableRow(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function TableCell(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function TableHead(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function HeaderCell(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; diff --git a/packages/markdown-common/types/lib/removeFormatting.d.ts b/packages/markdown-common/types/lib/removeFormatting.d.ts new file mode 100644 index 00000000..de1f13b3 --- /dev/null +++ b/packages/markdown-common/types/lib/removeFormatting.d.ts @@ -0,0 +1,7 @@ +export = removeFormatting; +/** + * Removes rich text formatting nodes. + * @param {*} obj input object + * @returns {*} the modified object + */ +declare function removeFormatting(obj: any): any; diff --git a/packages/markdown-common/types/lib/tocommonmarkrules.d.ts b/packages/markdown-common/types/lib/tocommonmarkrules.d.ts new file mode 100644 index 00000000..3b567c72 --- /dev/null +++ b/packages/markdown-common/types/lib/tocommonmarkrules.d.ts @@ -0,0 +1,494 @@ +declare namespace textRule { + let tag: string; + let leaf: boolean; + let open: boolean; + let close: boolean; + function enter(node: any, token: any, callback: any): void; + let skipEmpty: boolean; +} +declare namespace codeInlineRule { + let tag_1: string; + export { tag_1 as tag }; + let leaf_1: boolean; + export { leaf_1 as leaf }; + let open_1: boolean; + export { open_1 as open }; + let close_1: boolean; + export { close_1 as close }; + export function enter_1(node: any, token: any, callback: any): void; + export { enter_1 as enter }; + let skipEmpty_1: boolean; + export { skipEmpty_1 as skipEmpty }; +} +declare namespace softbreakRule { + let tag_2: string; + export { tag_2 as tag }; + let leaf_2: boolean; + export { leaf_2 as leaf }; + let open_2: boolean; + export { open_2 as open }; + let close_2: boolean; + export { close_2 as close }; + let skipEmpty_2: boolean; + export { skipEmpty_2 as skipEmpty }; +} +declare namespace hardbreakRule { + let tag_3: string; + export { tag_3 as tag }; + let leaf_3: boolean; + export { leaf_3 as leaf }; + let open_3: boolean; + export { open_3 as open }; + let close_3: boolean; + export { close_3 as close }; + let skipEmpty_3: boolean; + export { skipEmpty_3 as skipEmpty }; +} +declare namespace htmlInlineRule { + let tag_4: string; + export { tag_4 as tag }; + let leaf_4: boolean; + export { leaf_4 as leaf }; + let open_4: boolean; + export { open_4 as open }; + let close_4: boolean; + export { close_4 as close }; + export function enter_2(node: any, token: any, callback: any): void; + export { enter_2 as enter }; + let skipEmpty_4: boolean; + export { skipEmpty_4 as skipEmpty }; +} +declare namespace strongOpenRule { + let tag_5: string; + export { tag_5 as tag }; + let leaf_5: boolean; + export { leaf_5 as leaf }; + let open_5: boolean; + export { open_5 as open }; + let close_5: boolean; + export { close_5 as close }; + let skipEmpty_5: boolean; + export { skipEmpty_5 as skipEmpty }; +} +declare namespace strongCloseRule { + let tag_6: string; + export { tag_6 as tag }; + let leaf_6: boolean; + export { leaf_6 as leaf }; + let open_6: boolean; + export { open_6 as open }; + let close_6: boolean; + export { close_6 as close }; + let skipEmpty_6: boolean; + export { skipEmpty_6 as skipEmpty }; +} +declare namespace emphOpenRule { + let tag_7: string; + export { tag_7 as tag }; + let leaf_7: boolean; + export { leaf_7 as leaf }; + let open_7: boolean; + export { open_7 as open }; + let close_7: boolean; + export { close_7 as close }; + let skipEmpty_7: boolean; + export { skipEmpty_7 as skipEmpty }; +} +declare namespace emphCloseRule { + let tag_8: string; + export { tag_8 as tag }; + let leaf_8: boolean; + export { leaf_8 as leaf }; + let open_8: boolean; + export { open_8 as open }; + let close_8: boolean; + export { close_8 as close }; + let skipEmpty_8: boolean; + export { skipEmpty_8 as skipEmpty }; +} +declare namespace linkOpenRule { + let tag_9: string; + export { tag_9 as tag }; + let leaf_9: boolean; + export { leaf_9 as leaf }; + let open_9: boolean; + export { open_9 as open }; + let close_9: boolean; + export { close_9 as close }; + export function enter_3(node: any, token: any, callback: any): void; + export { enter_3 as enter }; + let skipEmpty_9: boolean; + export { skipEmpty_9 as skipEmpty }; +} +declare namespace linkCloseRule { + let tag_10: string; + export { tag_10 as tag }; + let leaf_10: boolean; + export { leaf_10 as leaf }; + let open_10: boolean; + export { open_10 as open }; + let close_10: boolean; + export { close_10 as close }; + let skipEmpty_10: boolean; + export { skipEmpty_10 as skipEmpty }; +} +declare namespace imageRule { + let tag_11: string; + export { tag_11 as tag }; + let leaf_11: boolean; + export { leaf_11 as leaf }; + let open_11: boolean; + export { open_11 as open }; + let close_11: boolean; + export { close_11 as close }; + export function enter_4(node: any, token: any, callback: any): void; + export { enter_4 as enter }; + let skipEmpty_11: boolean; + export { skipEmpty_11 as skipEmpty }; +} +declare namespace codeBlockRule { + let tag_12: string; + export { tag_12 as tag }; + let leaf_12: boolean; + export { leaf_12 as leaf }; + let open_12: boolean; + export { open_12 as open }; + let close_12: boolean; + export { close_12 as close }; + export function enter_5(node: any, token: any, callback: any): void; + export { enter_5 as enter }; +} +declare namespace fenceRule { } +declare namespace htmlBlockRule { + let tag_13: string; + export { tag_13 as tag }; + let leaf_13: boolean; + export { leaf_13 as leaf }; + let open_13: boolean; + export { open_13 as open }; + let close_13: boolean; + export { close_13 as close }; + export function enter_6(node: any, token: any, callback: any): void; + export { enter_6 as enter }; +} +declare namespace hrRule { + let tag_14: string; + export { tag_14 as tag }; + let leaf_14: boolean; + export { leaf_14 as leaf }; + let open_14: boolean; + export { open_14 as open }; + let close_14: boolean; + export { close_14 as close }; + export function enter_7(node: any, token: any, callback: any): void; + export { enter_7 as enter }; +} +declare namespace paragraphOpenRule { + let tag_15: string; + export { tag_15 as tag }; + let leaf_15: boolean; + export { leaf_15 as leaf }; + let open_15: boolean; + export { open_15 as open }; + let close_15: boolean; + export { close_15 as close }; + export function enter_8(node: any, token: any, callback: any): void; + export { enter_8 as enter }; +} +declare namespace paragraphCloseRule { + let tag_16: string; + export { tag_16 as tag }; + let leaf_16: boolean; + export { leaf_16 as leaf }; + let open_16: boolean; + export { open_16 as open }; + let close_16: boolean; + export { close_16 as close }; +} +declare namespace headingOpenRule { + let tag_17: string; + export { tag_17 as tag }; + let leaf_17: boolean; + export { leaf_17 as leaf }; + let open_17: boolean; + export { open_17 as open }; + let close_17: boolean; + export { close_17 as close }; + export function enter_9(node: any, token: any, callback: any): void; + export { enter_9 as enter }; +} +declare namespace headingCloseRule { + let tag_18: string; + export { tag_18 as tag }; + let leaf_18: boolean; + export { leaf_18 as leaf }; + let open_18: boolean; + export { open_18 as open }; + let close_18: boolean; + export { close_18 as close }; +} +declare namespace blockQuoteOpenRule { + let tag_19: string; + export { tag_19 as tag }; + let leaf_19: boolean; + export { leaf_19 as leaf }; + let open_19: boolean; + export { open_19 as open }; + let close_19: boolean; + export { close_19 as close }; + export function enter_10(node: any, token: any, callback: any): void; + export { enter_10 as enter }; +} +declare namespace blockQuoteCloseRule { + let tag_20: string; + export { tag_20 as tag }; + let leaf_20: boolean; + export { leaf_20 as leaf }; + let open_20: boolean; + export { open_20 as open }; + let close_20: boolean; + export { close_20 as close }; +} +declare namespace bulletListOpenRule { + let tag_21: string; + export { tag_21 as tag }; + let leaf_21: boolean; + export { leaf_21 as leaf }; + let open_21: boolean; + export { open_21 as open }; + let close_21: boolean; + export { close_21 as close }; + export function enter_11(node: any, token: any, callback: any): void; + export { enter_11 as enter }; +} +declare namespace bulletListCloseRule { + let tag_22: string; + export { tag_22 as tag }; + let leaf_22: boolean; + export { leaf_22 as leaf }; + let open_22: boolean; + export { open_22 as open }; + let close_22: boolean; + export { close_22 as close }; +} +declare namespace orderedListOpenRule { + let tag_23: string; + export { tag_23 as tag }; + let leaf_23: boolean; + export { leaf_23 as leaf }; + let open_23: boolean; + export { open_23 as open }; + let close_23: boolean; + export { close_23 as close }; + export function enter_12(node: any, token: any, callback: any): void; + export { enter_12 as enter }; +} +declare namespace orderedListCloseRule { + let tag_24: string; + export { tag_24 as tag }; + let leaf_24: boolean; + export { leaf_24 as leaf }; + let open_24: boolean; + export { open_24 as open }; + let close_24: boolean; + export { close_24 as close }; +} +declare namespace listItemOpenRule { + let tag_25: string; + export { tag_25 as tag }; + let leaf_25: boolean; + export { leaf_25 as leaf }; + let open_25: boolean; + export { open_25 as open }; + let close_25: boolean; + export { close_25 as close }; + export function enter_13(node: any, token: any, callback: any): void; + export { enter_13 as enter }; +} +declare namespace listItemCloseRule { + let tag_26: string; + export { tag_26 as tag }; + let leaf_26: boolean; + export { leaf_26 as leaf }; + let open_26: boolean; + export { open_26 as open }; + let close_26: boolean; + export { close_26 as close }; +} +declare namespace tableOpenRule { + let tag_27: string; + export { tag_27 as tag }; + let leaf_27: boolean; + export { leaf_27 as leaf }; + let open_27: boolean; + export { open_27 as open }; + let close_27: boolean; + export { close_27 as close }; + export function enter_14(node: any, token: any, callback: any): void; + export { enter_14 as enter }; +} +declare namespace tableCloseRule { + let tag_28: string; + export { tag_28 as tag }; + let leaf_28: boolean; + export { leaf_28 as leaf }; + let open_28: boolean; + export { open_28 as open }; + let close_28: boolean; + export { close_28 as close }; +} +declare namespace tableHeadOpenRule { + let tag_29: string; + export { tag_29 as tag }; + let leaf_29: boolean; + export { leaf_29 as leaf }; + let open_29: boolean; + export { open_29 as open }; + let close_29: boolean; + export { close_29 as close }; + export function enter_15(node: any, token: any, callback: any): void; + export { enter_15 as enter }; +} +declare namespace tableHeadCloseRule { + let tag_30: string; + export { tag_30 as tag }; + let leaf_30: boolean; + export { leaf_30 as leaf }; + let open_30: boolean; + export { open_30 as open }; + let close_30: boolean; + export { close_30 as close }; +} +declare namespace tableBodyOpenRule { + let tag_31: string; + export { tag_31 as tag }; + let leaf_31: boolean; + export { leaf_31 as leaf }; + let open_31: boolean; + export { open_31 as open }; + let close_31: boolean; + export { close_31 as close }; + export function enter_16(node: any, token: any, callback: any): void; + export { enter_16 as enter }; +} +declare namespace tableBodyCloseRule { + let tag_32: string; + export { tag_32 as tag }; + let leaf_32: boolean; + export { leaf_32 as leaf }; + let open_32: boolean; + export { open_32 as open }; + let close_32: boolean; + export { close_32 as close }; +} +declare namespace tableRowOpenRule { + let tag_33: string; + export { tag_33 as tag }; + let leaf_33: boolean; + export { leaf_33 as leaf }; + let open_33: boolean; + export { open_33 as open }; + let close_33: boolean; + export { close_33 as close }; + export function enter_17(node: any, token: any, callback: any): void; + export { enter_17 as enter }; +} +declare namespace tableRowCloseRule { + let tag_34: string; + export { tag_34 as tag }; + let leaf_34: boolean; + export { leaf_34 as leaf }; + let open_34: boolean; + export { open_34 as open }; + let close_34: boolean; + export { close_34 as close }; +} +declare namespace headerCellOpenRule { + let tag_35: string; + export { tag_35 as tag }; + let leaf_35: boolean; + export { leaf_35 as leaf }; + let open_35: boolean; + export { open_35 as open }; + let close_35: boolean; + export { close_35 as close }; + export function enter_18(node: any, token: any, callback: any): void; + export { enter_18 as enter }; +} +declare namespace headerCellCloseRule { + let tag_36: string; + export { tag_36 as tag }; + let leaf_36: boolean; + export { leaf_36 as leaf }; + let open_36: boolean; + export { open_36 as open }; + let close_36: boolean; + export { close_36 as close }; +} +declare namespace tableCellOpenRule { + let tag_37: string; + export { tag_37 as tag }; + let leaf_37: boolean; + export { leaf_37 as leaf }; + let open_37: boolean; + export { open_37 as open }; + let close_37: boolean; + export { close_37 as close }; + export function enter_19(node: any, token: any, callback: any): void; + export { enter_19 as enter }; +} +declare namespace tableCellCloseRule { + let tag_38: string; + export { tag_38 as tag }; + let leaf_38: boolean; + export { leaf_38 as leaf }; + let open_38: boolean; + export { open_38 as open }; + let close_38: boolean; + export { close_38 as close }; +} +export namespace inlines { + export { textRule as text }; + export { codeInlineRule as code_inline }; + export { softbreakRule as softbreak }; + export { hardbreakRule as hardbreak }; + export { htmlInlineRule as html_inline }; + export { strongOpenRule as strong_open }; + export { strongCloseRule as strong_close }; + export { emphOpenRule as em_open }; + export { emphCloseRule as em_close }; + export { linkOpenRule as link_open }; + export { linkCloseRule as link_close }; + export { imageRule as image }; +} +export namespace blocks { + export { codeBlockRule as code_block }; + export { fenceRule as fence }; + export { htmlBlockRule as html_block }; + export { hrRule as hr }; + export { paragraphOpenRule as paragraph_open }; + export { paragraphCloseRule as paragraph_close }; + export { headingOpenRule as heading_open }; + export { headingCloseRule as heading_close }; + export { blockQuoteOpenRule as blockquote_open }; + export { blockQuoteCloseRule as blockquote_close }; + export { bulletListOpenRule as bullet_list_open }; + export { bulletListCloseRule as bullet_list_close }; + export { orderedListOpenRule as ordered_list_open }; + export { orderedListCloseRule as ordered_list_close }; + export { listItemOpenRule as list_item_open }; + export { listItemCloseRule as list_item_close }; + export { tableOpenRule as table_open }; + export { tableCloseRule as table_close }; + export { tableHeadOpenRule as thead_open }; + export { tableHeadCloseRule as thead_close }; + export { tableBodyOpenRule as tbody_open }; + export { tableBodyCloseRule as tbody_close }; + export { tableRowOpenRule as tr_open }; + export { tableRowCloseRule as tr_close }; + export { headerCellOpenRule as th_open }; + export { headerCellCloseRule as th_close }; + export { tableCellOpenRule as td_open }; + export { tableCellCloseRule as td_close }; +} +export {}; diff --git a/packages/markdown-html/package.json b/packages/markdown-html/package.json index 4d8da131..6f34a5b3 100644 --- a/packages/markdown-html/package.json +++ b/packages/markdown-html/package.json @@ -1,149 +1,153 @@ { - "name": "@accordproject/markdown-html", - "version": "0.16.25", - "description": "Transform CiceroDOM to HTML", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "browser": "umd/markdown-html.js", - "scripts": { - "webpack": "webpack --config webpack.config.js --mode production", - "build": "babel src -d lib --copy-files", - "build:dist": "NODE_ENV=production babel src -d lib --copy-files", - "build:watch": "babel src -d lib --copy-files --watch", - "prepublishOnly": "npm run build:dist && npm run webpack", - "prepare": "npm run build", - "pretest": "npm run lint && npm run build", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "jest --timeOut=10000 --silent", - "test:updateSnapshot": "jest --updateSnapshot --silent", - "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", - "jsdoc": "jsdoc -c jsdoc.json package.json", - "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-html" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform#readme", - "devDependencies": { - "@babel/cli": "7.25.9", - "@babel/core": "7.26.0", - "@babel/preset-env": "7.26.0", - "ajv": "^8.17.1", - "babel-loader": "^8.4.1", - "babel-plugin-istanbul": "7.0.0", - "browserify-zlib": "0.2.0", - "buffer": "^6.0.3", - "crypto-browserify": "3.12.1", - "eslint": "8.57.1", - "https-browserify": "1.0.0", - "jest": "^29.7.0", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6", - "raw-loader": "^4.0.2", - "stream-browserify": "3.0.0", - "stream-http": "3.2.0", - "tsd-jsdoc": "^2.5.0", - "vm-browserify": "^1.1.2", - "webpack": "5.96.1", - "webpack-cli": "5.1.4" - }, - "dependencies": { - "@accordproject/markdown-cicero": "*", - "@accordproject/markdown-common": "*", - "jsdom": "^25.0.1", - "type-of": "^2.0.1" - }, - "license-check-and-add-config": { - "folder": "./src", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "./lib", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-html", + "version": "0.16.25", + "description": "Transform CiceroDOM to HTML", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "browser": "umd/markdown-html.js", + "scripts": { + "webpack": "webpack --config webpack.config.js --mode production", + "build": "babel src -d lib --copy-files && npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "build:dist": "NODE_ENV=production babel src -d lib --copy-files", + "build:watch": "babel src -d lib --copy-files --watch", + "prepublishOnly": "npm run build:dist && npm run webpack", + "prepare": "npm run build", + "pretest": "npm run lint && npm run build", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "jest --timeOut=10000 --silent", + "test:updateSnapshot": "jest --updateSnapshot --silent", + "test:cov": "npm run lint && jest --timeOut=10000 --coverage --silent", + "jsdoc": "jsdoc -c jsdoc.json package.json", + "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-html" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform#readme", + "devDependencies": { + "@babel/cli": "7.25.9", + "@babel/core": "7.26.0", + "@babel/preset-env": "7.26.0", + "ajv": "^8.17.1", + "babel-loader": "^8.4.1", + "babel-plugin-istanbul": "7.0.0", + "browserify-zlib": "0.2.0", + "buffer": "^6.0.3", + "crypto-browserify": "3.12.1", + "eslint": "8.57.1", + "https-browserify": "1.0.0", + "jest": "^29.7.0", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "raw-loader": "^4.0.2", + "stream-browserify": "3.0.0", + "stream-http": "3.2.0", + "tsd-jsdoc": "^2.5.0", + "vm-browserify": "^1.1.2", + "webpack": "5.96.1", + "webpack-cli": "5.1.4", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/markdown-cicero": "*", + "@accordproject/markdown-common": "*", + "jsdom": "^25.0.1", + "type-of": "^2.0.1" + }, + "license-check-and-add-config": { + "folder": "./src", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "./lib", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text", + "text-summary", + "html", + "json" + ], + "include": [ + "src/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 88, + "branches": 76, + "functions": 84, + "lines": 88 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text", - "text-summary", - "html", - "json" - ], - "include": [ - "src/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 88, - "branches": 76, - "functions": 84, - "lines": 88 - } } diff --git a/packages/markdown-html/types/index.d.ts b/packages/markdown-html/types/index.d.ts new file mode 100644 index 00000000..c7fd65c9 --- /dev/null +++ b/packages/markdown-html/types/index.d.ts @@ -0,0 +1,2 @@ +export const HtmlTransformer: typeof import("./lib/HtmlTransformer"); +export const ToHtmlStringVisitor: typeof import("./lib/ToHtmlStringVisitor"); diff --git a/packages/markdown-html/types/lib/HtmlTransformer.d.ts b/packages/markdown-html/types/lib/HtmlTransformer.d.ts new file mode 100644 index 00000000..49e4c0a1 --- /dev/null +++ b/packages/markdown-html/types/lib/HtmlTransformer.d.ts @@ -0,0 +1,25 @@ +export = HtmlTransformer; +/** + * Converts a CiceroMark or CommonMark DOM to HTML + */ +declare class HtmlTransformer { + /** + * Construct the parser. + * @param {object} [options] configuration options + */ + constructor(...args: any[]); + options: any; + ciceroMarkTransformer: import("@accordproject/markdown-cicero/types/lib/CiceroMarkTransformer"); + /** + * Converts a CiceroMark DOM to an html string + * @param {*} input - CiceroMark DOM object + * @returns {string} the html string + */ + toHtml(input: any): string; + /** + * Converts an html string to a CiceroMark DOM + * @param {string} input - html string + * @returns {*} CiceroMark DOM + */ + toCiceroMark(input: string): any; +} diff --git a/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts b/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts new file mode 100644 index 00000000..5677284a --- /dev/null +++ b/packages/markdown-html/types/lib/ToCiceroMarkVisitor.d.ts @@ -0,0 +1,45 @@ +export = ToCiceroMarkVisitor; +/** + * Converts an html string to a CiceroMark DOM + * + */ +declare class ToCiceroMarkVisitor { + /** + * Construct the parser. + * @param {object} [options] configuration options + */ + constructor(...args: any[]); + options: any; + rules: any[]; + /** + * Filter out cruft newline nodes inserted by the DOM parser. + * + * @param {Object} element DOM element + * @return {Boolean} true if node is not a new line + */ + cruftNewline(element: any): boolean; + /** + * Deserialize a DOM element. + * + * @param {Object} element DOM element + * @param {boolean} ignoreSpace override + * @return {Any} node + */ + deserializeElement(element: any, ignoreSpace: boolean): Any; + /** + * Deserialize an array of DOM elements. + * + * @param {Array} elements DOM elements + * @param {boolean} ignoreSpace override + * @return {Array} array of nodes + */ + deserializeElements(...args: any[]): any[]; + /** + * Converts an html string to a CiceroMark DOM + * @param {string} input - html string + * @param {string} [format] result format, defaults to 'concerto'. Pass + * 'json' to return the JSON data. + * @returns {*} CiceroMark DOM + */ + toCiceroMark(input: string, ...args: any[]): any; +} diff --git a/packages/markdown-html/types/lib/ToHtmlStringVisitor.d.ts b/packages/markdown-html/types/lib/ToHtmlStringVisitor.d.ts new file mode 100644 index 00000000..fa7524bd --- /dev/null +++ b/packages/markdown-html/types/lib/ToHtmlStringVisitor.d.ts @@ -0,0 +1,23 @@ +export = ToHtmlStringVisitor; +declare class ToHtmlStringVisitor { + /** + * Visits a sub-tree and return the html + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + * @returns {string} the html for the sub tree + */ + static visitChildren(visitor: any, thing: any, parameters?: any): string; + /** + * Construct the visitor + * @param {*} [options] configuration options + */ + constructor(options?: any); + options: any; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + */ + visit(thing: any, parameters: any): void; +} diff --git a/packages/markdown-html/types/lib/helpers.d.ts b/packages/markdown-html/types/lib/helpers.d.ts new file mode 100644 index 00000000..063de283 --- /dev/null +++ b/packages/markdown-html/types/lib/helpers.d.ts @@ -0,0 +1,12 @@ +export function isAllWhitespace(node: any): boolean; +/** + * Determine if a node should be ignored by the iterator functions. + * + * @param {object} node An object implementing the DOM1 |Node| interface. + * @param {boolean} ignoreSpace override + * @return {boolean} true if the node is: + * 1) A |Text| node that is all whitespace + * 2) A |Comment| node + * and otherwise false. + */ +export function isIgnorable(node: object, ignoreSpace: boolean): boolean; diff --git a/packages/markdown-html/types/lib/rules.d.ts b/packages/markdown-html/types/lib/rules.d.ts new file mode 100644 index 00000000..3e9de56b --- /dev/null +++ b/packages/markdown-html/types/lib/rules.d.ts @@ -0,0 +1,2 @@ +export = rules; +declare var rules: any[]; diff --git a/packages/markdown-it-cicero/package.json b/packages/markdown-it-cicero/package.json index 39d5a2bd..2c0495b0 100644 --- a/packages/markdown-it-cicero/package.json +++ b/packages/markdown-it-cicero/package.json @@ -1,125 +1,130 @@ { - "name": "@accordproject/markdown-it-cicero", - "version": "0.16.25", - "description": "Plugin to introduce cicero blocks and inlines for the markdown-it markdown parser", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "scripts": { - "pretest": "npm run lint", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "mocha", - "test:cov": "npm run lint && nyc mocha", - "jsdoc": "jsdoc -c jsdoc.json package.json" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-it-cicero" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "markdown-it-plugin", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform", - "devDependencies": { - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-string": "^1.5.0", - "chai-things": "0.2.0", - "eslint": "8.57.1", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "nyc": "17.1.0" - }, - "dependencies": { - "markdown-it": "^14.1.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-it-cicero", + "version": "0.16.25", + "description": "Plugin to introduce cicero blocks and inlines for the markdown-it markdown parser", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "scripts": { + "build": "npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "mocha", + "test:cov": "npm run lint && nyc mocha", + "jsdoc": "jsdoc -c jsdoc.json package.json" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-it-cicero" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "markdown-it-plugin", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform", + "devDependencies": { + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-string": "^1.5.0", + "chai-things": "0.2.0", + "eslint": "8.57.1", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "mocha": "10.8.2", + "nyc": "17.1.0", + "typescript": "5.7.2" + }, + "dependencies": { + "markdown-it": "^14.1.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 87, + "branches": 76, + "functions": 84, + "lines": 87 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 87, - "branches": 76, - "functions": 84, - "lines": 87 - } } diff --git a/packages/markdown-it-cicero/types/index.d.ts b/packages/markdown-it-cicero/types/index.d.ts new file mode 100644 index 00000000..02bbffd9 --- /dev/null +++ b/packages/markdown-it-cicero/types/index.d.ts @@ -0,0 +1,2 @@ +declare const _exports: typeof import("./lib"); +export = _exports; diff --git a/packages/markdown-it-cicero/types/lib/cicero_block.d.ts b/packages/markdown-it-cicero/types/lib/cicero_block.d.ts new file mode 100644 index 00000000..b6453b44 --- /dev/null +++ b/packages/markdown-it-cicero/types/lib/cicero_block.d.ts @@ -0,0 +1,2 @@ +export = cicero_block; +declare function cicero_block(state: any, startLine: any, endLine: any, silent: any): boolean; diff --git a/packages/markdown-it-cicero/types/lib/cicero_block_render.d.ts b/packages/markdown-it-cicero/types/lib/cicero_block_render.d.ts new file mode 100644 index 00000000..f8353da0 --- /dev/null +++ b/packages/markdown-it-cicero/types/lib/cicero_block_render.d.ts @@ -0,0 +1,2 @@ +export = cicero_block_render; +declare function cicero_block_render(name: any): (tokens: any, idx: any, _options: any, env: any, slf: any) => any; diff --git a/packages/markdown-it-cicero/types/lib/cicero_inline.d.ts b/packages/markdown-it-cicero/types/lib/cicero_inline.d.ts new file mode 100644 index 00000000..dcc1bd77 --- /dev/null +++ b/packages/markdown-it-cicero/types/lib/cicero_inline.d.ts @@ -0,0 +1,2 @@ +export = cicero_inline; +declare function cicero_inline(state: any, silent: any): boolean; diff --git a/packages/markdown-it-cicero/types/lib/cicero_re.d.ts b/packages/markdown-it-cicero/types/lib/cicero_re.d.ts new file mode 100644 index 00000000..45bc224b --- /dev/null +++ b/packages/markdown-it-cicero/types/lib/cicero_re.d.ts @@ -0,0 +1,25 @@ +export const VARIABLE_RE: RegExp; +export const OPEN_BLOCK_RE: RegExp; +export const CLOSE_BLOCK_RE: RegExp; +export const FORMULA_RE: RegExp; +/** + * Match opening blocks + * @param {string} text - the text + * @param {Array} stack - the block stack + * @return {*} open tag + */ +export function matchOpenBlock(text: string, stack: Array): any; +/** + * Match closing blocks + * @param {string} text - the text + * @param {string} block_open - the opening block name + * @param {Array} stack - the block stack + * @return {*} close tag + */ +export function matchCloseBlock(text: string, block_open: string, stack: Array): any; +/** + * Extract attributes from opening blocks + * @param {string[]} match + * @return {*[]} attributes + */ +export function getBlockAttributes(match: string[]): any[]; diff --git a/packages/markdown-it-cicero/types/lib/index.d.ts b/packages/markdown-it-cicero/types/lib/index.d.ts new file mode 100644 index 00000000..fb209288 --- /dev/null +++ b/packages/markdown-it-cicero/types/lib/index.d.ts @@ -0,0 +1,2 @@ +export = cicero_plugin; +declare function cicero_plugin(md: any): void; diff --git a/packages/markdown-it-template/package.json b/packages/markdown-it-template/package.json index 1f2887c0..1e38195f 100644 --- a/packages/markdown-it-template/package.json +++ b/packages/markdown-it-template/package.json @@ -1,125 +1,130 @@ { - "name": "@accordproject/markdown-it-template", - "version": "0.16.25", - "description": "Plugin to introduce template blocks and inlines for the markdown-it markdown parser", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "scripts": { - "pretest": "npm run lint", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "mocha", - "test:cov": "npm run lint && nyc mocha", - "jsdoc": "jsdoc -c jsdoc.json package.json" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-it-template" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "markdown-it-plugin", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform", - "devDependencies": { - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-string": "^1.5.0", - "chai-things": "0.2.0", - "eslint": "8.57.1", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "nyc": "17.1.0" - }, - "dependencies": { - "markdown-it": "^14.1.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-it-template", + "version": "0.16.25", + "description": "Plugin to introduce template blocks and inlines for the markdown-it markdown parser", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "scripts": { + "build": "npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "pretest": "npm run lint", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "mocha", + "test:cov": "npm run lint && nyc mocha", + "jsdoc": "jsdoc -c jsdoc.json package.json" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-it-template" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "markdown-it-plugin", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform", + "devDependencies": { + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-string": "^1.5.0", + "chai-things": "0.2.0", + "eslint": "8.57.1", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "mocha": "10.8.2", + "nyc": "17.1.0", + "typescript": "5.7.2" + }, + "dependencies": { + "markdown-it": "^14.1.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 87, + "branches": 76, + "functions": 84, + "lines": 87 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 87, - "branches": 76, - "functions": 84, - "lines": 87 - } } diff --git a/packages/markdown-it-template/types/index.d.ts b/packages/markdown-it-template/types/index.d.ts new file mode 100644 index 00000000..02bbffd9 --- /dev/null +++ b/packages/markdown-it-template/types/index.d.ts @@ -0,0 +1,2 @@ +declare const _exports: typeof import("./lib"); +export = _exports; diff --git a/packages/markdown-it-template/types/lib/index.d.ts b/packages/markdown-it-template/types/lib/index.d.ts new file mode 100644 index 00000000..d1883ed4 --- /dev/null +++ b/packages/markdown-it-template/types/lib/index.d.ts @@ -0,0 +1,2 @@ +export = template_plugin; +declare function template_plugin(md: any): void; diff --git a/packages/markdown-it-template/types/lib/template_block.d.ts b/packages/markdown-it-template/types/lib/template_block.d.ts new file mode 100644 index 00000000..1430ebd9 --- /dev/null +++ b/packages/markdown-it-template/types/lib/template_block.d.ts @@ -0,0 +1,2 @@ +export = template_block; +declare function template_block(state: any, startLine: any, endLine: any, silent: any): boolean; diff --git a/packages/markdown-it-template/types/lib/template_block_render.d.ts b/packages/markdown-it-template/types/lib/template_block_render.d.ts new file mode 100644 index 00000000..8f9c0ef2 --- /dev/null +++ b/packages/markdown-it-template/types/lib/template_block_render.d.ts @@ -0,0 +1,2 @@ +export = template_block_render; +declare function template_block_render(name: any): (tokens: any, idx: any, _options: any, env: any, slf: any) => any; diff --git a/packages/markdown-it-template/types/lib/template_inline.d.ts b/packages/markdown-it-template/types/lib/template_inline.d.ts new file mode 100644 index 00000000..de64b387 --- /dev/null +++ b/packages/markdown-it-template/types/lib/template_inline.d.ts @@ -0,0 +1,2 @@ +export = template_inline; +declare function template_inline(state: any, silent: any): boolean; diff --git a/packages/markdown-it-template/types/lib/template_inline_render.d.ts b/packages/markdown-it-template/types/lib/template_inline_render.d.ts new file mode 100644 index 00000000..2634af48 --- /dev/null +++ b/packages/markdown-it-template/types/lib/template_inline_render.d.ts @@ -0,0 +1,2 @@ +export = template_inline_render; +declare function template_inline_render(name: any): (tokens: any, idx: any, _options: any, env: any, slf: any) => any; diff --git a/packages/markdown-it-template/types/lib/template_re.d.ts b/packages/markdown-it-template/types/lib/template_re.d.ts new file mode 100644 index 00000000..bad332f8 --- /dev/null +++ b/packages/markdown-it-template/types/lib/template_re.d.ts @@ -0,0 +1,25 @@ +export const VARIABLE_RE: RegExp; +export const OPEN_BLOCK_RE: RegExp; +export const CLOSE_BLOCK_RE: RegExp; +export const FORMULA_RE: RegExp; +/** + * Match opening blocks + * @param {string} text - the text + * @param {Array} stack - the block stack + * @return {*} open tag + */ +export function matchOpenBlock(text: string, stack: Array): any; +/** + * Match closing blocks + * @param {string} text - the text + * @param {string} block_open - the opening block name + * @param {Array} stack - the block stack + * @return {*} close tag + */ +export function matchCloseBlock(text: string, block_open: string, stack: Array): any; +/** + * Extract attributes from opening blocks + * @param {string[]} match the block data + * @return {*[]} attributes + */ +export function getBlockAttributes(match: string[]): any[]; diff --git a/packages/markdown-template/lib/templatemarkutil.js b/packages/markdown-template/lib/templatemarkutil.js index e3096652..f8d01e4e 100644 --- a/packages/markdown-template/lib/templatemarkutil.js +++ b/packages/markdown-template/lib/templatemarkutil.js @@ -72,7 +72,7 @@ var templateMarkManager = mkTemplateMarkManager(); * @param {string} templateKind - either 'clause' or 'contract' * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept * @throws {Error} if no template model is found, or multiple template models are found - * @returns {ClassDeclaration} the concept for the template + * @returns {object} the concept for the template */ function findTemplateConcept(introspector, templateKind, conceptFullyQualifiedName) { if (conceptFullyQualifiedName) { @@ -96,7 +96,7 @@ function findTemplateConcept(introspector, templateKind, conceptFullyQualifiedNa * @param {object} introspector - the model introspector for this template * @param {string} elementType - the element type * @throws {Error} if no template model is found, or multiple template models are found - * @returns {ClassDeclaration} the template model for the template + * @returns {object} the template model for the template */ function findElementModel(introspector, elementType) { return introspector.getClassDeclaration(elementType); diff --git a/packages/markdown-template/package.json b/packages/markdown-template/package.json index 0fbe2870..4326a244 100644 --- a/packages/markdown-template/package.json +++ b/packages/markdown-template/package.json @@ -1,149 +1,153 @@ { - "name": "@accordproject/markdown-template", - "version": "0.16.25", - "description": "A framework for transforming markdown", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "browser": "umd/markdown-template.js", - "scripts": { - "webpack": "webpack --config webpack.config.js --mode production", - "build": "babel src -d lib --copy-files", - "build:dist": "NODE_ENV=production babel src -d lib --copy-files", - "build:watch": "babel src -d lib --copy-files --watch", - "prepublishOnly": "npm run build:dist && npm run webpack", - "prepare": "npm run build", - "pretest": "npm run lint && npm run build", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "mocha --timeout 30000", - "test:cov": "npm run lint && nyc mocha --timeout 30000", - "jsdoc": "jsdoc -c jsdoc.json package.json", - "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-template" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "homepage": "https://github.com/accordproject/markdown-transform", - "devDependencies": { - "@babel/cli": "7.25.9", - "@babel/core": "7.26.0", - "@babel/preset-env": "7.26.0", - "babel-loader": "9.2.1", - "babel-plugin-istanbul": "7.0.0", - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-string": "^1.5.0", - "chai-things": "0.2.0", - "crypto-browserify": "3.12.1", - "eslint": "8.57.1", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "nyc": "17.1.0", - "raw-loader": "^4.0.2", - "stream-browserify": "3.0.0", - "tsd-jsdoc": "^2.5.0", - "webpack": "5.96.1", - "webpack-cli": "5.1.4" - }, - "dependencies": { - "@accordproject/concerto-core": "3.25.7", - "@accordproject/concerto-cto": "3.25.7", - "@accordproject/markdown-cicero": "*", - "@accordproject/markdown-common": "*", - "@accordproject/markdown-it-template": "*", - "dayjs": "1.11.13", - "markdown-it": "^14.1.0" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-template", + "version": "0.16.25", + "description": "A framework for transforming markdown", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "browser": "umd/markdown-template.js", + "scripts": { + "webpack": "webpack --config webpack.config.js --mode production", + "build": "babel src -d lib --copy-files && npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "build:dist": "NODE_ENV=production babel src -d lib --copy-files", + "build:watch": "babel src -d lib --copy-files --watch", + "prepublishOnly": "npm run build:dist && npm run webpack", + "prepare": "npm run build", + "pretest": "npm run lint && npm run build", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "mocha --timeout 30000", + "test:cov": "npm run lint && nyc mocha --timeout 30000", + "jsdoc": "jsdoc -c jsdoc.json package.json", + "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-template" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "homepage": "https://github.com/accordproject/markdown-transform", + "devDependencies": { + "@babel/cli": "7.25.9", + "@babel/core": "7.26.0", + "@babel/preset-env": "7.26.0", + "babel-loader": "9.2.1", + "babel-plugin-istanbul": "7.0.0", + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-string": "^1.5.0", + "chai-things": "0.2.0", + "crypto-browserify": "3.12.1", + "eslint": "8.57.1", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "mocha": "10.8.2", + "nyc": "17.1.0", + "raw-loader": "^4.0.2", + "stream-browserify": "3.0.0", + "tsd-jsdoc": "^2.5.0", + "webpack": "5.96.1", + "webpack-cli": "5.1.4", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/concerto-core": "3.25.7", + "@accordproject/concerto-cto": "3.25.7", + "@accordproject/markdown-cicero": "*", + "@accordproject/markdown-common": "*", + "@accordproject/markdown-it-template": "*", + "dayjs": "1.11.13", + "markdown-it": "^14.1.0" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": false, + "statements": 87, + "branches": 76, + "functions": 84, + "lines": 87 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": false, - "statements": 87, - "branches": 76, - "functions": 84, - "lines": 87 - } } diff --git a/packages/markdown-template/src/templatemarkutil.js b/packages/markdown-template/src/templatemarkutil.js index 8d42a245..6d6754d2 100644 --- a/packages/markdown-template/src/templatemarkutil.js +++ b/packages/markdown-template/src/templatemarkutil.js @@ -59,7 +59,7 @@ const templateMarkManager = mkTemplateMarkManager(); * @param {string} templateKind - either 'clause' or 'contract' * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept * @throws {Error} if no template model is found, or multiple template models are found - * @returns {ClassDeclaration} the concept for the template + * @returns {object} the concept for the template */ function findTemplateConcept(introspector, templateKind, conceptFullyQualifiedName) { if(conceptFullyQualifiedName) { @@ -84,7 +84,7 @@ function findTemplateConcept(introspector, templateKind, conceptFullyQualifiedNa * @param {object} introspector - the model introspector for this template * @param {string} elementType - the element type * @throws {Error} if no template model is found, or multiple template models are found - * @returns {ClassDeclaration} the template model for the template + * @returns {object} the template model for the template */ function findElementModel(introspector, elementType) { return introspector.getClassDeclaration(elementType); diff --git a/packages/markdown-template/types/index.d.ts b/packages/markdown-template/types/index.d.ts new file mode 100644 index 00000000..1434af5a --- /dev/null +++ b/packages/markdown-template/types/index.d.ts @@ -0,0 +1,6 @@ +export const util: typeof import("./lib/util"); +export const templatemarkutil: typeof import("./lib/templatemarkutil"); +export const datetimeutil: typeof import("./lib/datetimeutil"); +export const normalizeNLs: typeof import("./lib/normalize").normalizeNLs; +export const TemplateException: typeof import("./lib/templateexception"); +export const TemplateMarkTransformer: typeof import("./lib/TemplateMarkTransformer"); diff --git a/packages/markdown-template/types/lib/FormulaVisitor.d.ts b/packages/markdown-template/types/lib/FormulaVisitor.d.ts new file mode 100644 index 00000000..64e1cb65 --- /dev/null +++ b/packages/markdown-template/types/lib/FormulaVisitor.d.ts @@ -0,0 +1,55 @@ +export = FormulaVisitor; +/** + * Converts a CommonMark DOM to a CiceroMark DOM + */ +declare class FormulaVisitor { + /** + * Visits a sub-tree and return CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + * @param {string} field where the children are + */ + static visitChildren(visitor: any, thing: any, parameters?: any, ...args: any[]): void; + /** + * Visits a list of nodes and return the CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} things the list node to visit + * @param {*} [parameters] optional parameters + */ + static visitNodes(visitor: any, things: any, parameters?: any): void; + /** + * Calculates the dependencies for TS code + * @param {string} tsCode the TS code to analyze + * @returns {string[]} array of dependencies + */ + static calculateDependencies(tsCode: string): string[]; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + */ + visit(thing: any, parameters: any): void; + /** + * Calculate dependencies + * @param {*} serializer - the template mark serializer + * @param {object} ast - the template AST + * @param {object} options - options + * @param {number} [options.utcOffset] - UTC Offset for this execution + * @returns {*} the formulas + */ + calculateDependencies(serializer: any, ast: object, options: { + utcOffset?: number; + }): any; + /** + * Process formulas and returns the list of those formulas from a TemplateMark DOM + * @param {*} serializer - the template mark serializer + * @param {object} ast - the template AST + * @param {object} options - options + * @param {number} [options.utcOffset] - UTC Offset for this execution + * @returns {*} the formulas + */ + processFormulas(serializer: any, ast: object, options: { + utcOffset?: number; + }): any; +} diff --git a/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts b/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts new file mode 100644 index 00000000..6f7ade3c --- /dev/null +++ b/packages/markdown-template/types/lib/TemplateMarkTransformer.d.ts @@ -0,0 +1,52 @@ +export = TemplateMarkTransformer; +/** + * Support for TemplateMark Templates + */ +declare class TemplateMarkTransformer { + /** + * Converts a template string to a token stream + * @param {object} templateInput the template template + * @returns {object} the token stream + */ + toTokens(templateInput: object): object; + /** + * Converts a template token strean string to a TemplateMark DOM + * @param {object} tokenStream the template token stream + * @param {object} modelManager - the model manager for this template + * @param {string} templateKind - either 'clause' or 'contract' + * @param {object} [options] configuration options + * @param {boolean} [options.verbose] verbose output + * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept + * @returns {object} the result of parsing + */ + tokensToMarkdownTemplate(tokenStream: object, modelManager: object, templateKind: string, options?: { + verbose?: boolean; + }, conceptFullyQualifiedName?: string): object; + /** + * Converts a markdown string to a TemplateMark DOM + * @param {{fileName:string,content:string}} templateInput the template template + * @param {object} modelManager - the model manager for this template + * @param {string} templateKind - either 'clause' or 'contract' + * @param {object} [options] configuration options + * @param {boolean} [options.verbose] verbose output + * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept + * @returns {object} the result of parsing + */ + fromMarkdownTemplate(templateInput: { + fileName: string; + content: string; + }, modelManager: object, templateKind: string, options?: { + verbose?: boolean; + }, conceptFullyQualifiedName?: string): object; + /** + * Converts a TemplateMark DOM to a template markdown string + * @param {object} input TemplateMark DOM + * @returns {string} the template markdown text + */ + toMarkdownTemplate(input: object): string; + /** + * Get TemplateMark serializer + * @return {*} templatemark serializer + */ + getSerializer(): any; +} diff --git a/packages/markdown-template/types/lib/ToMarkdownTemplateVisitor.d.ts b/packages/markdown-template/types/lib/ToMarkdownTemplateVisitor.d.ts new file mode 100644 index 00000000..4187a9c7 --- /dev/null +++ b/packages/markdown-template/types/lib/ToMarkdownTemplateVisitor.d.ts @@ -0,0 +1,21 @@ +export = ToMarkdownTemplateVisitor; +declare const ToMarkdownTemplateVisitor_base: typeof import("@accordproject/markdown-common/types/lib/FromCommonMarkVisitor"); +/** + * Converts a TemplateMark DOM to a template markdown string. + */ +declare class ToMarkdownTemplateVisitor extends ToMarkdownTemplateVisitor_base { + /** + * Construct the visitor. + * @param {object} [options] configuration options + * @param {*} resultSeq how to sequentially combine results + * @param {object} rules how to process each node type + */ + constructor(options?: object); + /** + * Converts a TemplateMark DOM to a template markdown string. + * @param {*} serializer - TemplateMark serializer + * @param {*} input - TemplateMark DOM (JSON) + * @returns {string} the template markdown string + */ + toMarkdownTemplate(serializer: any, input: any): string; +} diff --git a/packages/markdown-template/types/lib/TypeVisitor.d.ts b/packages/markdown-template/types/lib/TypeVisitor.d.ts new file mode 100644 index 00000000..a9b80f6b --- /dev/null +++ b/packages/markdown-template/types/lib/TypeVisitor.d.ts @@ -0,0 +1,38 @@ +export = TypeVisitor; +/** + * Adds the elementType property to a TemplateMark DOM + * along with type specific metadata. This visitor verifies + * the structure of a template with respect to an associated + * template model and annotates the TemplateMark DOM with model + * information for use in downstream tools. + */ +declare class TypeVisitor { + /** + * Visits a sub-tree and return CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} thing the node to visit + * @param {*} [parameters] optional parameters + * @param {string} field where the children are + */ + static visitChildren(visitor: any, thing: any, parameters?: any, ...args: any[]): void; + /** + * Visits a list of nodes and return the CiceroMark DOM + * @param {*} visitor the visitor to use + * @param {*} things the list node to visit + * @param {*} [parameters] optional parameters + */ + static visitNodes(visitor: any, things: any, parameters?: any): void; + /** + * Get the type information for a property + * @param {*} property the propety + * @param {*} parameters the configuration parameters + * @returns {*} the information about the next model element (property or declaration) + */ + static nextModel(property: any, parameters: any): any; + /** + * Visit a node + * @param {*} thing the object being visited + * @param {*} parameters the parameters + */ + visit(thing: any, parameters: any): void; +} diff --git a/packages/markdown-template/types/lib/datetimeutil.d.ts b/packages/markdown-template/types/lib/datetimeutil.d.ts new file mode 100644 index 00000000..fa8edb2b --- /dev/null +++ b/packages/markdown-template/types/lib/datetimeutil.d.ts @@ -0,0 +1,7 @@ +/** + * Ensures there is a proper current time + * + * @param {string} currentTime - the definition of 'now' + * @returns {object} if valid, the dayjs object for the current time + */ +export function setCurrentTime(currentTime: string): object; diff --git a/packages/markdown-template/types/lib/errorutil.d.ts b/packages/markdown-template/types/lib/errorutil.d.ts new file mode 100644 index 00000000..33b5cf18 --- /dev/null +++ b/packages/markdown-template/types/lib/errorutil.d.ts @@ -0,0 +1,7 @@ +/** + * Throw a template exception for the element + * @param {string} message - the error message + * @param {object} element the AST + * @throws {TemplateException} + */ +export function _throwTemplateExceptionForElement(message: string, element: object): void; diff --git a/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts b/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts new file mode 100644 index 00000000..315d5e70 --- /dev/null +++ b/packages/markdown-template/types/lib/fromtemplatemarkrules.d.ts @@ -0,0 +1,10 @@ +export function VariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function FormattedVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function EnumVariableDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function FormulaDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function ConditionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function OptionalDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function WithDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function JoinDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function ListBlockDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; +export function ClauseDefinition(visitor: any, thing: any, children: any, parameters: any, resultString: any, resultSeq: any): void; diff --git a/packages/markdown-template/types/lib/normalize.d.ts b/packages/markdown-template/types/lib/normalize.d.ts new file mode 100644 index 00000000..f0afdbaf --- /dev/null +++ b/packages/markdown-template/types/lib/normalize.d.ts @@ -0,0 +1,18 @@ +/** + * Prepare the text for parsing (normalizes new lines, etc) + * @param {string} input - the text + * @return {string} - the normalized text + */ +export function normalizeNLs(input: string): string; +/** + * Normalize to markdown cicero text + * @param {*} input - the CiceroMark DOM + * @return {string} - the normalized markdown cicero text + */ +export function normalizeToMarkdownCicero(input: any): string; +/** + * Normalize from markdown cicero text + * @param {string} input - the markdown cicero text + * @return {object} - the normalized CiceroMark DOM + */ +export function normalizeFromMarkdownCicero(input: string): object; diff --git a/packages/markdown-template/types/lib/templateexception.d.ts b/packages/markdown-template/types/lib/templateexception.d.ts new file mode 100644 index 00000000..a3008454 --- /dev/null +++ b/packages/markdown-template/types/lib/templateexception.d.ts @@ -0,0 +1,20 @@ +export = TemplateException; +/** + * Exception thrown for invalid templates + * @extends BaseFileException + * @see See {@link BaseFileException} + * @class + * @memberof module:markdown-template + * @private + */ +declare class TemplateException { + /** + * Create a TemplateException + * @param {string} message - the message for the exception + * @param {string} fileLocation - the optional file location associated with the exception + * @param {string} fileName - the optional file name associated with the exception + * @param {string} fullMessageOverride - the optional pre-existing full message + * @param {string} component - the optional component which throws this error + */ + constructor(message: string, fileLocation: string, fileName: string, fullMessageOverride: string, component: string); +} diff --git a/packages/markdown-template/types/lib/templatemarkutil.d.ts b/packages/markdown-template/types/lib/templatemarkutil.d.ts new file mode 100644 index 00000000..c5f392e1 --- /dev/null +++ b/packages/markdown-template/types/lib/templatemarkutil.d.ts @@ -0,0 +1,47 @@ +/** + * Returns the concept for the template + * @param {object} introspector - the model introspector for this template + * @param {string} templateKind - either 'clause' or 'contract' + * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept + * @throws {Error} if no template model is found, or multiple template models are found + * @returns {object} the concept for the template + */ +export function findTemplateConcept(introspector: object, templateKind: string, conceptFullyQualifiedName?: string): object; +export var templateMarkManager: any; +/** + * Converts a templatemark string to a token stream + * @param {object} input the templatemark string + * @returns {object} the token stream + */ +export function templateToTokens(input: object): object; +/** + * Converts a template token strean string to an untyped TemplateMark DOM + * @param {object} tokenStream the template token stream + * @param {string} templateKind - either 'clause' or 'contract' + * @returns {object} the TemplateMark DOM + */ +export function tokensToUntypedTemplateMarkFragment(tokenStream: object): object; +/** + * Converts a template token strean string to an untyped TemplateMark DOM + * @param {object} tokenStream the template token stream + * @param {string} templateKind - either 'clause' or 'contract' + * @returns {object} the TemplateMark DOM + */ +export function tokensToUntypedTemplateMark(tokenStream: object, templateKind: string): object; +/** + * Decorate TemplateMark DOM with its types + * @param {object} template the TemplateMark DOM + * @param {object} modelManager - the modelManager for this template + * @param {string} templateKind - either 'clause' or 'contract' + * @param {string} [conceptFullyQualifiedName] - the fully qualified name of the template concept + * @returns {object} the typed TemplateMark DOM + */ +export function templateMarkTyping(template: object, modelManager: object, templateKind: string, conceptFullyQualifiedName?: string): object; +/** + * Decorate TemplateMark DOM with its types + * @param {object} template the TemplateMark DOM + * @param {object} modelManager - the modelManager for this template + * @param {string} elementType - the element type + * @returns {object} the typed TemplateMark DOM + */ +export function templateMarkTypingFromType(template: object, modelManager: object, elementType: string): object; diff --git a/packages/markdown-template/types/lib/templaterules.d.ts b/packages/markdown-template/types/lib/templaterules.d.ts new file mode 100644 index 00000000..5254c923 --- /dev/null +++ b/packages/markdown-template/types/lib/templaterules.d.ts @@ -0,0 +1,242 @@ +declare namespace variableRule { + let tag: string; + let leaf: boolean; + let open: boolean; + let close: boolean; + function enter(node: any, token: any, callback: any): void; + let skipEmpty: boolean; +} +declare namespace thisRule { + let tag_1: string; + export { tag_1 as tag }; + let leaf_1: boolean; + export { leaf_1 as leaf }; + let open_1: boolean; + export { open_1 as open }; + let close_1: boolean; + export { close_1 as close }; + export function enter_1(node: any, token: any, callback: any): void; + export { enter_1 as enter }; + let skipEmpty_1: boolean; + export { skipEmpty_1 as skipEmpty }; +} +declare namespace formulaRule { + let tag_2: string; + export { tag_2 as tag }; + let leaf_2: boolean; + export { leaf_2 as leaf }; + let open_2: boolean; + export { open_2 as open }; + let close_2: boolean; + export { close_2 as close }; + export function enter_2(node: any, token: any, callback: any): void; + export { enter_2 as enter }; + let skipEmpty_2: boolean; + export { skipEmpty_2 as skipEmpty }; +} +declare namespace ifOpenRule { + let tag_3: string; + export { tag_3 as tag }; + let leaf_3: boolean; + export { leaf_3 as leaf }; + let open_3: boolean; + export { open_3 as open }; + let close_3: boolean; + export { close_3 as close }; + export function enter_3(node: any, token: any, callback: any): void; + export { enter_3 as enter }; + let skipEmpty_3: boolean; + export { skipEmpty_3 as skipEmpty }; +} +declare namespace ifCloseRule { + let tag_4: string; + export { tag_4 as tag }; + let leaf_4: boolean; + export { leaf_4 as leaf }; + let open_4: boolean; + export { open_4 as open }; + let close_4: boolean; + export { close_4 as close }; + export function exit(node: any, token: any, callback: any): void; + let skipEmpty_4: boolean; + export { skipEmpty_4 as skipEmpty }; +} +declare namespace optionalOpenRule { + let tag_5: string; + export { tag_5 as tag }; + let leaf_5: boolean; + export { leaf_5 as leaf }; + let open_5: boolean; + export { open_5 as open }; + let close_5: boolean; + export { close_5 as close }; + export function enter_4(node: any, token: any, callback: any): void; + export { enter_4 as enter }; + let skipEmpty_5: boolean; + export { skipEmpty_5 as skipEmpty }; +} +declare namespace optionalCloseRule { + let tag_6: string; + export { tag_6 as tag }; + let leaf_6: boolean; + export { leaf_6 as leaf }; + let open_6: boolean; + export { open_6 as open }; + let close_6: boolean; + export { close_6 as close }; + export function exit_1(node: any, token: any, callback: any): void; + export { exit_1 as exit }; + let skipEmpty_6: boolean; + export { skipEmpty_6 as skipEmpty }; +} +declare namespace elseRule { + let tag_7: string; + export { tag_7 as tag }; + let leaf_7: boolean; + export { leaf_7 as leaf }; + let open_7: boolean; + export { open_7 as open }; + let close_7: boolean; + export { close_7 as close }; + export function enter_5(node: any, token: any, callback: any): void; + export { enter_5 as enter }; + let skipEmpty_7: boolean; + export { skipEmpty_7 as skipEmpty }; +} +declare namespace withOpenRule { + let tag_8: string; + export { tag_8 as tag }; + let leaf_8: boolean; + export { leaf_8 as leaf }; + let open_8: boolean; + export { open_8 as open }; + let close_8: boolean; + export { close_8 as close }; + export function enter_6(node: any, token: any, callback: any): void; + export { enter_6 as enter }; + let skipEmpty_8: boolean; + export { skipEmpty_8 as skipEmpty }; +} +declare namespace withCloseRule { + let tag_9: string; + export { tag_9 as tag }; + let leaf_9: boolean; + export { leaf_9 as leaf }; + let open_9: boolean; + export { open_9 as open }; + let close_9: boolean; + export { close_9 as close }; +} +declare namespace joinOpenRule { + let tag_10: string; + export { tag_10 as tag }; + let leaf_10: boolean; + export { leaf_10 as leaf }; + let open_10: boolean; + export { open_10 as open }; + let close_10: boolean; + export { close_10 as close }; + export function enter_7(node: any, token: any, callback: any): void; + export { enter_7 as enter }; + let skipEmpty_9: boolean; + export { skipEmpty_9 as skipEmpty }; +} +declare namespace joinCloseRule { + let tag_11: string; + export { tag_11 as tag }; + let leaf_11: boolean; + export { leaf_11 as leaf }; + let open_11: boolean; + export { open_11 as open }; + let close_11: boolean; + export { close_11 as close }; +} +declare namespace clauseOpenRule { + let tag_12: string; + export { tag_12 as tag }; + let leaf_12: boolean; + export { leaf_12 as leaf }; + let open_12: boolean; + export { open_12 as open }; + let close_12: boolean; + export { close_12 as close }; + export function enter_8(node: any, token: any, callback: any): void; + export { enter_8 as enter }; +} +declare namespace clauseCloseRule { + let tag_13: string; + export { tag_13 as tag }; + let leaf_13: boolean; + export { leaf_13 as leaf }; + let open_13: boolean; + export { open_13 as open }; + let close_13: boolean; + export { close_13 as close }; +} +declare namespace ulistOpenRule { + let tag_14: string; + export { tag_14 as tag }; + let leaf_14: boolean; + export { leaf_14 as leaf }; + let open_14: boolean; + export { open_14 as open }; + let close_14: boolean; + export { close_14 as close }; + export function enter_9(node: any, token: any, callback: any): void; + export { enter_9 as enter }; +} +declare namespace ulistCloseRule { + let tag_15: string; + export { tag_15 as tag }; + let leaf_15: boolean; + export { leaf_15 as leaf }; + let open_15: boolean; + export { open_15 as open }; + let close_15: boolean; + export { close_15 as close }; +} +declare namespace olistOpenRule { + let tag_16: string; + export { tag_16 as tag }; + let leaf_16: boolean; + export { leaf_16 as leaf }; + let open_16: boolean; + export { open_16 as open }; + let close_16: boolean; + export { close_16 as close }; + export function enter_10(node: any, token: any, callback: any): void; + export { enter_10 as enter }; +} +declare namespace olistCloseRule { + let tag_17: string; + export { tag_17 as tag }; + let leaf_17: boolean; + export { leaf_17 as leaf }; + let open_17: boolean; + export { open_17 as open }; + let close_17: boolean; + export { close_17 as close }; +} +export namespace inlines { + export { variableRule as variable }; + export { thisRule as this }; + export { formulaRule as formula }; + export { ifOpenRule as inline_block_if_open }; + export { ifCloseRule as inline_block_if_close }; + export { optionalOpenRule as inline_block_optional_open }; + export { optionalCloseRule as inline_block_optional_close }; + export { elseRule as inline_block_else }; + export { withOpenRule as inline_block_with_open }; + export { withCloseRule as inline_block_with_close }; + export { joinOpenRule as inline_block_join_open }; + export { joinCloseRule as inline_block_join_close }; +} +export namespace blocks { + export { clauseOpenRule as block_clause_open }; + export { clauseCloseRule as block_clause_close }; + export { ulistOpenRule as block_ulist_open }; + export { ulistCloseRule as block_ulist_close }; + export { olistOpenRule as block_olist_open }; + export { olistCloseRule as block_olist_close }; +} +export {}; diff --git a/packages/markdown-template/types/lib/util.d.ts b/packages/markdown-template/types/lib/util.d.ts new file mode 100644 index 00000000..b249e951 --- /dev/null +++ b/packages/markdown-template/types/lib/util.d.ts @@ -0,0 +1,12 @@ +/** + * Flatten an array of array + * @param {*[]} arr the input array + * @return {*[]} the flattened array + */ +export function flatten(arr: any[]): any[]; +/** + * Returns a unique chosen name for a formula + * @param {string} code - the formula code + * @return {string} the unique name + */ +export function formulaName(code: string): string; diff --git a/packages/markdown-transform/package.json b/packages/markdown-transform/package.json index a84595ca..92946fb8 100644 --- a/packages/markdown-transform/package.json +++ b/packages/markdown-transform/package.json @@ -1,153 +1,157 @@ { - "name": "@accordproject/markdown-transform", - "version": "0.16.25", - "description": "API for transforming markdown data", - "engines": { - "node": ">=18", - "npm": ">=9" - }, - "publishConfig": { - "access": "public" - }, - "files": [ - "bin", - "lib", - "umd" - ], - "main": "index.js", - "browser": "umd/markdown-transform.js", - "scripts": { - "webpack": "webpack --config webpack.config.js --mode production", - "build": "babel src -d lib --copy-files", - "build:dist": "NODE_ENV=production babel src -d lib --copy-files", - "build:watch": "babel src -d lib --copy-files --watch", - "prepublishOnly": "npm run build:dist && npm run webpack", - "prepare": "npm run build", - "pretest": "npm run lint && npm run build", - "lint": "eslint .", - "postlint": "npm run licchk", - "licchk": "license-check-and-add", - "test": "mocha --timeout 30000", - "test:cov": "npm run lint && nyc mocha --timeout 30000", - "jsdoc": "jsdoc -c jsdoc.json package.json", - "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/accordproject/markdown-transform.git", - "directory": "packages/markdown-transform" - }, - "keywords": [ - "accord-project", - "markdown", - "markdown-it", - "commonmark" - ], - "author": "accordproject.org", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/accordproject/markdown-transform/issues" - }, - "devDependencies": { - "@babel/cli": "7.25.9", - "@babel/core": "7.26.0", - "@babel/preset-env": "7.16.11", - "@babel/register": "7.25.9", - "axios": "^1.8.2", - "babel-loader": "9.2.1", - "babel-plugin-istanbul": "7.0.0", - "browserify-zlib": "^0.2.0", - "chai": "4.3.6", - "chai-as-promised": "7.1.1", - "chai-string": "^1.5.0", - "chai-things": "0.2.0", - "crypto-browserify": "3.12.1", - "eslint": "8.57.1", - "https-browserify": "^1.0.0", - "jsdoc": "^4.0.4", - "license-check-and-add": "2.3.6", - "mocha": "10.8.2", - "nyc": "17.1.0", - "plantuml-encoder": "^1.4.0", - "raw-loader": "^4.0.2", - "stream-browserify": "3.0.0", - "stream-http": "^3.2.0", - "tsd-jsdoc": "^2.5.0", - "webpack": "^5.96.1", - "webpack-cli": "5.1.4" - }, - "dependencies": { - "@accordproject/concerto-core": "3.25.7", - "@accordproject/markdown-cicero": "*", - "@accordproject/markdown-common": "*", - "@accordproject/markdown-html": "*", - "@accordproject/markdown-template": "*", - "dijkstrajs": "^1.0.3", - "jszip": "^3.10.1" - }, - "license-check-and-add-config": { - "folder": "./lib", - "license": "header.txt", - "exact_paths_method": "EXCLUDE", - "exact_paths": [ - "externalModels/.npmignore", - "externalModels/.gitignore", - "coverage", - "index.d.ts", - "./system", - "LICENSE", - "node_modules", - ".nyc-output", - "out", - ".tern-project" + "name": "@accordproject/markdown-transform", + "version": "0.16.25", + "description": "API for transforming markdown data", + "engines": { + "node": ">=18", + "npm": ">=9" + }, + "publishConfig": { + "access": "public" + }, + "files": [ + "bin", + "lib", + "umd", + "types" ], - "file_type_method": "EXCLUDE", - "file_types": [ - ".yml", - ".yaml", - ".zip", - ".tgz", - ".snap" + "types": "types/index.d.ts", + "main": "index.js", + "browser": "umd/markdown-transform.js", + "scripts": { + "webpack": "webpack --config webpack.config.js --mode production", + "build": "babel src -d lib --copy-files && npm run build:types", + "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types", + "build:dist": "NODE_ENV=production babel src -d lib --copy-files", + "build:watch": "babel src -d lib --copy-files --watch", + "prepublishOnly": "npm run build:dist && npm run webpack", + "prepare": "npm run build", + "pretest": "npm run lint && npm run build", + "lint": "eslint .", + "postlint": "npm run licchk", + "licchk": "license-check-and-add", + "test": "mocha --timeout 30000", + "test:cov": "npm run lint && nyc mocha --timeout 30000", + "jsdoc": "jsdoc -c jsdoc.json package.json", + "typescript": "jsdoc -t node_modules/tsd-jsdoc/dist -r ./src/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/accordproject/markdown-transform.git", + "directory": "packages/markdown-transform" + }, + "keywords": [ + "accord-project", + "markdown", + "markdown-it", + "commonmark" ], - "insert_license": false, - "license_formats": { - "js|njk|pegjs|cto|acl|qry": { - "prepend": "/*", - "append": " */", - "eachLine": { - "prepend": " * " + "author": "accordproject.org", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/accordproject/markdown-transform/issues" + }, + "devDependencies": { + "@babel/cli": "7.25.9", + "@babel/core": "7.26.0", + "@babel/preset-env": "7.16.11", + "@babel/register": "7.25.9", + "axios": "^1.8.2", + "babel-loader": "9.2.1", + "babel-plugin-istanbul": "7.0.0", + "browserify-zlib": "^0.2.0", + "chai": "4.3.6", + "chai-as-promised": "7.1.1", + "chai-string": "^1.5.0", + "chai-things": "0.2.0", + "crypto-browserify": "3.12.1", + "eslint": "8.57.1", + "https-browserify": "^1.0.0", + "jsdoc": "^4.0.4", + "license-check-and-add": "2.3.6", + "mocha": "10.8.2", + "nyc": "17.1.0", + "plantuml-encoder": "^1.4.0", + "raw-loader": "^4.0.2", + "stream-browserify": "3.0.0", + "stream-http": "^3.2.0", + "tsd-jsdoc": "^2.5.0", + "webpack": "^5.96.1", + "webpack-cli": "5.1.4", + "typescript": "5.7.2" + }, + "dependencies": { + "@accordproject/concerto-core": "3.25.7", + "@accordproject/markdown-cicero": "*", + "@accordproject/markdown-common": "*", + "@accordproject/markdown-html": "*", + "@accordproject/markdown-template": "*", + "dijkstrajs": "^1.0.3", + "jszip": "^3.10.1" + }, + "license-check-and-add-config": { + "folder": "./lib", + "license": "header.txt", + "exact_paths_method": "EXCLUDE", + "exact_paths": [ + "externalModels/.npmignore", + "externalModels/.gitignore", + "coverage", + "index.d.ts", + "./system", + "LICENSE", + "node_modules", + ".nyc-output", + "out", + ".tern-project" + ], + "file_type_method": "EXCLUDE", + "file_types": [ + ".yml", + ".yaml", + ".zip", + ".tgz", + ".snap" + ], + "insert_license": false, + "license_formats": { + "js|njk|pegjs|cto|acl|qry": { + "prepend": "/*", + "append": " */", + "eachLine": { + "prepend": " * " + } + }, + "npmrc|editorconfig|txt": { + "eachLine": { + "prepend": "# " + } + }, + "md": { + "file": "header.md" + } } - }, - "npmrc|editorconfig|txt": { - "eachLine": { - "prepend": "# " - } - }, - "md": { - "file": "header.md" - } + }, + "nyc": { + "produce-source-map": "true", + "sourceMap": "inline", + "reporter": [ + "lcov", + "text-summary", + "html", + "json" + ], + "include": [ + "lib/**/*.js" + ], + "exclude": [ + "scripts/**/*.js" + ], + "all": true, + "check-coverage": true, + "statements": 90, + "branches": 88, + "functions": 88, + "lines": 90 } - }, - "nyc": { - "produce-source-map": "true", - "sourceMap": "inline", - "reporter": [ - "lcov", - "text-summary", - "html", - "json" - ], - "include": [ - "lib/**/*.js" - ], - "exclude": [ - "scripts/**/*.js" - ], - "all": true, - "check-coverage": true, - "statements": 90, - "branches": 88, - "functions": 88, - "lines": 90 - } } diff --git a/packages/markdown-transform/types/index.d.ts b/packages/markdown-transform/types/index.d.ts new file mode 100644 index 00000000..fc8c5bcf --- /dev/null +++ b/packages/markdown-transform/types/index.d.ts @@ -0,0 +1,81 @@ +export const formatDescriptor: (format: any) => any; +export const transform: (source: any, sourceFormat: any, destinationFormat: any, parameters: any, options: any) => any; +export const TransformEngine: typeof import("./lib/transformEngine"); +export const builtinTransformationGraph: { + markdown_template: { + docs: string; + fileFormat: string; + templatemark_tokens: (input: any, parameters: any, options: any) => object; + }; + templatemark_tokens: { + docs: string; + fileFormat: string; + templatemark: (input: any, parameters: any, options: any) => Promise; + }; + templatemark: { + docs: string; + fileFormat: string; + markdown_template: (input: any, parameters: any, options: any) => string; + }; + markdown: { + docs: string; + fileFormat: string; + commonmark_tokens: (input: any, parameters: any, options: any) => any; + }; + commonmark_tokens: { + docs: string; + fileFormat: string; + commonmark: (input: any, parameters: any, options: any) => Promise; + }; + markdown_cicero: { + docs: string; + fileFormat: string; + ciceromark_tokens: (input: any, parameters: any, options: any) => any; + }; + ciceromark_tokens: { + docs: string; + fileFormat: string; + ciceromark: (input: any, parameters: any, options: any) => Promise; + }; + commonmark: { + docs: string; + fileFormat: string; + markdown: (input: any, parameters: any, options: any) => string; + ciceromark: (input: any, parameters: any, options: any) => any; + plaintext: (input: any, parameters: any, options: any) => string; + }; + ciceromark: { + docs: string; + fileFormat: string; + markdown_cicero: (input: any, parameters: any, options: any) => string; + commonmark: (input: any, parameters: any, options: any) => any; + ciceromark_parsed: (input: any, parameters: any, options: any) => any; + }; + ciceromark_parsed: { + docs: string; + fileFormat: string; + html: (input: any, parameters: any, options: any) => string; + ciceromark: (input: any, parameters: any, options: any) => any; + ciceromark_unquoted: (input: any, parameters: any, options: any) => object; + }; + plaintext: { + docs: string; + fileFormat: string; + markdown: (input: any, parameters: any, options: any) => any; + }; + ciceroedit: { + docs: string; + fileFormat: string; + ciceromark_parsed: (input: any, parameters: any, options: any) => any; + }; + ciceromark_unquoted: { + docs: string; + fileFormat: string; + ciceromark_parsed: (input: any, parameters: any, options: any) => any; + }; + html: { + docs: string; + fileFormat: string; + ciceromark_parsed: (input: any, parameters: any, options: any) => any; + }; +}; diff --git a/packages/markdown-transform/types/lib/builtinTransforms.d.ts b/packages/markdown-transform/types/lib/builtinTransforms.d.ts new file mode 100644 index 00000000..eee1b36c --- /dev/null +++ b/packages/markdown-transform/types/lib/builtinTransforms.d.ts @@ -0,0 +1,113 @@ +export declare namespace markdown_template { + let docs: string; + let fileFormat: string; + function templatemark_tokens(input: any, parameters: any, options: any): object; +} +export declare namespace templatemark_tokens_1 { + let docs_1: string; + export { docs_1 as docs }; + let fileFormat_1: string; + export { fileFormat_1 as fileFormat }; + export function templatemark(input: any, parameters: any, options: any): Promise; +} +export declare namespace templatemark_1 { + let docs_2: string; + export { docs_2 as docs }; + let fileFormat_2: string; + export { fileFormat_2 as fileFormat }; + export function markdown_template_1(input: any, parameters: any, options: any): string; + export { markdown_template_1 as markdown_template }; +} +export declare namespace markdown { + let docs_3: string; + export { docs_3 as docs }; + let fileFormat_3: string; + export { fileFormat_3 as fileFormat }; + export function commonmark_tokens(input: any, parameters: any, options: any): any; +} +export declare namespace commonmark_tokens_1 { + let docs_4: string; + export { docs_4 as docs }; + let fileFormat_4: string; + export { fileFormat_4 as fileFormat }; + export function commonmark(input: any, parameters: any, options: any): Promise; +} +export declare namespace markdown_cicero { + let docs_5: string; + export { docs_5 as docs }; + let fileFormat_5: string; + export { fileFormat_5 as fileFormat }; + export function ciceromark_tokens(input: any, parameters: any, options: any): any; +} +export declare namespace ciceromark_tokens_1 { + let docs_6: string; + export { docs_6 as docs }; + let fileFormat_6: string; + export { fileFormat_6 as fileFormat }; + export function ciceromark(input: any, parameters: any, options: any): Promise; +} +export declare namespace commonmark_1 { + let docs_7: string; + export { docs_7 as docs }; + let fileFormat_7: string; + export { fileFormat_7 as fileFormat }; + export function markdown_1(input: any, parameters: any, options: any): string; + export { markdown_1 as markdown }; + export function ciceromark_1(input: any, parameters: any, options: any): any; + export { ciceromark_1 as ciceromark }; + export function plaintext(input: any, parameters: any, options: any): string; +} +export declare namespace ciceromark_2 { + let docs_8: string; + export { docs_8 as docs }; + let fileFormat_8: string; + export { fileFormat_8 as fileFormat }; + export function markdown_cicero_1(input: any, parameters: any, options: any): string; + export { markdown_cicero_1 as markdown_cicero }; + export function commonmark_2(input: any, parameters: any, options: any): any; + export { commonmark_2 as commonmark }; + export function ciceromark_parsed(input: any, parameters: any, options: any): any; +} +export declare namespace ciceromark_parsed_1 { + let docs_9: string; + export { docs_9 as docs }; + let fileFormat_9: string; + export { fileFormat_9 as fileFormat }; + export function html(input: any, parameters: any, options: any): string; + export function ciceromark_3(input: any, parameters: any, options: any): any; + export { ciceromark_3 as ciceromark }; + export function ciceromark_unquoted(input: any, parameters: any, options: any): object; +} +export declare namespace plaintext_1 { + let docs_10: string; + export { docs_10 as docs }; + let fileFormat_10: string; + export { fileFormat_10 as fileFormat }; + export function markdown_2(input: any, parameters: any, options: any): any; + export { markdown_2 as markdown }; +} +export declare namespace ciceroedit { + let docs_11: string; + export { docs_11 as docs }; + let fileFormat_11: string; + export { fileFormat_11 as fileFormat }; + export function ciceromark_parsed_2(input: any, parameters: any, options: any): any; + export { ciceromark_parsed_2 as ciceromark_parsed }; +} +export declare namespace ciceromark_unquoted_1 { + let docs_12: string; + export { docs_12 as docs }; + let fileFormat_12: string; + export { fileFormat_12 as fileFormat }; + export function ciceromark_parsed_3(input: any, parameters: any, options: any): any; + export { ciceromark_parsed_3 as ciceromark_parsed }; +} +export declare namespace html_1 { + let docs_13: string; + export { docs_13 as docs }; + let fileFormat_13: string; + export { fileFormat_13 as fileFormat }; + export function ciceromark_parsed_4(input: any, parameters: any, options: any): any; + export { ciceromark_parsed_4 as ciceromark_parsed }; +} +export { templatemark_tokens_1 as templatemark_tokens, templatemark_1 as templatemark, commonmark_tokens_1 as commonmark_tokens, ciceromark_tokens_1 as ciceromark_tokens, commonmark_1 as commonmark, ciceromark_2 as ciceromark, ciceromark_parsed_1 as ciceromark_parsed, plaintext_1 as plaintext, ciceromark_unquoted_1 as ciceromark_unquoted, html_1 as html }; diff --git a/packages/markdown-transform/types/lib/transform.d.ts b/packages/markdown-transform/types/lib/transform.d.ts new file mode 100644 index 00000000..c8f46a77 --- /dev/null +++ b/packages/markdown-transform/types/lib/transform.d.ts @@ -0,0 +1,7 @@ +export function formatDescriptor(format: any): any; +export function transform(source: any, sourceFormat: any, destinationFormat: any, parameters: any, options: any): any; +export function generateTransformationDiagram(): any; +/** + * This is instantiated here for backward compatibility + */ +export const builtinEngine: any; diff --git a/packages/markdown-transform/types/lib/transformEngine.d.ts b/packages/markdown-transform/types/lib/transformEngine.d.ts new file mode 100644 index 00000000..446fd11e --- /dev/null +++ b/packages/markdown-transform/types/lib/transformEngine.d.ts @@ -0,0 +1,113 @@ +export = TransformEngine; +/** + * A generic transformation engine. + * + * The format for the graph is a map (a JavaScript object) where each entry is a format, i.e., vertex in the graph with the following content: + * + * [sourceFormat]: { + * docs: // A format description + * fileFormat: // What kind of format it is (i.e., utf8, json, binary) + * [targetFormat1]: async (input, parameters, options) => { ... return result } + * [targetFormat2]: async (input, parameters, options) => { ... return result } + * ... + * } + * + * Each [targetFormat] entry defines an edge in the graph transforming [sourceFormat] to [targetFormat] + */ +declare class TransformEngine { + /** + * Construct the transformation engine + * @param {object} transformationGraph - the transformation graph + */ + constructor(transformationGraph: object); + transformationGraph: any; + /** + * Converts the graph of transformations into a PlantUML text string + * @returns {string} the PlantUML string + */ + generateTransformationDiagram(): string; + /** + * Transforms from a source format to a single destination format or + * throws an exception if the transformation is not possible. + * + * @param {*} source the input for the transformation + * @param {string} sourceFormat the input format + * @param {string} destinationFormat the destination format + * @param {object} parameters the transform parameters + * @param {object} [options] the transform options + * @param {boolean} [options.verbose] output verbose console logs + * @returns {*} result of the transformation + */ + transformToDestination(source: any, sourceFormat: string, destinationFormat: string, parameters: object, options?: { + verbose?: boolean; + }): any; + /** + * Transforms from a source format to a list of destination formats, or + * throws an exception if the transformation is not possible. + * + * @param {*} source the input for the transformation + * @param {string} sourceFormat the input format + * @param {string[]} destinationFormat the destination format as an array, + * the transformation are applied in order to reach all formats in the array + * @param {object} parameters the transform parameters + * @param {object} [options] the transform options + * @param {boolean} [options.verbose] output verbose console logs + * @returns {Promise} result of the transformation + */ + transform(source: any, sourceFormat: string, destinationFormat: string[], parameters: object, options?: { + verbose?: boolean; + }): Promise; + /** + * Return the format descriptor for a given format + * + * @param {string} format the format + * @return {object} the descriptor for that format + */ + formatDescriptor(format: string): object; + /** + * Return the transformation graph + * + * @return {object} the transformation graph + */ + getTransformationGraph(): object; + /** + * Return all the available formats + * + * @return {object} the transformation graph + */ + getAllFormats(): object; + /** + * Return all the available targets from a source formats + * + * @param {string} sourceFormat - the sourceFormat + * @return {object} the transformation graph + */ + getAllTargetFormats(sourceFormat: string): object; + /** + * Add a new format + * + * @param {string} sourceFormat - the name of the source format + * @param {string} docs - the format description + * @param {string} fileFormat - the format type (either 'json', 'utf8' or 'binary') + */ + registerFormat(sourceFormat: string, docs: string, fileFormat: string): void; + /** + * Add a new transform + * + * @param {string} sourceFormat - the name of the source format + * @param {string} targetFormat - the name of the targetFormat format + * @param {*} transform - the transform (an async function to transform from sourceFormat to targetFormat) + */ + registerTransformation(sourceFormat: string, targetFormat: string, transform: any): void; + /** + * Register a transform extension + * @param {*} extension - the transform extension, including format and transforms + */ + registerExtension(extension: any): void; + /** + * Refresh raw graph + * @private + */ + private refreshRawGraph; + rawGraph: any; +}