@openfairygui/functions 0.2.0-alpha.3 → 0.2.0-alpha.5

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.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.cjs";
1
+ import { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.cjs";
2
2
  import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
3
3
 
4
4
  //#region src/inspect.d.ts
@@ -463,4 +463,4 @@ declare function publish(options: PublishOptions): Transform;
463
463
  */
464
464
  declare function createTransform(name: string, fn: Transform): Transform;
465
465
  //#endregion
466
- export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
466
+ export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppDiagnostic, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.js";
1
+ import { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.js";
2
2
  import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
3
3
 
4
4
  //#region src/inspect.d.ts
@@ -463,4 +463,4 @@ declare function publish(options: PublishOptions): Transform;
463
463
  */
464
464
  declare function createTransform(name: string, fn: Transform): Transform;
465
465
  //#endregion
466
- export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
466
+ export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppDiagnostic, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
@@ -9,6 +9,47 @@ function mapTransactionErrorStage(error) {
9
9
  case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
10
10
  }
11
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
+ }
12
53
  function applyUamTransactionApp(input) {
13
54
  try {
14
55
  return {
@@ -25,8 +66,10 @@ function applyUamTransactionApp(input) {
25
66
  opIndex: error.opIndex,
26
67
  opId: error.opId,
27
68
  opKind: error.opKind,
69
+ operationKind: error.opKind,
28
70
  selector: error.selector,
29
- issues: error.issues
71
+ issues: error.issues,
72
+ diagnostics: mapTransactionDiagnostics(error)
30
73
  }
31
74
  };
32
75
  throw error;
@@ -12,8 +12,10 @@ interface ApplyUamTransactionAppError {
12
12
  opIndex?: number;
13
13
  opId?: string;
14
14
  opKind?: UamTransactionOperation['kind'];
15
+ operationKind?: UamTransactionOperation['kind'];
15
16
  selector?: Record<string, unknown>;
16
17
  issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
18
+ diagnostics: ApplyUamTransactionAppDiagnostic[];
17
19
  }
18
20
  type ApplyUamTransactionAppResult = {
19
21
  ok: true;
@@ -22,6 +24,19 @@ type ApplyUamTransactionAppResult = {
22
24
  ok: false;
23
25
  error: ApplyUamTransactionAppError;
24
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
+ }
25
40
  declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
26
41
  //#endregion
27
- export { ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
42
+ export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
@@ -12,8 +12,10 @@ interface ApplyUamTransactionAppError {
12
12
  opIndex?: number;
13
13
  opId?: string;
14
14
  opKind?: UamTransactionOperation['kind'];
15
+ operationKind?: UamTransactionOperation['kind'];
15
16
  selector?: Record<string, unknown>;
16
17
  issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
18
+ diagnostics: ApplyUamTransactionAppDiagnostic[];
17
19
  }
18
20
  type ApplyUamTransactionAppResult = {
19
21
  ok: true;
@@ -22,6 +24,19 @@ type ApplyUamTransactionAppResult = {
22
24
  ok: false;
23
25
  error: ApplyUamTransactionAppError;
24
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
+ }
25
40
  declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
26
41
  //#endregion
27
- export { ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
42
+ export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
@@ -8,6 +8,47 @@ function mapTransactionErrorStage(error) {
8
8
  case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
9
9
  }
10
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
+ }
11
52
  function applyUamTransactionApp(input) {
12
53
  try {
13
54
  return {
@@ -24,8 +65,10 @@ function applyUamTransactionApp(input) {
24
65
  opIndex: error.opIndex,
25
66
  opId: error.opId,
26
67
  opKind: error.opKind,
68
+ operationKind: error.opKind,
27
69
  selector: error.selector,
28
- issues: error.issues
70
+ issues: error.issues,
71
+ diagnostics: mapTransactionDiagnostics(error)
29
72
  }
30
73
  };
31
74
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/functions",
3
- "version": "0.2.0-alpha.3",
3
+ "version": "0.2.0-alpha.5",
4
4
  "description": "FairyGUI Headless Authoring SDK — composable transform functions.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "publish"
54
54
  ],
55
55
  "dependencies": {
56
- "@openfairygui/core": "0.2.0-alpha.3"
56
+ "@openfairygui/core": "0.2.0-alpha.5"
57
57
  },
58
58
  "devDependencies": {
59
59
  "ava": "^7.0.0",
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ export {
24
24
  } from './publish.js';
25
25
  export {
26
26
  applyUamTransactionApp,
27
+ type ApplyUamTransactionAppDiagnostic,
27
28
  type ApplyUamTransactionAppError,
28
29
  type ApplyUamTransactionAppInput,
29
30
  type ApplyUamTransactionAppResult,
@@ -20,8 +20,10 @@ export interface ApplyUamTransactionAppError {
20
20
  opIndex?: number;
21
21
  opId?: string;
22
22
  opKind?: UamTransactionOperation['kind'];
23
+ operationKind?: UamTransactionOperation['kind'];
23
24
  selector?: Record<string, unknown>;
24
25
  issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
26
+ diagnostics: ApplyUamTransactionAppDiagnostic[];
25
27
  }
26
28
 
27
29
  export type ApplyUamTransactionAppResult =
@@ -41,6 +43,70 @@ function mapTransactionErrorStage(error: UamTransactionError): ApplyUamTransacti
41
43
  }
42
44
  }
43
45
 
46
+ export interface ApplyUamTransactionAppDiagnostic {
47
+ code: string;
48
+ message: string;
49
+ severity: 'error';
50
+ path?: string;
51
+ nodeKind?: string;
52
+ resourceKind?: string;
53
+ gearKind?: string;
54
+ field?: string;
55
+ operationKind?: UamTransactionOperation['kind'];
56
+ opIndex?: number;
57
+ opId?: string;
58
+ }
59
+
60
+ function compactDiagnostic(diagnostic: ApplyUamTransactionAppDiagnostic): ApplyUamTransactionAppDiagnostic {
61
+ return Object.fromEntries(Object.entries(diagnostic).filter(([, value]) => value !== undefined)) as ApplyUamTransactionAppDiagnostic;
62
+ }
63
+
64
+ function isTransactionSupportIssue(issue: UamValidationIssue | UamTransactionSupportIssue): issue is UamTransactionSupportIssue {
65
+ return 'code' in issue;
66
+ }
67
+
68
+ function mapTransactionDiagnostics(error: UamTransactionError): ApplyUamTransactionAppDiagnostic[] {
69
+ if (error.issues?.length) {
70
+ return error.issues.map((issue) => {
71
+ if (isTransactionSupportIssue(issue)) {
72
+ return compactDiagnostic({
73
+ code: issue.code,
74
+ message: issue.message,
75
+ severity: 'error' as const,
76
+ path: issue.path,
77
+ nodeKind: issue.nodeKind,
78
+ resourceKind: issue.resourceKind,
79
+ gearKind: issue.gearKind,
80
+ field: issue.field,
81
+ operationKind: issue.operationKind ?? error.opKind,
82
+ opIndex: error.opIndex,
83
+ opId: error.opId,
84
+ });
85
+ }
86
+ return compactDiagnostic({
87
+ code: error.code,
88
+ message: issue.message,
89
+ severity: 'error' as const,
90
+ path: issue.path,
91
+ operationKind: error.opKind,
92
+ opIndex: error.opIndex,
93
+ opId: error.opId,
94
+ });
95
+ });
96
+ }
97
+ return [
98
+ compactDiagnostic({
99
+ code: error.code,
100
+ message: error.message,
101
+ severity: 'error',
102
+ path: error.opIndex === undefined ? undefined : `operations[${error.opIndex}]`,
103
+ operationKind: error.opKind,
104
+ opIndex: error.opIndex,
105
+ opId: error.opId,
106
+ }),
107
+ ];
108
+ }
109
+
44
110
  export function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult {
45
111
  try {
46
112
  return {
@@ -58,8 +124,10 @@ export function applyUamTransactionApp(input: ApplyUamTransactionAppInput): Appl
58
124
  opIndex: error.opIndex,
59
125
  opId: error.opId,
60
126
  opKind: error.opKind,
127
+ operationKind: error.opKind,
61
128
  selector: error.selector,
62
129
  issues: error.issues,
130
+ diagnostics: mapTransactionDiagnostics(error),
63
131
  },
64
132
  };
65
133
  }