@mimir-labs/core 0.2.0 → 0.4.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/README.md +3 -2
- package/dist/implementation/authoring/knowledge-loader.d.ts +10 -0
- package/dist/implementation/authoring/knowledge-loader.js +46 -0
- package/dist/implementation/authoring/knowledge-loader.js.map +1 -0
- package/dist/implementation/authoring/mimir-descriptor-loader.d.ts +2 -0
- package/dist/implementation/authoring/mimir-descriptor-loader.js +7 -0
- package/dist/implementation/authoring/mimir-descriptor-loader.js.map +1 -0
- package/dist/implementation/contracts/descriptor.d.ts +27 -0
- package/dist/implementation/contracts/descriptor.js +3 -0
- package/dist/implementation/contracts/descriptor.js.map +1 -0
- package/dist/implementation/contracts/resource.d.ts +16 -0
- package/dist/implementation/contracts/resource.js +3 -0
- package/dist/implementation/contracts/resource.js.map +1 -0
- package/dist/implementation/descriptors/descriptor-discovery.d.ts +2 -0
- package/dist/implementation/descriptors/descriptor-discovery.js +47 -0
- package/dist/implementation/descriptors/descriptor-discovery.js.map +1 -0
- package/dist/implementation/descriptors/descriptor-repository.d.ts +2 -0
- package/dist/implementation/descriptors/descriptor-repository.js +156 -0
- package/dist/implementation/descriptors/descriptor-repository.js.map +1 -0
- package/dist/implementation/generation/generate-service.d.ts +1 -0
- package/dist/implementation/generation/generate-service.js +68 -52
- package/dist/implementation/generation/generate-service.js.map +1 -1
- package/dist/implementation/generation/provenance/provenance-builder.d.ts +1 -1
- package/dist/implementation/generation/provenance/provenance-builder.js +4 -4
- package/dist/implementation/generation/provenance/provenance-builder.js.map +1 -1
- package/dist/implementation/generation/resource-builders/component-builder.d.ts +2 -1
- package/dist/implementation/generation/resource-builders/component-builder.js +22 -9
- package/dist/implementation/generation/resource-builders/component-builder.js.map +1 -1
- package/dist/implementation/generation/types.d.ts +1 -19
- package/dist/implementation/generators/aps-generator.js +1 -1
- package/dist/implementation/generators/aps-generator.js.map +1 -1
- package/dist/implementation/resource-discovery/storybook-extractor.d.ts +2 -0
- package/dist/implementation/resource-discovery/storybook-extractor.js +63 -0
- package/dist/implementation/resource-discovery/storybook-extractor.js.map +1 -0
- package/dist/implementation/resource-discovery/typescript-extractor.d.ts +2 -0
- package/dist/implementation/resource-discovery/typescript-extractor.js +137 -0
- package/dist/implementation/resource-discovery/typescript-extractor.js.map +1 -0
- package/dist/implementation/services/authoring-service.d.ts +9 -0
- package/dist/implementation/services/authoring-service.js +215 -23
- package/dist/implementation/services/authoring-service.js.map +1 -1
- package/dist/implementation/synchronization/context-generator.js +67 -2
- package/dist/implementation/synchronization/context-generator.js.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ Core business logic and reusable services for the Mimir CLI.
|
|
|
4
4
|
|
|
5
5
|
Public workflows include discovery, authoring, generation, validation,
|
|
6
6
|
governance, context generation, synchronization, initialization, and doctor
|
|
7
|
-
assessment.
|
|
8
|
-
artifacts remain under
|
|
7
|
+
assessment. Author Knowledge sources live in versioned `*.mimir.yaml`
|
|
8
|
+
descriptors maintained by `mimir author`; generated APS artifacts remain under
|
|
9
|
+
`dist/aps`.
|
|
9
10
|
|
|
10
11
|
See extension guidance in [EXTENSIONS.md](./EXTENSIONS.md).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type HumanKnowledge = {
|
|
2
|
+
description: string;
|
|
3
|
+
whenToUse: string[];
|
|
4
|
+
whenNotToUse: string[];
|
|
5
|
+
};
|
|
6
|
+
export type AuthoredKnowledge = {
|
|
7
|
+
knowledge: HumanKnowledge;
|
|
8
|
+
sourceRef: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function loadComponentKnowledge(cwd: string, resourceId: string): Promise<AuthoredKnowledge | null>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadComponentKnowledge = loadComponentKnowledge;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const yaml_1 = require("yaml");
|
|
9
|
+
const fs_1 = require("../io/fs");
|
|
10
|
+
const json_1 = require("../io/json");
|
|
11
|
+
function readStringArray(value, field, sourceRef) {
|
|
12
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
13
|
+
throw new Error(`${sourceRef}: '${field}' must be an array of strings`);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
async function loadComponentKnowledge(cwd, resourceId) {
|
|
18
|
+
const sourceRef = `aps/knowledge/components/${resourceId}.yaml`;
|
|
19
|
+
const filePath = node_path_1.default.join(cwd, "aps", "knowledge", "components", `${resourceId}.yaml`);
|
|
20
|
+
if (!(await (0, fs_1.fileExists)(filePath))) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
let value;
|
|
24
|
+
try {
|
|
25
|
+
value = (0, yaml_1.parse)(await (0, fs_1.readText)(filePath));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
29
|
+
throw new Error(`Invalid author knowledge at ${sourceRef}: ${message}`);
|
|
30
|
+
}
|
|
31
|
+
if (!(0, json_1.isObject)(value)) {
|
|
32
|
+
throw new Error(`${sourceRef}: author knowledge must be a YAML object`);
|
|
33
|
+
}
|
|
34
|
+
if (typeof value.description !== "string") {
|
|
35
|
+
throw new Error(`${sourceRef}: 'description' must be a string`);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
knowledge: {
|
|
39
|
+
description: value.description,
|
|
40
|
+
whenToUse: readStringArray(value.whenToUse, "whenToUse", sourceRef),
|
|
41
|
+
whenNotToUse: readStringArray(value.whenNotToUse, "whenNotToUse", sourceRef)
|
|
42
|
+
},
|
|
43
|
+
sourceRef
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=knowledge-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-loader.js","sourceRoot":"","sources":["../../../src/implementation/authoring/knowledge-loader.ts"],"names":[],"mappings":";;;;;AAwBA,wDAmCC;AA3DD,0DAA6B;AAC7B,+BAA6B;AAC7B,iCAAgD;AAChD,qCAAsC;AAatC,SAAS,eAAe,CAAC,KAAc,EAAE,KAAa,EAAE,SAAiB;IACvE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,MAAM,KAAK,+BAA+B,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAiB,CAAC;AAC3B,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,GAAW,EACX,UAAkB;IAElB,MAAM,SAAS,GAAG,4BAA4B,UAAU,OAAO,CAAC;IAChE,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,UAAU,OAAO,CAAC,CAAC;IAExF,IAAI,CAAC,CAAC,MAAM,IAAA,eAAU,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAA,YAAK,EAAC,MAAM,IAAA,aAAQ,EAAC,QAAQ,CAAC,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,IAAA,eAAQ,EAAC,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,0CAA0C,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,kCAAkC,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,SAAS,EAAE;YACT,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,SAAS,EAAE,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC;YACnE,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,EAAE,SAAS,CAAC;SAC7E;QACD,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadMimirDescriptors = void 0;
|
|
4
|
+
// Backward-compatible re-export. Descriptor loading now lives in descriptors/descriptor-repository.
|
|
5
|
+
var descriptor_repository_1 = require("../descriptors/descriptor-repository");
|
|
6
|
+
Object.defineProperty(exports, "loadMimirDescriptors", { enumerable: true, get: function () { return descriptor_repository_1.loadMimirDescriptors; } });
|
|
7
|
+
//# sourceMappingURL=mimir-descriptor-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mimir-descriptor-loader.js","sourceRoot":"","sources":["../../../src/implementation/authoring/mimir-descriptor-loader.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8EAA4E;AAAnE,6HAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExtractedProp } from "./resource";
|
|
2
|
+
export type MimirResourceDescriptor = {
|
|
3
|
+
kind: string;
|
|
4
|
+
name: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
auto: {
|
|
7
|
+
source: {
|
|
8
|
+
file?: string;
|
|
9
|
+
symbol?: string;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
};
|
|
12
|
+
props: Record<string, ExtractedProp>;
|
|
13
|
+
variants: string[];
|
|
14
|
+
storyFiles: string[];
|
|
15
|
+
};
|
|
16
|
+
human: {
|
|
17
|
+
description: string;
|
|
18
|
+
whenToUse: string[];
|
|
19
|
+
whenNotToUse: string[];
|
|
20
|
+
};
|
|
21
|
+
sourceRef: string;
|
|
22
|
+
};
|
|
23
|
+
export type MimirDescriptorLoadResult = {
|
|
24
|
+
descriptorFiles: string[];
|
|
25
|
+
resources: MimirResourceDescriptor[];
|
|
26
|
+
warnings: string[];
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/implementation/contracts/descriptor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ExtractedProp = {
|
|
2
|
+
name: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type ExtractedComponentFact = {
|
|
7
|
+
name: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
importName: string;
|
|
10
|
+
packageName: string;
|
|
11
|
+
props: Record<string, ExtractedProp>;
|
|
12
|
+
};
|
|
13
|
+
export type StorybookFacts = {
|
|
14
|
+
variantsByComponent: Record<string, string[]>;
|
|
15
|
+
storyFilesByComponent: Record<string, string[]>;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/implementation/contracts/resource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DESCRIPTOR_SUFFIXES = void 0;
|
|
7
|
+
exports.discoverDescriptorFiles = discoverDescriptorFiles;
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const promises_1 = require("node:fs/promises");
|
|
10
|
+
exports.DESCRIPTOR_SUFFIXES = [".mimir.yaml", ".mimir.yml"];
|
|
11
|
+
function normalizeSlashes(value) {
|
|
12
|
+
return value.split(node_path_1.default.sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
function shouldSkipDirectory(name) {
|
|
15
|
+
if (name === "node_modules" || name === "dist" || name === ".git") {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (name.startsWith(".") && name !== ".aps") {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
async function collectDescriptorFiles(dir) {
|
|
24
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
25
|
+
const files = [];
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const absolutePath = node_path_1.default.join(dir, entry.name);
|
|
28
|
+
if (entry.isDirectory()) {
|
|
29
|
+
if (shouldSkipDirectory(entry.name)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
files.push(...(await collectDescriptorFiles(absolutePath)));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (entry.isFile() && exports.DESCRIPTOR_SUFFIXES.some((suffix) => entry.name.endsWith(suffix))) {
|
|
36
|
+
files.push(absolutePath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
async function discoverDescriptorFiles(cwd) {
|
|
42
|
+
const descriptorPaths = await collectDescriptorFiles(cwd);
|
|
43
|
+
return descriptorPaths
|
|
44
|
+
.map((filePath) => normalizeSlashes(node_path_1.default.relative(cwd, filePath)))
|
|
45
|
+
.sort((a, b) => a.localeCompare(b));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=descriptor-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-discovery.js","sourceRoot":"","sources":["../../../src/implementation/descriptors/descriptor-discovery.ts"],"names":[],"mappings":";;;;;;AA4CA,0DAKC;AAjDD,0DAA6B;AAC7B,+CAA2C;AAE9B,QAAA,mBAAmB,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAEjE,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,GAAW;IAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAO,EAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpC,SAAS;YACX,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC5D,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,2BAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACxF,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,GAAW;IACvD,MAAM,eAAe,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC1D,OAAO,eAAe;SACnB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,mBAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadMimirDescriptors = loadMimirDescriptors;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const yaml_1 = require("yaml");
|
|
9
|
+
const fs_1 = require("../io/fs");
|
|
10
|
+
const json_1 = require("../io/json");
|
|
11
|
+
const descriptor_discovery_1 = require("./descriptor-discovery");
|
|
12
|
+
const SUPPORTED_KINDS = new Set([
|
|
13
|
+
"component",
|
|
14
|
+
"function",
|
|
15
|
+
"api",
|
|
16
|
+
"service",
|
|
17
|
+
"model",
|
|
18
|
+
"event",
|
|
19
|
+
"rule",
|
|
20
|
+
"example",
|
|
21
|
+
"pattern",
|
|
22
|
+
"migration"
|
|
23
|
+
]);
|
|
24
|
+
function readStringArray(value, field, sourceRef) {
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
29
|
+
throw new Error(`${sourceRef}: '${field}' must be an array of strings`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function readPropsMap(value, field, sourceRef) {
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(value)) {
|
|
38
|
+
throw new Error(`${sourceRef}: '${field}' must be an array of prop objects`);
|
|
39
|
+
}
|
|
40
|
+
const props = {};
|
|
41
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
42
|
+
const item = value[index];
|
|
43
|
+
if (!(0, json_1.isObject)(item) || typeof item.name !== "string" || item.name.trim() === "") {
|
|
44
|
+
throw new Error(`${sourceRef}: '${field}[${index}]' must include a non-empty 'name'`);
|
|
45
|
+
}
|
|
46
|
+
const name = item.name.trim();
|
|
47
|
+
props[name] = {
|
|
48
|
+
name,
|
|
49
|
+
type: typeof item.type === "string" ? item.type : undefined,
|
|
50
|
+
required: typeof item.required === "boolean" ? item.required : undefined
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return props;
|
|
54
|
+
}
|
|
55
|
+
function readResource(value, sourceRef, index) {
|
|
56
|
+
if (!(0, json_1.isObject)(value)) {
|
|
57
|
+
throw new Error(`${sourceRef}: resources[${index}] must be an object`);
|
|
58
|
+
}
|
|
59
|
+
const resource = value;
|
|
60
|
+
if (typeof resource.kind !== "string" || resource.kind.trim() === "") {
|
|
61
|
+
throw new Error(`${sourceRef}: resources[${index}].kind must be a non-empty string`);
|
|
62
|
+
}
|
|
63
|
+
if (typeof resource.name !== "string" || resource.name.trim() === "") {
|
|
64
|
+
throw new Error(`${sourceRef}: resources[${index}].name must be a non-empty string`);
|
|
65
|
+
}
|
|
66
|
+
const kind = resource.kind.trim().toLowerCase();
|
|
67
|
+
if (!SUPPORTED_KINDS.has(kind)) {
|
|
68
|
+
throw new Error(`${sourceRef}: resources[${index}].kind '${resource.kind}' is not supported by the descriptor contract`);
|
|
69
|
+
}
|
|
70
|
+
const autoNode = (0, json_1.isObject)(resource.auto) ? resource.auto : {};
|
|
71
|
+
const humanNode = (0, json_1.isObject)(resource.human) ? resource.human : {};
|
|
72
|
+
const sourceCandidate = (0, json_1.isObject)(autoNode.source)
|
|
73
|
+
? autoNode.source
|
|
74
|
+
: (0, json_1.isObject)(resource.source)
|
|
75
|
+
? resource.source
|
|
76
|
+
: {};
|
|
77
|
+
const source = (0, json_1.isObject)(sourceCandidate)
|
|
78
|
+
? {
|
|
79
|
+
file: typeof sourceCandidate.file === "string" ? sourceCandidate.file : undefined,
|
|
80
|
+
symbol: typeof sourceCandidate.symbol === "string" ? sourceCandidate.symbol : undefined,
|
|
81
|
+
public: typeof sourceCandidate.public === "boolean" ? sourceCandidate.public : undefined
|
|
82
|
+
}
|
|
83
|
+
: {};
|
|
84
|
+
const props = readPropsMap(autoNode.props ?? resource.props, "auto.props", sourceRef);
|
|
85
|
+
const variants = readStringArray(autoNode.variants ?? resource.variants, "auto.variants", sourceRef);
|
|
86
|
+
const storyFiles = readStringArray(autoNode.storyFiles ?? resource.storyFiles, "auto.storyFiles", sourceRef);
|
|
87
|
+
return {
|
|
88
|
+
kind,
|
|
89
|
+
name: resource.name,
|
|
90
|
+
id: typeof resource.id === "string" ? resource.id : undefined,
|
|
91
|
+
auto: {
|
|
92
|
+
source,
|
|
93
|
+
props,
|
|
94
|
+
variants,
|
|
95
|
+
storyFiles
|
|
96
|
+
},
|
|
97
|
+
human: {
|
|
98
|
+
description: typeof humanNode.description === "string"
|
|
99
|
+
? humanNode.description
|
|
100
|
+
: typeof resource.description === "string"
|
|
101
|
+
? resource.description
|
|
102
|
+
: "",
|
|
103
|
+
whenToUse: readStringArray(humanNode.whenToUse ?? resource.whenToUse, "human.whenToUse", sourceRef),
|
|
104
|
+
whenNotToUse: readStringArray(humanNode.whenNotToUse ?? resource.whenNotToUse, "human.whenNotToUse", sourceRef)
|
|
105
|
+
},
|
|
106
|
+
sourceRef
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async function loadMimirDescriptors(cwd) {
|
|
110
|
+
const descriptorFiles = await (0, descriptor_discovery_1.discoverDescriptorFiles)(cwd);
|
|
111
|
+
const resources = [];
|
|
112
|
+
const warnings = [];
|
|
113
|
+
for (const sourceRef of descriptorFiles) {
|
|
114
|
+
const descriptorPath = node_path_1.default.join(cwd, sourceRef);
|
|
115
|
+
let raw;
|
|
116
|
+
try {
|
|
117
|
+
raw = (0, yaml_1.parse)(await (0, fs_1.readText)(descriptorPath));
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
warnings.push(`Invalid descriptor YAML at ${sourceRef}: ${message}`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!(0, json_1.isObject)(raw)) {
|
|
125
|
+
warnings.push(`${sourceRef}: descriptor must be a YAML object`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const schemaVersion = raw.schemaVersion;
|
|
129
|
+
if (schemaVersion !== 1) {
|
|
130
|
+
warnings.push(`${sourceRef}: schemaVersion must be 1`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (!Array.isArray(raw.resources)) {
|
|
134
|
+
warnings.push(`${sourceRef}: resources must be an array`);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
for (let index = 0; index < raw.resources.length; index += 1) {
|
|
138
|
+
try {
|
|
139
|
+
const resource = readResource(raw.resources[index], sourceRef, index);
|
|
140
|
+
if (resource) {
|
|
141
|
+
resources.push(resource);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
146
|
+
warnings.push(message);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
descriptorFiles,
|
|
152
|
+
resources,
|
|
153
|
+
warnings
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=descriptor-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-repository.js","sourceRoot":"","sources":["../../../src/implementation/descriptors/descriptor-repository.ts"],"names":[],"mappings":";;;;;AAoKA,oDAmDC;AAvND,0DAA6B;AAC7B,+BAA6B;AAC7B,iCAAoC;AACpC,qCAAsC;AAGtC,iEAAiE;AAEjE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,UAAU;IACV,KAAK;IACL,SAAS;IACT,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAiBH,SAAS,eAAe,CAAC,KAAc,EAAE,KAAa,EAAE,SAAiB;IACvE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,MAAM,KAAK,+BAA+B,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAK,CAA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,oCAAoC,CAAC,CAAC;YAChE,SAAS;QACX,CAAC;QAED,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,CAAC;QACxC,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,2BAA2B,CAAC,CAAC;YACvD,SAAS;QACX,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,8BAA8B,CAAC,CAAC;YAC1D,SAAS;QACX,CAAC;QAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBACtE,IAAI,QAAQ,EAAE,CAAC;oBACb,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,eAAe;QACf,SAAS;QACT,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -2,5 +2,6 @@ import type { GenerateReport } from "./types";
|
|
|
2
2
|
type GenerateOptions = {
|
|
3
3
|
force?: boolean;
|
|
4
4
|
};
|
|
5
|
+
export declare function compileApsFromDescriptors(cwd: string, options?: GenerateOptions): Promise<GenerateReport>;
|
|
5
6
|
export declare function generateApsFromEvidence(cwd: string, options?: GenerateOptions): Promise<GenerateReport>;
|
|
6
7
|
export {};
|
|
@@ -3,24 +3,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compileApsFromDescriptors = compileApsFromDescriptors;
|
|
6
7
|
exports.generateApsFromEvidence = generateApsFromEvidence;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
const fs_1 = require("../io/fs");
|
|
9
|
-
const json_1 = require("../io/json");
|
|
10
10
|
const compatibility_1 = require("../../protocol/compatibility");
|
|
11
11
|
const governance_1 = require("../../protocol/governance");
|
|
12
|
-
const readme_extractor_1 = require("./extractors/readme-extractor");
|
|
13
|
-
const storybook_extractor_1 = require("./extractors/storybook-extractor");
|
|
14
|
-
const typescript_extractor_1 = require("./extractors/typescript-extractor");
|
|
15
|
-
const component_builder_1 = require("./resource-builders/component-builder");
|
|
16
12
|
const example_builder_1 = require("./resource-builders/example-builder");
|
|
17
|
-
const
|
|
13
|
+
const descriptor_repository_1 = require("../descriptors/descriptor-repository");
|
|
14
|
+
const resource_identity_1 = require("../resource-identity");
|
|
15
|
+
const provenance_builder_1 = require("./provenance/provenance-builder");
|
|
18
16
|
function hasHumanMetadata(component) {
|
|
19
17
|
return component.description.trim() !== "" && component.whenToUse.length > 0 && component.whenNotToUse.length > 0;
|
|
20
18
|
}
|
|
21
19
|
function toUniqueSorted(values) {
|
|
22
20
|
return [...new Set(values)].sort((a, b) => a.localeCompare(b));
|
|
23
21
|
}
|
|
22
|
+
function buildComponentFromDescriptor(packageName, descriptor) {
|
|
23
|
+
const sourceFile = descriptor.auto.source.file ?? descriptor.sourceRef;
|
|
24
|
+
const storyFiles = descriptor.auto.storyFiles;
|
|
25
|
+
const variants = descriptor.auto.variants;
|
|
26
|
+
const authoredDescription = descriptor.human.description.trim();
|
|
27
|
+
const evidenceByField = {
|
|
28
|
+
id: { evidence: [(0, provenance_builder_1.fromPackageJson)()] },
|
|
29
|
+
name: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
30
|
+
package: { evidence: [(0, provenance_builder_1.fromPackageJson)()] },
|
|
31
|
+
import: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
32
|
+
description: {
|
|
33
|
+
evidence: authoredDescription !== "" ? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)] : [(0, provenance_builder_1.missingHumanSource)("description")]
|
|
34
|
+
},
|
|
35
|
+
props: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
36
|
+
variants: {
|
|
37
|
+
evidence: variants.length > 0
|
|
38
|
+
? storyFiles.length > 0
|
|
39
|
+
? storyFiles.map((file) => (0, provenance_builder_1.fromStorybook)(file))
|
|
40
|
+
: [(0, provenance_builder_1.fromTypeScript)(sourceFile)]
|
|
41
|
+
: [(0, provenance_builder_1.fromTypeScript)(sourceFile)]
|
|
42
|
+
},
|
|
43
|
+
whenToUse: {
|
|
44
|
+
evidence: descriptor.human.whenToUse.length > 0
|
|
45
|
+
? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)]
|
|
46
|
+
: [(0, provenance_builder_1.missingHumanSource)("whenToUse")]
|
|
47
|
+
},
|
|
48
|
+
whenNotToUse: {
|
|
49
|
+
evidence: descriptor.human.whenNotToUse.length > 0
|
|
50
|
+
? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)]
|
|
51
|
+
: [(0, provenance_builder_1.missingHumanSource)("whenNotToUse")]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
type: "component",
|
|
56
|
+
id: descriptor.id ?? (0, resource_identity_1.createComponentResourceId)(packageName, descriptor.name),
|
|
57
|
+
name: descriptor.name,
|
|
58
|
+
package: packageName,
|
|
59
|
+
import: descriptor.auto.source.symbol ?? descriptor.name,
|
|
60
|
+
description: authoredDescription,
|
|
61
|
+
props: descriptor.auto.props,
|
|
62
|
+
variants,
|
|
63
|
+
whenToUse: descriptor.human.whenToUse,
|
|
64
|
+
whenNotToUse: descriptor.human.whenNotToUse,
|
|
65
|
+
governance: {
|
|
66
|
+
fields: evidenceByField
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
24
70
|
async function readPackageName(cwd) {
|
|
25
71
|
const packageJsonPath = node_path_1.default.join(cwd, "package.json");
|
|
26
72
|
const packageJson = await (0, fs_1.readJson)(packageJsonPath);
|
|
@@ -29,44 +75,7 @@ async function readPackageName(cwd) {
|
|
|
29
75
|
}
|
|
30
76
|
return packageJson.name;
|
|
31
77
|
}
|
|
32
|
-
async function
|
|
33
|
-
const warnings = [];
|
|
34
|
-
const packageJsonPath = node_path_1.default.join(cwd, "package.json");
|
|
35
|
-
const packageJson = await (0, fs_1.readJson)(packageJsonPath);
|
|
36
|
-
let changed = false;
|
|
37
|
-
if (!(0, json_1.isObject)(packageJson.aps)) {
|
|
38
|
-
packageJson.aps = {};
|
|
39
|
-
changed = true;
|
|
40
|
-
}
|
|
41
|
-
const aps = packageJson.aps;
|
|
42
|
-
if (aps.version === undefined) {
|
|
43
|
-
aps.version = 1;
|
|
44
|
-
changed = true;
|
|
45
|
-
warnings.push("APS config version was missing and has been set to 1.");
|
|
46
|
-
}
|
|
47
|
-
if (aps.manifest !== APS_MANIFEST_RELATIVE_PATH) {
|
|
48
|
-
const previous = typeof aps.manifest === "string" ? aps.manifest : "(not set)";
|
|
49
|
-
aps.manifest = APS_MANIFEST_RELATIVE_PATH;
|
|
50
|
-
changed = true;
|
|
51
|
-
warnings.push(`APS manifest path updated from '${previous}' to '${APS_MANIFEST_RELATIVE_PATH}' for consistency with generated resources.`);
|
|
52
|
-
}
|
|
53
|
-
if ((0, json_1.isObject)(packageJson.exports)) {
|
|
54
|
-
const exportsMap = packageJson.exports;
|
|
55
|
-
if (exportsMap["./package.json"] !== "./package.json") {
|
|
56
|
-
exportsMap["./package.json"] = "./package.json";
|
|
57
|
-
changed = true;
|
|
58
|
-
warnings.push("Added exports['./package.json'] for provider discovery compatibility.");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (packageJson.exports !== undefined) {
|
|
62
|
-
warnings.push("Package exports is not an object. Could not add exports['./package.json']; configure it manually for discovery compatibility.");
|
|
63
|
-
}
|
|
64
|
-
if (changed) {
|
|
65
|
-
await (0, fs_1.writeJson)(packageJsonPath, packageJson);
|
|
66
|
-
}
|
|
67
|
-
return warnings;
|
|
68
|
-
}
|
|
69
|
-
async function generateApsFromEvidence(cwd, options = {}) {
|
|
78
|
+
async function compileApsFromDescriptors(cwd, options = {}) {
|
|
70
79
|
const packageName = await readPackageName(cwd);
|
|
71
80
|
const outputDir = node_path_1.default.join(cwd, "dist", "aps");
|
|
72
81
|
const manifestPath = node_path_1.default.join(outputDir, "manifest.json");
|
|
@@ -75,18 +84,22 @@ async function generateApsFromEvidence(cwd, options = {}) {
|
|
|
75
84
|
if (alreadyExists && !options.force) {
|
|
76
85
|
throw new Error("APS resources already exist in dist/aps. Re-run with --force to replace existing generated resources.");
|
|
77
86
|
}
|
|
78
|
-
const discoverabilityWarnings = await ensureProviderDiscoverability(cwd);
|
|
79
87
|
await (0, fs_1.ensureDir)(outputDir);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]);
|
|
85
|
-
const components = typescriptComponents.map((component) => (0, component_builder_1.buildComponentResource)(component, storybookFacts, readmeFacts));
|
|
88
|
+
const descriptorResult = await (0, descriptor_repository_1.loadMimirDescriptors)(cwd);
|
|
89
|
+
const unsupportedKinds = toUniqueSorted(descriptorResult.resources.filter((resource) => resource.kind !== "component").map((resource) => resource.kind));
|
|
90
|
+
const componentDescriptors = descriptorResult.resources.filter((resource) => resource.kind === "component");
|
|
91
|
+
const components = await Promise.all(componentDescriptors.map(async (descriptor) => buildComponentFromDescriptor(packageName, descriptor)));
|
|
86
92
|
const exampleResult = (0, example_builder_1.buildExamplesNotImplemented)();
|
|
93
|
+
const descriptorWarnings = [...descriptorResult.warnings];
|
|
94
|
+
if (descriptorResult.descriptorFiles.length === 0) {
|
|
95
|
+
descriptorWarnings.push("No *.mimir.yaml descriptors found. Run 'mimir author' to scaffold descriptor files.");
|
|
96
|
+
}
|
|
97
|
+
if (unsupportedKinds.length > 0) {
|
|
98
|
+
descriptorWarnings.push(`Descriptor resources ignored by generator v1 (unsupported kinds): ${unsupportedKinds.join(", ")}.`);
|
|
99
|
+
}
|
|
87
100
|
const output = {
|
|
88
101
|
components,
|
|
89
|
-
warnings: [...exampleResult.warnings, ...
|
|
102
|
+
warnings: [...exampleResult.warnings, ...descriptorWarnings],
|
|
90
103
|
missingHumanMetadata: toUniqueSorted(components
|
|
91
104
|
.filter((component) => !hasHumanMetadata(component))
|
|
92
105
|
.map((component) => component.name))
|
|
@@ -118,4 +131,7 @@ async function generateApsFromEvidence(cwd, options = {}) {
|
|
|
118
131
|
}
|
|
119
132
|
};
|
|
120
133
|
}
|
|
134
|
+
async function generateApsFromEvidence(cwd, options = {}) {
|
|
135
|
+
return compileApsFromDescriptors(cwd, options);
|
|
136
|
+
}
|
|
121
137
|
//# sourceMappingURL=generate-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../src/implementation/generation/generate-service.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../src/implementation/generation/generate-service.ts"],"names":[],"mappings":";;;;;AAoGA,8DAmFC;AAED,0DAKC;AA9LD,0DAA6B;AAC7B,iCAAsE;AACtE,gEAAmE;AACnE,0DAA+D;AAC/D,yEAAkF;AAElF,gFAA4E;AAE5E,4DAAiE;AACjE,wEAMyC;AAUzC,SAAS,gBAAgB,CAAC,SAAqC;IAC7D,OAAO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
2
|
export declare function fromTypeScript(sourceRef: string): FieldEvidence;
|
|
3
3
|
export declare function fromPackageJson(): FieldEvidence;
|
|
4
4
|
export declare function fromStorybook(sourceRef: string): FieldEvidence;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function fromHumanKnowledge(sourceRef: string): FieldEvidence;
|
|
6
6
|
export declare function missingHumanSource(fieldName: string): FieldEvidence;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fromTypeScript = fromTypeScript;
|
|
4
4
|
exports.fromPackageJson = fromPackageJson;
|
|
5
5
|
exports.fromStorybook = fromStorybook;
|
|
6
|
-
exports.
|
|
6
|
+
exports.fromHumanKnowledge = fromHumanKnowledge;
|
|
7
7
|
exports.missingHumanSource = missingHumanSource;
|
|
8
8
|
function fromTypeScript(sourceRef) {
|
|
9
9
|
return {
|
|
@@ -26,11 +26,11 @@ function fromStorybook(sourceRef) {
|
|
|
26
26
|
confidence: "medium"
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function fromHumanKnowledge(sourceRef) {
|
|
30
30
|
return {
|
|
31
|
-
sourceType: "
|
|
31
|
+
sourceType: "human",
|
|
32
32
|
sourceRef,
|
|
33
|
-
confidence: "
|
|
33
|
+
confidence: "high"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function missingHumanSource(fieldName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provenance-builder.js","sourceRoot":"","sources":["../../../../src/implementation/generation/provenance/provenance-builder.ts"],"names":[],"mappings":";;AAEA,wCAMC;AAED,0CAMC;AAED,sCAMC;AAED,
|
|
1
|
+
{"version":3,"file":"provenance-builder.js","sourceRoot":"","sources":["../../../../src/implementation/generation/provenance/provenance-builder.ts"],"names":[],"mappings":";;AAEA,wCAMC;AAED,0CAMC;AAED,sCAMC;AAED,gDAMC;AAED,gDAOC;AAvCD,SAAgB,cAAc,CAAC,SAAiB;IAC9C,OAAO;QACL,UAAU,EAAE,YAAY;QACxB,SAAS;QACT,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAAC,SAAiB;IAC7C,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS;QACT,UAAU,EAAE,QAAQ;KACrB,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,SAAS;QACT,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,sCAAsC,SAAS,GAAG;KACzD,CAAC;AACJ,CAAC"}
|