@rolexjs/resourcex-types 0.1.0
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.
- package/dist/index.d.ts +27 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BundledType } from 'resourcexjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Organization type for ResourceX.
|
|
5
|
+
*
|
|
6
|
+
* An organization resource contains:
|
|
7
|
+
* - organization.json (manifest)
|
|
8
|
+
* - *.feature (Gherkin content)
|
|
9
|
+
*
|
|
10
|
+
* Resolves to a State tree (plain object) for prototype merging.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
declare const organizationType: BundledType;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Role type for ResourceX.
|
|
17
|
+
*
|
|
18
|
+
* A role resource contains:
|
|
19
|
+
* - individual.json (manifest)
|
|
20
|
+
* - *.feature (Gherkin content)
|
|
21
|
+
*
|
|
22
|
+
* Resolves to a State tree (plain object) for prototype merging.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
declare const roleType: BundledType;
|
|
26
|
+
|
|
27
|
+
export { organizationType, roleType };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/resolver.ts
|
|
2
|
+
function resolverCode(typeName, manifestFile) {
|
|
3
|
+
return `// @resolver: ${typeName}_type_default
|
|
4
|
+
var ${typeName}_type_default = {
|
|
5
|
+
name: "${typeName}",
|
|
6
|
+
async resolve(ctx) {
|
|
7
|
+
var decoder = new TextDecoder();
|
|
8
|
+
|
|
9
|
+
// Find and parse manifest
|
|
10
|
+
var manifestBuf = ctx.files["${manifestFile}"];
|
|
11
|
+
if (!manifestBuf) {
|
|
12
|
+
throw new Error("${typeName} resource must contain a ${manifestFile} file");
|
|
13
|
+
}
|
|
14
|
+
var manifest = JSON.parse(decoder.decode(manifestBuf));
|
|
15
|
+
|
|
16
|
+
// Collect .feature file contents
|
|
17
|
+
var features = {};
|
|
18
|
+
for (var name of Object.keys(ctx.files)) {
|
|
19
|
+
if (name.endsWith(".feature")) {
|
|
20
|
+
features[name] = decoder.decode(ctx.files[name]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Build State tree from manifest node
|
|
25
|
+
function buildState(id, node) {
|
|
26
|
+
var filename = id + "." + node.type + ".feature";
|
|
27
|
+
var information = features[filename];
|
|
28
|
+
var children = [];
|
|
29
|
+
if (node.children) {
|
|
30
|
+
var entries = Object.entries(node.children);
|
|
31
|
+
for (var i = 0; i < entries.length; i++) {
|
|
32
|
+
children.push(buildState(entries[i][0], entries[i][1]));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var state = { id: id, name: node.type, description: "", parent: null };
|
|
36
|
+
if (information) state.information = information;
|
|
37
|
+
if (children.length > 0) state.children = children;
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Build root State
|
|
42
|
+
var rootFilename = manifest.id + "." + manifest.type + ".feature";
|
|
43
|
+
var rootInformation = features[rootFilename];
|
|
44
|
+
var children = [];
|
|
45
|
+
if (manifest.children) {
|
|
46
|
+
var entries = Object.entries(manifest.children);
|
|
47
|
+
for (var i = 0; i < entries.length; i++) {
|
|
48
|
+
children.push(buildState(entries[i][0], entries[i][1]));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var state = { id: manifest.id, name: manifest.type, description: "", parent: null };
|
|
53
|
+
if (manifest.alias) state.alias = manifest.alias;
|
|
54
|
+
if (rootInformation) state.information = rootInformation;
|
|
55
|
+
if (children.length > 0) state.children = children;
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
};`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/organization.ts
|
|
62
|
+
var organizationType = {
|
|
63
|
+
name: "organization",
|
|
64
|
+
aliases: ["org"],
|
|
65
|
+
description: "RoleX organization prototype \u2014 organization manifest + feature files",
|
|
66
|
+
code: resolverCode("organization", "organization.json")
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/role.ts
|
|
70
|
+
var roleType = {
|
|
71
|
+
name: "role",
|
|
72
|
+
aliases: ["individual"],
|
|
73
|
+
description: "RoleX role prototype \u2014 individual manifest + feature files",
|
|
74
|
+
code: resolverCode("role", "individual.json")
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
organizationType,
|
|
78
|
+
roleType
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolver.ts","../src/organization.ts","../src/role.ts"],"sourcesContent":["/**\n * Shared resolver logic for role and organization types.\n *\n * This code is inlined as a string in BundledType.code.\n * It parses manifest JSON + .feature files into a State tree.\n *\n * The resolver receives ctx.files (Record<string, Buffer>) and\n * returns a State object (plain JS object).\n */\n\n/**\n * Generate the resolver code string for a given manifest filename.\n * The code is self-contained — no imports, runs in ResourceX's sandbox.\n */\nexport function resolverCode(typeName: string, manifestFile: string): string {\n return `// @resolver: ${typeName}_type_default\nvar ${typeName}_type_default = {\n name: \"${typeName}\",\n async resolve(ctx) {\n var decoder = new TextDecoder();\n\n // Find and parse manifest\n var manifestBuf = ctx.files[\"${manifestFile}\"];\n if (!manifestBuf) {\n throw new Error(\"${typeName} resource must contain a ${manifestFile} file\");\n }\n var manifest = JSON.parse(decoder.decode(manifestBuf));\n\n // Collect .feature file contents\n var features = {};\n for (var name of Object.keys(ctx.files)) {\n if (name.endsWith(\".feature\")) {\n features[name] = decoder.decode(ctx.files[name]);\n }\n }\n\n // Build State tree from manifest node\n function buildState(id, node) {\n var filename = id + \".\" + node.type + \".feature\";\n var information = features[filename];\n var children = [];\n if (node.children) {\n var entries = Object.entries(node.children);\n for (var i = 0; i < entries.length; i++) {\n children.push(buildState(entries[i][0], entries[i][1]));\n }\n }\n var state = { id: id, name: node.type, description: \"\", parent: null };\n if (information) state.information = information;\n if (children.length > 0) state.children = children;\n return state;\n }\n\n // Build root State\n var rootFilename = manifest.id + \".\" + manifest.type + \".feature\";\n var rootInformation = features[rootFilename];\n var children = [];\n if (manifest.children) {\n var entries = Object.entries(manifest.children);\n for (var i = 0; i < entries.length; i++) {\n children.push(buildState(entries[i][0], entries[i][1]));\n }\n }\n\n var state = { id: manifest.id, name: manifest.type, description: \"\", parent: null };\n if (manifest.alias) state.alias = manifest.alias;\n if (rootInformation) state.information = rootInformation;\n if (children.length > 0) state.children = children;\n return state;\n }\n};`;\n}\n","/**\n * Organization type for ResourceX.\n *\n * An organization resource contains:\n * - organization.json (manifest)\n * - *.feature (Gherkin content)\n *\n * Resolves to a State tree (plain object) for prototype merging.\n */\nimport type { BundledType } from \"resourcexjs\";\nimport { resolverCode } from \"./resolver.js\";\n\nexport const organizationType: BundledType = {\n name: \"organization\",\n aliases: [\"org\"],\n description: \"RoleX organization prototype — organization manifest + feature files\",\n code: resolverCode(\"organization\", \"organization.json\"),\n};\n","/**\n * Role type for ResourceX.\n *\n * A role resource contains:\n * - individual.json (manifest)\n * - *.feature (Gherkin content)\n *\n * Resolves to a State tree (plain object) for prototype merging.\n */\nimport type { BundledType } from \"resourcexjs\";\nimport { resolverCode } from \"./resolver.js\";\n\nexport const roleType: BundledType = {\n name: \"role\",\n aliases: [\"individual\"],\n description: \"RoleX role prototype — individual manifest + feature files\",\n code: resolverCode(\"role\", \"individual.json\"),\n};\n"],"mappings":";AAcO,SAAS,aAAa,UAAkB,cAA8B;AAC3E,SAAO,iBAAiB,QAAQ;AAAA,MAC5B,QAAQ;AAAA,WACH,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,mCAKgB,YAAY;AAAA;AAAA,yBAEtB,QAAQ,4BAA4B,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CzE;;;AC3DO,IAAM,mBAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,SAAS,CAAC,KAAK;AAAA,EACf,aAAa;AAAA,EACb,MAAM,aAAa,gBAAgB,mBAAmB;AACxD;;;ACLO,IAAM,WAAwB;AAAA,EACnC,MAAM;AAAA,EACN,SAAS,CAAC,YAAY;AAAA,EACtB,aAAa;AAAA,EACb,MAAM,aAAa,QAAQ,iBAAiB;AAC9C;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rolexjs/resourcex-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "RoleX resource types for ResourceX — role and organization",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rolex",
|
|
7
|
+
"resourcex",
|
|
8
|
+
"type",
|
|
9
|
+
"role",
|
|
10
|
+
"organization"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/Deepractice/RoleX.git",
|
|
15
|
+
"directory": "packages/resourcex-types"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.0.0"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"bun": "./src/index.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"lint": "biome lint .",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"resourcexjs": "^2.8.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|