@robinpath/toml 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +73 -12
  2. package/dist/toml.js +52 -42
  3. package/package.json +40 -8
package/dist/index.js CHANGED
@@ -1,12 +1,73 @@
1
- import { TomlFunctions, TomlFunctionMetadata, TomlModuleMetadata } from "./toml.js";
2
- const TomlModule = {
3
- name: "toml",
4
- functions: TomlFunctions,
5
- functionMetadata: TomlFunctionMetadata,
6
- moduleMetadata: TomlModuleMetadata,
7
- global: false,
8
- }; // as ModuleAdapter
9
- export default TomlModule;
10
- export { TomlModule };
11
- export { TomlFunctions, TomlFunctionMetadata, TomlModuleMetadata } from "./toml.js";
12
- //# sourceMappingURL=index.js.map
1
+ // src/toml.ts
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ function resolvePath(obj, path) {
4
+ const keys = path.split(".");
5
+ let current = obj;
6
+ for (const key of keys) {
7
+ if (current == null || typeof current !== "object") return void 0;
8
+ current = current[key];
9
+ }
10
+ return current;
11
+ }
12
+ var parse = (args) => any(String(args[0] ?? ""));
13
+ var stringify = (args) => any(args[0]);
14
+ var parseFile = (args) => any(readFileSync(String(args[0] ?? ""), "utf-8"));
15
+ var writeFile = (args) => {
16
+ writeFileSync(String(args[0] ?? ""), any(args[1]), "utf-8");
17
+ return true;
18
+ };
19
+ var get = (args) => {
20
+ const obj = any(String(args[0] ?? ""));
21
+ return resolvePath(obj, String(args[1] ?? ""));
22
+ };
23
+ var isValid = (args) => {
24
+ try {
25
+ any(String(args[0] ?? ""));
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
30
+ };
31
+ var toJSON = (args) => JSON.stringify(any(String(args[0] ?? "")), null, 2);
32
+ var fromJSON = (args) => any(JSON.parse(String(args[0] ?? "")));
33
+ var TomlFunctions = {
34
+ parse,
35
+ stringify,
36
+ parseFile,
37
+ writeFile,
38
+ get,
39
+ isValid,
40
+ toJSON,
41
+ fromJSON
42
+ };
43
+ var TomlFunctionMetadata = {
44
+ parse: { description: "Parse a TOML string to object", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parse "title = \\"My App\\""' },
45
+ stringify: { description: "Convert object to TOML string", parameters: [{ name: "obj", dataType: "object", description: "Object to convert", formInputType: "json", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.stringify $config" },
46
+ parseFile: { description: "Read and parse a TOML file", parameters: [{ name: "filePath", dataType: "string", description: "Path to TOML file", formInputType: "text", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parseFile "config.toml"' },
47
+ writeFile: { description: "Write object as TOML to file", parameters: [{ name: "filePath", dataType: "string", description: "Output file path", formInputType: "text", required: true }, { name: "obj", dataType: "object", description: "Object to write", formInputType: "json", required: true }], returnType: "boolean", returnDescription: "True on success", example: 'toml.writeFile "config.toml" $obj' },
48
+ get: { description: "Get nested value by dot path from TOML string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }, { name: "path", dataType: "string", description: "Dot-separated path", formInputType: "text", required: true }], returnType: "any", returnDescription: "Value at path", example: 'toml.get $toml "database.host"' },
49
+ isValid: { description: "Check if string is valid TOML", parameters: [{ name: "str", dataType: "string", description: "String to check", formInputType: "textarea", required: true }], returnType: "boolean", returnDescription: "True if valid TOML", example: 'toml.isValid "key = 1"' },
50
+ toJSON: { description: "Convert TOML string to JSON string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "JSON string", example: "toml.toJSON $toml" },
51
+ fromJSON: { description: "Convert JSON string to TOML string", parameters: [{ name: "jsonString", dataType: "string", description: "JSON string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.fromJSON $json" }
52
+ };
53
+ var TomlModuleMetadata = {
54
+ description: "Parse, stringify, and manipulate TOML configuration files",
55
+ methods: ["parse", "stringify", "parseFile", "writeFile", "get", "isValid", "toJSON", "fromJSON"]
56
+ };
57
+
58
+ // src/index.ts
59
+ var TomlModule = {
60
+ name: "toml",
61
+ functions: TomlFunctions,
62
+ functionMetadata: TomlFunctionMetadata,
63
+ moduleMetadata: TomlModuleMetadata,
64
+ global: false
65
+ };
66
+ var index_default = TomlModule;
67
+ export {
68
+ TomlFunctionMetadata,
69
+ TomlFunctions,
70
+ TomlModule,
71
+ TomlModuleMetadata,
72
+ index_default as default
73
+ };
package/dist/toml.js CHANGED
@@ -1,51 +1,61 @@
1
+ // src/toml.ts
1
2
  import { readFileSync, writeFileSync } from "node:fs";
2
3
  function resolvePath(obj, path) {
3
- const keys = path.split(".");
4
- let current = obj;
5
- for (const key of keys) {
6
- if (current == null || typeof current !== "object")
7
- return undefined;
8
- current = current[key];
9
- }
10
- return current;
4
+ const keys = path.split(".");
5
+ let current = obj;
6
+ for (const key of keys) {
7
+ if (current == null || typeof current !== "object") return void 0;
8
+ current = current[key];
9
+ }
10
+ return current;
11
11
  }
12
- const parse = (args) => any(String(args[0] ?? ""));
13
- const stringify = (args) => any(args[0]);
14
- const parseFile = (args) => any(readFileSync(String(args[0] ?? ""), "utf-8"));
15
- const writeFile = (args) => {
16
- writeFileSync(String(args[0] ?? ""), any(args[1]), "utf-8");
17
- return true;
12
+ var parse = (args) => any(String(args[0] ?? ""));
13
+ var stringify = (args) => any(args[0]);
14
+ var parseFile = (args) => any(readFileSync(String(args[0] ?? ""), "utf-8"));
15
+ var writeFile = (args) => {
16
+ writeFileSync(String(args[0] ?? ""), any(args[1]), "utf-8");
17
+ return true;
18
+ };
19
+ var get = (args) => {
20
+ const obj = any(String(args[0] ?? ""));
21
+ return resolvePath(obj, String(args[1] ?? ""));
18
22
  };
19
- const get = (args) => {
20
- const obj = any(String(args[0] ?? ""));
21
- return resolvePath(obj, String(args[1] ?? ""));
23
+ var isValid = (args) => {
24
+ try {
25
+ any(String(args[0] ?? ""));
26
+ return true;
27
+ } catch {
28
+ return false;
29
+ }
22
30
  };
23
- const isValid = (args) => {
24
- try {
25
- any(String(args[0] ?? ""));
26
- return true;
27
- }
28
- catch {
29
- return false;
30
- }
31
+ var toJSON = (args) => JSON.stringify(any(String(args[0] ?? "")), null, 2);
32
+ var fromJSON = (args) => any(JSON.parse(String(args[0] ?? "")));
33
+ var TomlFunctions = {
34
+ parse,
35
+ stringify,
36
+ parseFile,
37
+ writeFile,
38
+ get,
39
+ isValid,
40
+ toJSON,
41
+ fromJSON
31
42
  };
32
- const toJSON = (args) => JSON.stringify(any(String(args[0] ?? "")), null, 2);
33
- const fromJSON = (args) => any(JSON.parse(String(args[0] ?? "")));
34
- export const TomlFunctions = {
35
- parse, stringify, parseFile, writeFile, get, isValid, toJSON, fromJSON,
43
+ var TomlFunctionMetadata = {
44
+ parse: { description: "Parse a TOML string to object", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parse "title = \\"My App\\""' },
45
+ stringify: { description: "Convert object to TOML string", parameters: [{ name: "obj", dataType: "object", description: "Object to convert", formInputType: "json", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.stringify $config" },
46
+ parseFile: { description: "Read and parse a TOML file", parameters: [{ name: "filePath", dataType: "string", description: "Path to TOML file", formInputType: "text", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parseFile "config.toml"' },
47
+ writeFile: { description: "Write object as TOML to file", parameters: [{ name: "filePath", dataType: "string", description: "Output file path", formInputType: "text", required: true }, { name: "obj", dataType: "object", description: "Object to write", formInputType: "json", required: true }], returnType: "boolean", returnDescription: "True on success", example: 'toml.writeFile "config.toml" $obj' },
48
+ get: { description: "Get nested value by dot path from TOML string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }, { name: "path", dataType: "string", description: "Dot-separated path", formInputType: "text", required: true }], returnType: "any", returnDescription: "Value at path", example: 'toml.get $toml "database.host"' },
49
+ isValid: { description: "Check if string is valid TOML", parameters: [{ name: "str", dataType: "string", description: "String to check", formInputType: "textarea", required: true }], returnType: "boolean", returnDescription: "True if valid TOML", example: 'toml.isValid "key = 1"' },
50
+ toJSON: { description: "Convert TOML string to JSON string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "JSON string", example: "toml.toJSON $toml" },
51
+ fromJSON: { description: "Convert JSON string to TOML string", parameters: [{ name: "jsonString", dataType: "string", description: "JSON string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.fromJSON $json" }
36
52
  };
37
- export const TomlFunctionMetadata = {
38
- parse: { description: "Parse a TOML string to object", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parse "title = \\"My App\\""' },
39
- stringify: { description: "Convert object to TOML string", parameters: [{ name: "obj", dataType: "object", description: "Object to convert", formInputType: "json", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.stringify $config" },
40
- parseFile: { description: "Read and parse a TOML file", parameters: [{ name: "filePath", dataType: "string", description: "Path to TOML file", formInputType: "text", required: true }], returnType: "object", returnDescription: "Parsed object", example: 'toml.parseFile "config.toml"' },
41
- writeFile: { description: "Write object as TOML to file", parameters: [{ name: "filePath", dataType: "string", description: "Output file path", formInputType: "text", required: true }, { name: "obj", dataType: "object", description: "Object to write", formInputType: "json", required: true }], returnType: "boolean", returnDescription: "True on success", example: 'toml.writeFile "config.toml" $obj' },
42
- get: { description: "Get nested value by dot path from TOML string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }, { name: "path", dataType: "string", description: "Dot-separated path", formInputType: "text", required: true }], returnType: "any", returnDescription: "Value at path", example: 'toml.get $toml "database.host"' },
43
- isValid: { description: "Check if string is valid TOML", parameters: [{ name: "str", dataType: "string", description: "String to check", formInputType: "textarea", required: true }], returnType: "boolean", returnDescription: "True if valid TOML", example: 'toml.isValid "key = 1"' },
44
- toJSON: { description: "Convert TOML string to JSON string", parameters: [{ name: "tomlString", dataType: "string", description: "TOML string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "JSON string", example: "toml.toJSON $toml" },
45
- fromJSON: { description: "Convert JSON string to TOML string", parameters: [{ name: "jsonString", dataType: "string", description: "JSON string", formInputType: "textarea", required: true }], returnType: "string", returnDescription: "TOML string", example: "toml.fromJSON $json" },
53
+ var TomlModuleMetadata = {
54
+ description: "Parse, stringify, and manipulate TOML configuration files",
55
+ methods: ["parse", "stringify", "parseFile", "writeFile", "get", "isValid", "toJSON", "fromJSON"]
46
56
  };
47
- export const TomlModuleMetadata = {
48
- description: "Parse, stringify, and manipulate TOML configuration files",
49
- methods: ["parse", "stringify", "parseFile", "writeFile", "get", "isValid", "toJSON", "fromJSON"],
57
+ export {
58
+ TomlFunctionMetadata,
59
+ TomlFunctions,
60
+ TomlModuleMetadata
50
61
  };
51
- //# sourceMappingURL=toml.js.map
package/package.json CHANGED
@@ -1,14 +1,46 @@
1
1
  {
2
2
  "name": "@robinpath/toml",
3
- "version": "0.1.0",
4
- "publishConfig": { "access": "public" },
3
+ "version": "0.1.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
5
7
  "type": "module",
6
8
  "main": "dist/index.js",
7
9
  "types": "dist/index.d.ts",
8
- "exports": { ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" } },
9
- "files": ["dist"],
10
- "scripts": { "build": "tsc", "test": "node --import tsx --test tests/*.test.ts" },
11
- "dependencies": { "smol-toml": "^1.3.0" },
12
- "peerDependencies": { "@wiredwp/robinpath": ">=0.20.0" },
13
- "devDependencies": { "@wiredwp/robinpath": "^0.30.1", "tsx": "^4.19.0", "typescript": "^5.6.0" }
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "test": "node --import tsx --test tests/*.test.ts"
22
+ },
23
+ "dependencies": {
24
+ "smol-toml": "^1.3.0"
25
+ },
26
+ "peerDependencies": {
27
+ "@wiredwp/robinpath": ">=0.20.0"
28
+ },
29
+ "devDependencies": {
30
+ "@wiredwp/robinpath": "^0.30.1",
31
+ "tsx": "^4.19.0",
32
+ "typescript": "^5.6.0"
33
+ },
34
+ "description": "Parse, stringify, and manipulate TOML configuration files",
35
+ "keywords": [
36
+ "toml",
37
+ "utility"
38
+ ],
39
+ "license": "MIT",
40
+ "robinpath": {
41
+ "category": "utility",
42
+ "type": "utility",
43
+ "auth": "none",
44
+ "functionCount": 8
45
+ }
14
46
  }