@openfairygui/functions 0.2.0-alpha.0 → 0.2.0-alpha.11
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/README.md +4 -0
- package/dist/index.cjs +872 -282
- package/dist/index.d.cts +143 -79
- package/dist/index.d.ts +143 -79
- package/dist/index.js +869 -283
- package/dist/uam-transaction.cjs +79 -0
- package/dist/uam-transaction.d.cts +42 -0
- package/dist/uam-transaction.d.ts +42 -0
- package/dist/uam-transaction.js +78 -0
- package/package.json +66 -53
- package/src/atlas.ts +502 -146
- package/src/codegen.ts +104 -66
- package/src/index.ts +25 -1
- package/src/plugins/loader.ts +85 -0
- package/src/plugins/types.ts +47 -0
- package/src/publish.ts +499 -105
- package/src/restore.ts +12 -5
- package/src/shared-types.ts +1 -0
- package/src/uam-transaction.ts +69 -1
- package/src/utils.ts +28 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _openfairygui_core_uam = require("@openfairygui/core/uam");
|
|
3
|
+
//#region src/uam-transaction.ts
|
|
4
|
+
function mapTransactionErrorStage(error) {
|
|
5
|
+
switch (error.code) {
|
|
6
|
+
case "transaction_unsupported": return "preflight";
|
|
7
|
+
case "invalid_uam": return "preflight";
|
|
8
|
+
case "execution_failure": return error.opIndex === void 0 && error.issues !== void 0 ? "postflight" : "execution";
|
|
9
|
+
case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function compactDiagnostic(diagnostic) {
|
|
13
|
+
return Object.fromEntries(Object.entries(diagnostic).filter(([, value]) => value !== void 0));
|
|
14
|
+
}
|
|
15
|
+
function isTransactionSupportIssue(issue) {
|
|
16
|
+
return "code" in issue;
|
|
17
|
+
}
|
|
18
|
+
function mapTransactionDiagnostics(error) {
|
|
19
|
+
if (error.issues?.length) return error.issues.map((issue) => {
|
|
20
|
+
if (isTransactionSupportIssue(issue)) return compactDiagnostic({
|
|
21
|
+
code: issue.code,
|
|
22
|
+
message: issue.message,
|
|
23
|
+
severity: "error",
|
|
24
|
+
path: issue.path,
|
|
25
|
+
nodeKind: issue.nodeKind,
|
|
26
|
+
resourceKind: issue.resourceKind,
|
|
27
|
+
gearKind: issue.gearKind,
|
|
28
|
+
field: issue.field,
|
|
29
|
+
operationKind: issue.operationKind ?? error.opKind,
|
|
30
|
+
opIndex: error.opIndex,
|
|
31
|
+
opId: error.opId
|
|
32
|
+
});
|
|
33
|
+
return compactDiagnostic({
|
|
34
|
+
code: error.code,
|
|
35
|
+
message: issue.message,
|
|
36
|
+
severity: "error",
|
|
37
|
+
path: issue.path,
|
|
38
|
+
operationKind: error.opKind,
|
|
39
|
+
opIndex: error.opIndex,
|
|
40
|
+
opId: error.opId
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
return [compactDiagnostic({
|
|
44
|
+
code: error.code,
|
|
45
|
+
message: error.message,
|
|
46
|
+
severity: "error",
|
|
47
|
+
path: error.opIndex === void 0 ? void 0 : `operations[${error.opIndex}]`,
|
|
48
|
+
operationKind: error.opKind,
|
|
49
|
+
opIndex: error.opIndex,
|
|
50
|
+
opId: error.opId
|
|
51
|
+
})];
|
|
52
|
+
}
|
|
53
|
+
function applyUamTransactionApp(input) {
|
|
54
|
+
try {
|
|
55
|
+
return {
|
|
56
|
+
ok: true,
|
|
57
|
+
project: (0, _openfairygui_core_uam.applyUamTransaction)(input.project, input.operations)
|
|
58
|
+
};
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof _openfairygui_core_uam.UamTransactionError) return {
|
|
61
|
+
ok: false,
|
|
62
|
+
error: {
|
|
63
|
+
code: error.code,
|
|
64
|
+
stage: mapTransactionErrorStage(error),
|
|
65
|
+
message: error.message,
|
|
66
|
+
opIndex: error.opIndex,
|
|
67
|
+
opId: error.opId,
|
|
68
|
+
opKind: error.opKind,
|
|
69
|
+
operationKind: error.opKind,
|
|
70
|
+
selector: error.selector,
|
|
71
|
+
issues: error.issues,
|
|
72
|
+
diagnostics: mapTransactionDiagnostics(error)
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
exports.applyUamTransactionApp = applyUamTransactionApp;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UamProject, UamTransactionErrorCode, UamTransactionOperation, UamTransactionSupportIssue, UamValidationIssue } from "@openfairygui/core/uam";
|
|
2
|
+
|
|
3
|
+
//#region src/uam-transaction.d.ts
|
|
4
|
+
interface ApplyUamTransactionAppInput {
|
|
5
|
+
project: UamProject;
|
|
6
|
+
operations: UamTransactionOperation[];
|
|
7
|
+
}
|
|
8
|
+
interface ApplyUamTransactionAppError {
|
|
9
|
+
code: UamTransactionErrorCode;
|
|
10
|
+
stage: 'preflight' | 'execution' | 'postflight';
|
|
11
|
+
message: string;
|
|
12
|
+
opIndex?: number;
|
|
13
|
+
opId?: string;
|
|
14
|
+
opKind?: UamTransactionOperation['kind'];
|
|
15
|
+
operationKind?: UamTransactionOperation['kind'];
|
|
16
|
+
selector?: Record<string, unknown>;
|
|
17
|
+
issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
|
|
18
|
+
diagnostics: ApplyUamTransactionAppDiagnostic[];
|
|
19
|
+
}
|
|
20
|
+
type ApplyUamTransactionAppResult = {
|
|
21
|
+
ok: true;
|
|
22
|
+
project: UamProject;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
error: ApplyUamTransactionAppError;
|
|
26
|
+
};
|
|
27
|
+
interface ApplyUamTransactionAppDiagnostic {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
severity: 'error';
|
|
31
|
+
path?: string;
|
|
32
|
+
nodeKind?: string;
|
|
33
|
+
resourceKind?: string;
|
|
34
|
+
gearKind?: string;
|
|
35
|
+
field?: string;
|
|
36
|
+
operationKind?: UamTransactionOperation['kind'];
|
|
37
|
+
opIndex?: number;
|
|
38
|
+
opId?: string;
|
|
39
|
+
}
|
|
40
|
+
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UamProject, UamTransactionErrorCode, UamTransactionOperation, UamTransactionSupportIssue, UamValidationIssue } from "@openfairygui/core/uam";
|
|
2
|
+
|
|
3
|
+
//#region src/uam-transaction.d.ts
|
|
4
|
+
interface ApplyUamTransactionAppInput {
|
|
5
|
+
project: UamProject;
|
|
6
|
+
operations: UamTransactionOperation[];
|
|
7
|
+
}
|
|
8
|
+
interface ApplyUamTransactionAppError {
|
|
9
|
+
code: UamTransactionErrorCode;
|
|
10
|
+
stage: 'preflight' | 'execution' | 'postflight';
|
|
11
|
+
message: string;
|
|
12
|
+
opIndex?: number;
|
|
13
|
+
opId?: string;
|
|
14
|
+
opKind?: UamTransactionOperation['kind'];
|
|
15
|
+
operationKind?: UamTransactionOperation['kind'];
|
|
16
|
+
selector?: Record<string, unknown>;
|
|
17
|
+
issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
|
|
18
|
+
diagnostics: ApplyUamTransactionAppDiagnostic[];
|
|
19
|
+
}
|
|
20
|
+
type ApplyUamTransactionAppResult = {
|
|
21
|
+
ok: true;
|
|
22
|
+
project: UamProject;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
error: ApplyUamTransactionAppError;
|
|
26
|
+
};
|
|
27
|
+
interface ApplyUamTransactionAppDiagnostic {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
severity: 'error';
|
|
31
|
+
path?: string;
|
|
32
|
+
nodeKind?: string;
|
|
33
|
+
resourceKind?: string;
|
|
34
|
+
gearKind?: string;
|
|
35
|
+
field?: string;
|
|
36
|
+
operationKind?: UamTransactionOperation['kind'];
|
|
37
|
+
opIndex?: number;
|
|
38
|
+
opId?: string;
|
|
39
|
+
}
|
|
40
|
+
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { UamTransactionError, applyUamTransaction } from "@openfairygui/core/uam";
|
|
2
|
+
//#region src/uam-transaction.ts
|
|
3
|
+
function mapTransactionErrorStage(error) {
|
|
4
|
+
switch (error.code) {
|
|
5
|
+
case "transaction_unsupported": return "preflight";
|
|
6
|
+
case "invalid_uam": return "preflight";
|
|
7
|
+
case "execution_failure": return error.opIndex === void 0 && error.issues !== void 0 ? "postflight" : "execution";
|
|
8
|
+
case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function compactDiagnostic(diagnostic) {
|
|
12
|
+
return Object.fromEntries(Object.entries(diagnostic).filter(([, value]) => value !== void 0));
|
|
13
|
+
}
|
|
14
|
+
function isTransactionSupportIssue(issue) {
|
|
15
|
+
return "code" in issue;
|
|
16
|
+
}
|
|
17
|
+
function mapTransactionDiagnostics(error) {
|
|
18
|
+
if (error.issues?.length) return error.issues.map((issue) => {
|
|
19
|
+
if (isTransactionSupportIssue(issue)) return compactDiagnostic({
|
|
20
|
+
code: issue.code,
|
|
21
|
+
message: issue.message,
|
|
22
|
+
severity: "error",
|
|
23
|
+
path: issue.path,
|
|
24
|
+
nodeKind: issue.nodeKind,
|
|
25
|
+
resourceKind: issue.resourceKind,
|
|
26
|
+
gearKind: issue.gearKind,
|
|
27
|
+
field: issue.field,
|
|
28
|
+
operationKind: issue.operationKind ?? error.opKind,
|
|
29
|
+
opIndex: error.opIndex,
|
|
30
|
+
opId: error.opId
|
|
31
|
+
});
|
|
32
|
+
return compactDiagnostic({
|
|
33
|
+
code: error.code,
|
|
34
|
+
message: issue.message,
|
|
35
|
+
severity: "error",
|
|
36
|
+
path: issue.path,
|
|
37
|
+
operationKind: error.opKind,
|
|
38
|
+
opIndex: error.opIndex,
|
|
39
|
+
opId: error.opId
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
return [compactDiagnostic({
|
|
43
|
+
code: error.code,
|
|
44
|
+
message: error.message,
|
|
45
|
+
severity: "error",
|
|
46
|
+
path: error.opIndex === void 0 ? void 0 : `operations[${error.opIndex}]`,
|
|
47
|
+
operationKind: error.opKind,
|
|
48
|
+
opIndex: error.opIndex,
|
|
49
|
+
opId: error.opId
|
|
50
|
+
})];
|
|
51
|
+
}
|
|
52
|
+
function applyUamTransactionApp(input) {
|
|
53
|
+
try {
|
|
54
|
+
return {
|
|
55
|
+
ok: true,
|
|
56
|
+
project: applyUamTransaction(input.project, input.operations)
|
|
57
|
+
};
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error instanceof UamTransactionError) return {
|
|
60
|
+
ok: false,
|
|
61
|
+
error: {
|
|
62
|
+
code: error.code,
|
|
63
|
+
stage: mapTransactionErrorStage(error),
|
|
64
|
+
message: error.message,
|
|
65
|
+
opIndex: error.opIndex,
|
|
66
|
+
opId: error.opId,
|
|
67
|
+
opKind: error.opKind,
|
|
68
|
+
operationKind: error.opKind,
|
|
69
|
+
selector: error.selector,
|
|
70
|
+
issues: error.issues,
|
|
71
|
+
diagnostics: mapTransactionDiagnostics(error)
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { applyUamTransactionApp };
|
package/package.json
CHANGED
|
@@ -1,54 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
2
|
+
"name": "@openfairygui/functions",
|
|
3
|
+
"version": "0.2.0-alpha.11",
|
|
4
|
+
"description": "FairyGUI Headless Authoring SDK — composable transform functions.",
|
|
5
|
+
"author": "OpenFairyGUI Contributors",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/OpenFairyGUI/OpenFairyGUI.git",
|
|
10
|
+
"directory": "packages/functions"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/OpenFairyGUI/OpenFairyGUI#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/OpenFairyGUI/OpenFairyGUI/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.cjs",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"require": {
|
|
24
|
+
"types": "./dist/index.d.cts",
|
|
25
|
+
"default": "./dist/index.cjs"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"./uam": {
|
|
33
|
+
"require": {
|
|
34
|
+
"types": "./dist/uam-transaction.d.cts",
|
|
35
|
+
"default": "./dist/uam-transaction.cjs"
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"types": "./dist/uam-transaction.d.ts",
|
|
39
|
+
"default": "./dist/uam-transaction.js"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist/",
|
|
45
|
+
"src/"
|
|
46
|
+
],
|
|
47
|
+
"keywords": [
|
|
48
|
+
"fairygui",
|
|
49
|
+
"ui",
|
|
50
|
+
"headless",
|
|
51
|
+
"authoring",
|
|
52
|
+
"transform",
|
|
53
|
+
"publish"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"jiti": "^2.6.1",
|
|
57
|
+
"@openfairygui/core": "0.2.0-alpha.11"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"ava": "^7.0.0",
|
|
61
|
+
"tsx": "^4.0.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsdown src/index.ts src/uam-transaction.ts --format esm,cjs --platform neutral --env.PACKAGE_VERSION=$npm_package_version",
|
|
65
|
+
"build:watch": "tsdown src/index.ts src/uam-transaction.ts --watch --format esm,cjs --platform neutral --env.PACKAGE_VERSION=$npm_package_version"
|
|
66
|
+
}
|
|
67
|
+
}
|