@mxpicture/gcp-functions-generator 0.2.69 → 0.2.71
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/4testing/templates/template.example.d.ts +3 -35
- package/dist/4testing/templates/template.example.d.ts.map +1 -1
- package/dist/4testing/templates/template.example.js +103 -181
- package/dist/4testing/templates/template.example.js.map +1 -1
- package/dist/4testing/templates/template.medication.d.ts +1 -27
- package/dist/4testing/templates/template.medication.d.ts.map +1 -1
- package/dist/4testing/templates/template.medication.js +76 -141
- package/dist/4testing/templates/template.medication.js.map +1 -1
- package/dist/4testing/templates/template.settings.d.ts +1 -23
- package/dist/4testing/templates/template.settings.d.ts.map +1 -1
- package/dist/4testing/templates/template.settings.js +38 -73
- package/dist/4testing/templates/template.settings.js.map +1 -1
- package/dist/common/Barrel.d.ts +4 -4
- package/dist/common/Barrel.d.ts.map +1 -1
- package/dist/common/Collector.d.ts +5 -6
- package/dist/common/Collector.d.ts.map +1 -1
- package/dist/common/Collector.js +2 -2
- package/dist/common/Collector.js.map +1 -1
- package/dist/common/Directories.d.ts +12 -12
- package/dist/common/Directories.d.ts.map +1 -1
- package/dist/common/Directories.js +4 -4
- package/dist/common/Directories.js.map +1 -1
- package/dist/common/Extractor.d.ts +4 -28
- package/dist/common/Extractor.d.ts.map +1 -1
- package/dist/common/Extractor.js +11 -185
- package/dist/common/Extractor.js.map +1 -1
- package/dist/common/file.common.d.ts +5 -5
- package/dist/common/file.common.d.ts.map +1 -1
- package/dist/common/file.common.js +6 -6
- package/dist/common/file.common.js.map +1 -1
- package/dist/common/generator.common.d.ts +3 -3
- package/dist/common/generator.common.d.ts.map +1 -1
- package/dist/common/generator.common.js +2 -2
- package/dist/common/generator.common.js.map +1 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +0 -1
- package/dist/common/index.js.map +1 -1
- package/dist/common/types.common.d.ts +4 -4
- package/dist/common/types.common.d.ts.map +1 -1
- package/dist/{meta/meta.imports.d.ts → decorator/deco.imports.d.ts} +3 -3
- package/dist/decorator/deco.imports.d.ts.map +1 -0
- package/dist/{meta/meta.imports.js → decorator/deco.imports.js} +1 -1
- package/dist/decorator/deco.imports.js.map +1 -0
- package/dist/decorator/deco.names.d.ts +13 -0
- package/dist/decorator/deco.names.d.ts.map +1 -0
- package/dist/decorator/deco.names.js +93 -0
- package/dist/decorator/deco.names.js.map +1 -0
- package/dist/decorator/index.d.ts +3 -0
- package/dist/decorator/index.d.ts.map +1 -0
- package/dist/decorator/index.js +4 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/generator/Generator.d.ts +26 -21
- package/dist/generator/Generator.d.ts.map +1 -1
- package/dist/generator/Generator.js +24 -23
- package/dist/generator/Generator.js.map +1 -1
- package/dist/generator/GeneratorAnnotations.d.ts +2 -4
- package/dist/generator/GeneratorAnnotations.d.ts.map +1 -1
- package/dist/generator/GeneratorAnnotations.js +24 -23
- package/dist/generator/GeneratorAnnotations.js.map +1 -1
- package/dist/generator/GeneratorBackend.d.ts +8 -8
- package/dist/generator/GeneratorBackend.d.ts.map +1 -1
- package/dist/generator/GeneratorBackend.js +21 -18
- package/dist/generator/GeneratorBackend.js.map +1 -1
- package/dist/generator/GeneratorDoc.d.ts +2 -4
- package/dist/generator/GeneratorDoc.d.ts.map +1 -1
- package/dist/generator/GeneratorDoc.js +24 -8
- package/dist/generator/GeneratorDoc.js.map +1 -1
- package/dist/generator/GeneratorFrontend.d.ts +7 -7
- package/dist/generator/GeneratorFrontend.d.ts.map +1 -1
- package/dist/generator/GeneratorFrontend.js +19 -16
- package/dist/generator/GeneratorFrontend.js.map +1 -1
- package/dist/generator/GeneratorRoutes.d.ts +5 -6
- package/dist/generator/GeneratorRoutes.d.ts.map +1 -1
- package/dist/generator/GeneratorRoutes.js +15 -9
- package/dist/generator/GeneratorRoutes.js.map +1 -1
- package/dist/generator/GeneratorZod.d.ts +19 -19
- package/dist/generator/GeneratorZod.d.ts.map +1 -1
- package/dist/generator/GeneratorZod.js +19 -17
- package/dist/generator/GeneratorZod.js.map +1 -1
- package/package.json +10 -7
- package/dist/common/Evaluate.d.ts +0 -13
- package/dist/common/Evaluate.d.ts.map +0 -1
- package/dist/common/Evaluate.js +0 -121
- package/dist/common/Evaluate.js.map +0 -1
- package/dist/meta/index.d.ts +0 -4
- package/dist/meta/index.d.ts.map +0 -1
- package/dist/meta/index.js +0 -5
- package/dist/meta/index.js.map +0 -1
- package/dist/meta/meta.decorators.d.ts +0 -19
- package/dist/meta/meta.decorators.d.ts.map +0 -1
- package/dist/meta/meta.decorators.js +0 -23
- package/dist/meta/meta.decorators.js.map +0 -1
- package/dist/meta/meta.imports.d.ts.map +0 -1
- package/dist/meta/meta.imports.js.map +0 -1
- package/dist/meta/meta.names.d.ts +0 -14
- package/dist/meta/meta.names.d.ts.map +0 -1
- package/dist/meta/meta.names.js +0 -98
- package/dist/meta/meta.names.js.map +0 -1
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Example: Decorator-based Zod schema generation
|
|
3
|
-
*
|
|
4
|
-
* Since TypeScript interfaces are compile-time only and don't exist at runtime,
|
|
5
|
-
* we demonstrate the decorator system using classes that can serve as both
|
|
6
|
-
* type definitions and runtime metadata carriers.
|
|
7
|
-
*
|
|
8
|
-
* This example shows how to:
|
|
9
|
-
* 1. Use decorators to annotate class properties
|
|
10
|
-
* 2. Generate Zod schemas from the decorator metadata
|
|
11
|
-
* 3. Use the generated schemas for validation
|
|
12
|
-
*/
|
|
13
|
-
import type { DocumentAdmin, DocumentKey } from "@mxpicture/gcp-functions-common/types";
|
|
14
|
-
export declare class SettingsTemplate implements DocumentKey, DocumentAdmin {
|
|
15
|
-
id: string;
|
|
16
|
-
createTime?: Date;
|
|
17
|
-
updateTime?: Date;
|
|
18
|
-
active: boolean;
|
|
19
|
-
name: string;
|
|
20
|
-
type: string;
|
|
21
|
-
valueNumber?: number;
|
|
22
|
-
valueString?: string;
|
|
23
|
-
}
|
|
1
|
+
export declare const medication: import("@mxpicture/gcp-functions-common/decorator").Decorator;
|
|
24
2
|
//# sourceMappingURL=template.settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.settings.d.ts","sourceRoot":"","sources":["../../../src/4testing/templates/template.settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.settings.d.ts","sourceRoot":"","sources":["../../../src/4testing/templates/template.settings.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,UAAU,+DAkCnB,CAAC"}
|
|
@@ -1,74 +1,39 @@
|
|
|
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
|
-
__metadata("design:type", Date)
|
|
40
|
-
], SettingsTemplate.prototype, "createTime", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
MetaUpdateTime({ optional: true }),
|
|
43
|
-
__metadata("design:type", Date)
|
|
44
|
-
], SettingsTemplate.prototype, "updateTime", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
MetaBoolean({ title: "Active", default: true }),
|
|
47
|
-
__metadata("design:type", Boolean)
|
|
48
|
-
], SettingsTemplate.prototype, "active", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
MetaString({ title: "Name", default: "" }),
|
|
51
|
-
__metadata("design:type", String)
|
|
52
|
-
], SettingsTemplate.prototype, "name", void 0);
|
|
53
|
-
__decorate([
|
|
54
|
-
MetaString({ title: "Type", default: "" }),
|
|
55
|
-
__metadata("design:type", String)
|
|
56
|
-
], SettingsTemplate.prototype, "type", void 0);
|
|
57
|
-
__decorate([
|
|
58
|
-
MetaNumber({ title: "Number", optional: true, default: 0 }),
|
|
59
|
-
__metadata("design:type", Number)
|
|
60
|
-
], SettingsTemplate.prototype, "valueNumber", void 0);
|
|
61
|
-
__decorate([
|
|
62
|
-
MetaString({ title: "String", optional: true, default: "" }),
|
|
63
|
-
__metadata("design:type", String)
|
|
64
|
-
], SettingsTemplate.prototype, "valueString", void 0);
|
|
65
|
-
SettingsTemplate = __decorate([
|
|
66
|
-
MetaHeadInterface({
|
|
67
|
-
title: "Settings",
|
|
68
|
-
routes: {
|
|
69
|
-
crud: true,
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
], SettingsTemplate);
|
|
73
|
-
export { SettingsTemplate };
|
|
1
|
+
import { createDecorator, decoBoolean, decoDate, decoNumber, decoString, } from "@mxpicture/gcp-functions-common/decorator";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
const decorator = createDecorator(fileURLToPath(import.meta.url));
|
|
4
|
+
export const medication = decorator("Settings")
|
|
5
|
+
.title("Settings")
|
|
6
|
+
.namespace("picpad")
|
|
7
|
+
.lead()
|
|
8
|
+
.routesCrud()
|
|
9
|
+
.properties({
|
|
10
|
+
id: decoString()
|
|
11
|
+
.key()
|
|
12
|
+
.title("Example ID")
|
|
13
|
+
.hidden({ item: true }),
|
|
14
|
+
createDate: decoDate()
|
|
15
|
+
.optional()
|
|
16
|
+
.title("Created at")
|
|
17
|
+
.hidden({ item: true }),
|
|
18
|
+
updateTime: decoDate()
|
|
19
|
+
.optional()
|
|
20
|
+
.title("Update at")
|
|
21
|
+
.hidden({ item: true }),
|
|
22
|
+
active: decoBoolean()
|
|
23
|
+
.title("Active")
|
|
24
|
+
.default(true)
|
|
25
|
+
.editable(),
|
|
26
|
+
name: decoString().title("Name").default("").editable(),
|
|
27
|
+
type: decoString().title("Type").default("").editable(),
|
|
28
|
+
valueNumber: decoNumber()
|
|
29
|
+
.title("Number")
|
|
30
|
+
.optional()
|
|
31
|
+
.default(0)
|
|
32
|
+
.editable(),
|
|
33
|
+
valueString: decoString()
|
|
34
|
+
.title("String")
|
|
35
|
+
.optional()
|
|
36
|
+
.default("")
|
|
37
|
+
.editable(),
|
|
38
|
+
});
|
|
74
39
|
//# sourceMappingURL=template.settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.settings.js","sourceRoot":"","sources":["../../../src/4testing/templates/template.settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"template.settings.js","sourceRoot":"","sources":["../../../src/4testing/templates/template.settings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,GACX,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,eAAe,CAC/B,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;KAC5C,KAAK,CAAC,UAAU,CAAC;KACjB,SAAS,CAAC,QAAQ,CAAC;KACnB,IAAI,EAAE;KACN,UAAU,EAAE;KACZ,UAAU,CAAC;IACV,EAAE,EAAE,UAAU,EAAE;SACb,GAAG,EAAE;SACL,KAAK,CAAC,YAAY,CAAC;SACnB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzB,UAAU,EAAE,QAAQ,EAAE;SACnB,QAAQ,EAAE;SACV,KAAK,CAAC,YAAY,CAAC;SACnB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzB,UAAU,EAAE,QAAQ,EAAE;SACnB,QAAQ,EAAE;SACV,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACzB,MAAM,EAAE,WAAW,EAAE;SAClB,KAAK,CAAC,QAAQ,CAAC;SACf,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,EAAE;IACb,IAAI,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvD,IAAI,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACvD,WAAW,EAAE,UAAU,EAAE;SACtB,KAAK,CAAC,QAAQ,CAAC;SACf,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,EAAE;IACb,WAAW,EAAE,UAAU,EAAE;SACtB,KAAK,CAAC,QAAQ,CAAC;SACf,QAAQ,EAAE;SACV,OAAO,CAAC,EAAE,CAAC;SACX,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
package/dist/common/Barrel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecoTargetType } from "@mxpicture/gcp-functions-common/decorator";
|
|
2
2
|
export interface BarrelResult {
|
|
3
3
|
dirPath: string;
|
|
4
4
|
barrelFilePath: string;
|
|
@@ -10,12 +10,12 @@ export interface BarrelFileGroup {
|
|
|
10
10
|
filenames: string[];
|
|
11
11
|
}
|
|
12
12
|
export declare class Barrel {
|
|
13
|
-
readonly targetType:
|
|
13
|
+
readonly targetType: DecoTargetType;
|
|
14
14
|
static ignorePackageJson: boolean;
|
|
15
15
|
static instances: Barrel[];
|
|
16
16
|
protected filePaths: string[];
|
|
17
|
-
static instance(targetType:
|
|
18
|
-
protected constructor(targetType:
|
|
17
|
+
static instance(targetType: DecoTargetType): Barrel;
|
|
18
|
+
protected constructor(targetType: DecoTargetType);
|
|
19
19
|
add(...filePaths: string[]): void;
|
|
20
20
|
create(): BarrelResult[];
|
|
21
21
|
write(results: BarrelResult[]): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Barrel.d.ts","sourceRoot":"","sources":["../../src/common/Barrel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Barrel.d.ts","sourceRoot":"","sources":["../../src/common/Barrel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAG3E,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,qBAAa,MAAM;aAgBqB,UAAU,EAAE,cAAc;IAfhE,OAAc,iBAAiB,EAAE,OAAO,CAAS;IACjD,OAAc,SAAS,EAAE,MAAM,EAAE,CAAM;IACvC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;WAErB,QAAQ,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM;IAW1D,SAAS,aAA6B,UAAU,EAAE,cAAc;IAEzD,GAAG,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAIjC,MAAM,IAAI,YAAY,EAAE;IAUlB,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAc7C,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBzE,SAAS,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,eAAe,EAAE;CAsB7D"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MetaNames } from "@mxpicture/gcp-functions-common/types";
|
|
1
|
+
import { DecoNames, DecoTargetType } from "@mxpicture/gcp-functions-common/decorator";
|
|
3
2
|
export interface CollectorKey {
|
|
4
3
|
basename: string;
|
|
5
|
-
targetType:
|
|
4
|
+
targetType: DecoTargetType;
|
|
6
5
|
}
|
|
7
6
|
export interface CollectorData {
|
|
8
|
-
names:
|
|
7
|
+
names: DecoNames;
|
|
9
8
|
}
|
|
10
9
|
export interface CollectorItem {
|
|
11
10
|
key: CollectorKey;
|
|
@@ -15,8 +14,8 @@ export declare class Collector {
|
|
|
15
14
|
protected items: CollectorItem[];
|
|
16
15
|
static instance(): Collector;
|
|
17
16
|
constructor();
|
|
18
|
-
add(basename: string, targetType:
|
|
19
|
-
find(basename: string, targetType:
|
|
17
|
+
add(basename: string, targetType: DecoTargetType, data: CollectorData): void;
|
|
18
|
+
find(basename: string, targetType: DecoTargetType): CollectorItem | null;
|
|
20
19
|
findGeneric(name: string): CollectorItem[];
|
|
21
20
|
findFirst(name: string): CollectorItem | null;
|
|
22
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collector.d.ts","sourceRoot":"","sources":["../../src/common/Collector.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Collector.d.ts","sourceRoot":"","sources":["../../src/common/Collector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAET,cAAc,EACf,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,YAAY,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;CACrB;AAID,qBAAa,SAAS;IACpB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,CAAM;WAExB,QAAQ,IAAI,SAAS;;IAO5B,GAAG,CACR,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,aAAa,GAClB,IAAI;IAKA,IAAI,CACT,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,cAAc,GACzB,aAAa,GAAG,IAAI;IAShB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE;IAc1C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAIrD"}
|
package/dist/common/Collector.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decoNamesProperties, } from "@mxpicture/gcp-functions-common/decorator";
|
|
2
2
|
let __instance = null;
|
|
3
3
|
export class Collector {
|
|
4
4
|
items = [];
|
|
@@ -21,7 +21,7 @@ export class Collector {
|
|
|
21
21
|
for (const item of this.items) {
|
|
22
22
|
if (item.key.basename === name)
|
|
23
23
|
results.push(item);
|
|
24
|
-
for (const prop of
|
|
24
|
+
for (const prop of decoNamesProperties) {
|
|
25
25
|
if (item.data.names[prop] === name) {
|
|
26
26
|
results.push(item);
|
|
27
27
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collector.js","sourceRoot":"","sources":["../../src/common/Collector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Collector.js","sourceRoot":"","sources":["../../src/common/Collector.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,GAEpB,MAAM,2CAA2C,CAAC;AAgBnD,IAAI,UAAU,GAAqB,IAAI,CAAC;AAExC,MAAM,OAAO,SAAS;IACV,KAAK,GAAoB,EAAE,CAAC;IAE/B,MAAM,CAAC,QAAQ;QACpB,IAAI,CAAC,UAAU;YAAE,UAAU,GAAG,IAAI,SAAS,EAAE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CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DecoFileType, DecoTargetType } from "@mxpicture/gcp-functions-common/decorator";
|
|
2
2
|
export interface DirectoriesResolverParams {
|
|
3
|
-
targetType:
|
|
4
|
-
fileType:
|
|
3
|
+
targetType: DecoTargetType;
|
|
4
|
+
fileType: DecoFileType;
|
|
5
5
|
}
|
|
6
|
-
export type DirectoriesResolver = (imp: DirectoriesResolverParams, // e.g ${TargetType}/${
|
|
6
|
+
export type DirectoriesResolver = (imp: DirectoriesResolverParams, // e.g ${TargetType}/${DecoFileType} --> common/doc,
|
|
7
7
|
current: DirectoriesResolverParams) => string;
|
|
8
8
|
export interface DirectoriesParams {
|
|
9
9
|
cwd: string;
|
|
@@ -16,17 +16,17 @@ declare class Directories {
|
|
|
16
16
|
constructor();
|
|
17
17
|
setup(params: DirectoriesParams): void;
|
|
18
18
|
get templatesDir(): string;
|
|
19
|
-
targetDir(targetType:
|
|
20
|
-
targetBasePath(targetType:
|
|
21
|
-
toTargetPath(type:
|
|
22
|
-
targetPackageJson(targetType:
|
|
19
|
+
targetDir(targetType: DecoTargetType): string;
|
|
20
|
+
targetBasePath(targetType: DecoTargetType): string;
|
|
21
|
+
toTargetPath(type: DecoFileType, filename: string, targetType: DecoTargetType): string;
|
|
22
|
+
targetPackageJson(targetType: DecoTargetType): string;
|
|
23
23
|
templatesPathRead(): Promise<string[]>;
|
|
24
24
|
resolveImport(imp: {
|
|
25
|
-
targetType:
|
|
26
|
-
fileType:
|
|
25
|
+
targetType: DecoTargetType;
|
|
26
|
+
fileType: DecoFileType;
|
|
27
27
|
} | string, currentFile: {
|
|
28
|
-
targetType:
|
|
29
|
-
fileType:
|
|
28
|
+
targetType: DecoTargetType;
|
|
29
|
+
fileType: DecoFileType;
|
|
30
30
|
} | string): string;
|
|
31
31
|
splitResolverPath(path: string): DirectoriesResolverParams;
|
|
32
32
|
concatResolverPath(params: DirectoriesResolverParams): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Directories.d.ts","sourceRoot":"","sources":["../../src/common/Directories.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Directories.d.ts","sourceRoot":"","sources":["../../src/common/Directories.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,cAAc,EAGf,MAAM,2CAA2C,CAAC;AAGnD,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,GAAG,EAAE,yBAAyB,EAAE,oDAAoD;AACpF,OAAO,EAAE,yBAAyB,KAC/B,MAAM,CAAC;AAEZ,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,mBAAmB,CAAC;CACrC;AAQD,cAAM,WAAW;IACf,SAAS,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAQ;;IAI5C,KAAK,CAAC,MAAM,EAAE,iBAAiB;IAStC,IAAW,YAAY,IAAI,MAAM,CAEhC;IAEM,SAAS,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM;IAI7C,cAAc,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM;IAIlD,YAAY,CACjB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,cAAc;IAKrB,iBAAiB,CAAC,UAAU,EAAE,cAAc;IAItC,iBAAiB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM5C,aAAa,CAClB,GAAG,EAAE;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAA;KAAE,GAAG,MAAM,EACpE,WAAW,EACP;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,QAAQ,EAAE,YAAY,CAAA;KAAE,GACtD,MAAM,GACT,MAAM;IASF,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,yBAAyB;IAkB1D,kBAAkB,CAAC,MAAM,EAAE,yBAAyB,GAAG,MAAM;IAIpE,SAAS,KAAK,MAAM,IAAI,iBAAiB,CAGxC;CACF;AAED,eAAO,MAAM,WAAW,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
2
|
import { readdir } from "node:fs/promises";
|
|
3
|
-
import {
|
|
3
|
+
import { guardDecoFileType, guardDecoTargetType, } from "@mxpicture/gcp-functions-common/decorator";
|
|
4
4
|
import { isTemplateFile } from "./file.common.js";
|
|
5
5
|
let __instance = null;
|
|
6
6
|
const instance = () => {
|
|
@@ -47,12 +47,12 @@ class Directories {
|
|
|
47
47
|
splitResolverPath(path) {
|
|
48
48
|
const parts = path.split("/");
|
|
49
49
|
if (parts.length !== 2)
|
|
50
|
-
throw new Error(`${path} does not fit the pattern {TargetType}/{
|
|
50
|
+
throw new Error(`${path} does not fit the pattern {TargetType}/{DecoFileType}`);
|
|
51
51
|
const [_targetType, _fileType] = parts;
|
|
52
|
-
const fileType =
|
|
52
|
+
const fileType = guardDecoFileType(_fileType);
|
|
53
53
|
if (!fileType)
|
|
54
54
|
throw new Error(`${path}: fileType ${_fileType} invalid`);
|
|
55
|
-
const targetType =
|
|
55
|
+
const targetType = guardDecoTargetType(_targetType);
|
|
56
56
|
if (!targetType)
|
|
57
57
|
throw new Error(`${path}: targetType ${_targetType} invalid`);
|
|
58
58
|
return { targetType, fileType };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Directories.js","sourceRoot":"","sources":["../../src/common/Directories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WA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,GAAG,IAAI,cAAc,SAAS,UAAU,CAAC,CAAC;QAEzE,MAAM,UAAU,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,UAAU;YACb,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gBAAgB,WAAW,UAAU,CAAC,CAAC;QAEhE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;IAEM,kBAAkB,CAAC,MAAiC;QACzD,OAAO,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;IACnD,CAAC;IAED,IAAc,MAAM;QAClB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,EAAE,CAAC"}
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DocumentData } from "@mxpicture/gcp-functions-common/types";
|
|
3
|
-
import { CrudRouteName, MetaHeadData, MetaHeadDecorator, MetaHeadOptionsBase, MetaPropertyData, MetaPropertyDecorator, MetaPropertyOptionsBase } from "@mxpicture/gcp-functions-common/meta";
|
|
4
|
-
import type { MetaRouteParams, MetaHeadInterfaceOptions, MetaFile } from "@mxpicture/gcp-functions-common/types";
|
|
5
|
-
export type MetaHeadExtract = {
|
|
6
|
-
[K in keyof MetaHeadOptionsBase]: (property: ts.ClassDeclaration) => MetaHeadData | undefined;
|
|
7
|
-
};
|
|
8
|
-
export type MetaPropertyExtract = {
|
|
9
|
-
[K in keyof MetaPropertyOptionsBase]: (property: ts.PropertyDeclaration) => MetaPropertyData | undefined;
|
|
10
|
-
};
|
|
1
|
+
import { DecoFile } from "@mxpicture/gcp-functions-common/types";
|
|
11
2
|
export declare const createExtractors: (filePaths: string[]) => Promise<Extractor[]>;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const crudRoutes: (docName: string) => Record<CrudRouteName, MetaRouteParams>;
|
|
3
|
+
export declare const runExtractors: (filePaths: string[]) => Promise<DecoFile[]>;
|
|
14
4
|
export declare class Extractor {
|
|
15
5
|
readonly filePath: string;
|
|
16
|
-
readonly checker: ts.TypeChecker;
|
|
17
|
-
readonly sourceFile: ts.SourceFile;
|
|
18
6
|
readonly rootDir: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(filePath: string, checker: ts.TypeChecker, sourceFile: ts.SourceFile, rootDir: string);
|
|
22
|
-
run(): MetaFile;
|
|
23
|
-
header(main: ts.ClassDeclaration): MetaHeadData | undefined;
|
|
24
|
-
property(property: ts.PropertyDeclaration): MetaPropertyData | undefined;
|
|
25
|
-
protected buildPropertyExtr(): MetaPropertyExtract;
|
|
26
|
-
protected buildMainExtr(): MetaHeadExtract;
|
|
27
|
-
protected buildMainExtrRoutes(templateName: string, o: MetaHeadInterfaceOptions): Record<string, MetaRouteParams>;
|
|
28
|
-
protected findDecorator(modifiers: ts.NodeArray<ts.ModifierLike> | undefined, name: string): ts.Decorator | undefined;
|
|
29
|
-
protected extractType(property: ts.PropertyDeclaration): string;
|
|
30
|
-
protected extractProperty<K extends MetaPropertyDecorator, T extends MetaPropertyOptionsBase[K] = MetaPropertyOptionsBase[K]>(type: K, modifiers: ts.NodeArray<ts.ModifierLike> | undefined): T | undefined;
|
|
31
|
-
protected extractMain<K extends MetaHeadDecorator, T extends MetaHeadOptionsBase[K] = MetaHeadOptionsBase[K]>(type: K, modifiers: ts.NodeArray<ts.ModifierLike> | undefined): T | undefined;
|
|
32
|
-
protected extractAny<T extends DocumentData>(name: string, modifiers: ts.NodeArray<ts.ModifierLike> | undefined): T | undefined;
|
|
7
|
+
constructor(filePath: string, rootDir: string);
|
|
8
|
+
run(): Promise<DecoFile>;
|
|
33
9
|
}
|
|
34
10
|
//# sourceMappingURL=Extractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extractor.d.ts","sourceRoot":"","sources":["../../src/common/Extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Extractor.d.ts","sourceRoot":"","sources":["../../src/common/Extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAQjE,eAAO,MAAM,gBAAgB,GAC3B,WAAW,MAAM,EAAE,KAClB,OAAO,CAAC,SAAS,EAAE,CAGrB,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,WAAW,MAAM,EAAE,KAClB,OAAO,CAAC,QAAQ,EAAE,CAGpB,CAAC;AAEF,qBAAa,SAAS;aAEF,QAAQ,EAAE,MAAM;aAChB,OAAO,EAAE,MAAM;gBADf,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM;IAGpB,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;CAUtC"}
|
package/dist/common/Extractor.js
CHANGED
|
@@ -1,204 +1,30 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { Evaluate } from "./Evaluate.js";
|
|
3
|
-
import { metaRename } from "../meta/meta.names.js";
|
|
4
1
|
import { dirname, relative } from "node:path";
|
|
5
|
-
import { MetaFileType, MetaHeadType, metaMainOptionsMap, metaPropertyOptionsMap, } from "@mxpicture/gcp-functions-common/meta";
|
|
6
2
|
import { findWorkspaceRoot } from "@mxpicture/build-api/workspace";
|
|
7
3
|
import { fileURLToPath } from "node:url";
|
|
8
|
-
import {
|
|
4
|
+
import { Decorator } from "@mxpicture/gcp-functions-common/decorator";
|
|
9
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
6
|
export const createExtractors = async (filePaths) => {
|
|
11
7
|
const rootDir = (await findWorkspaceRoot(__dirname)).dirPath;
|
|
12
|
-
return
|
|
8
|
+
return filePaths.map((filePath) => new Extractor(filePath, rootDir));
|
|
9
|
+
};
|
|
10
|
+
export const runExtractors = async (filePaths) => {
|
|
11
|
+
const exs = await createExtractors(filePaths);
|
|
12
|
+
return Promise.all(exs.map((ex) => ex.run()));
|
|
13
13
|
};
|
|
14
|
-
export const extractFiles = (extractors) => extractors.map((extractor) => extractor.run());
|
|
15
|
-
export const crudRoutes = (docName) => ({
|
|
16
|
-
create: {
|
|
17
|
-
requestType: `WithoutKey<${docName}>`,
|
|
18
|
-
responseType: `WithKey<${docName}>`,
|
|
19
|
-
},
|
|
20
|
-
update: {
|
|
21
|
-
requestType: `WithKey<Partial<${docName}>>`,
|
|
22
|
-
responseType: `WithKey<${docName}>`,
|
|
23
|
-
},
|
|
24
|
-
delete: { requestType: "DocumentKey", responseType: "{ deleted: true }" },
|
|
25
|
-
get: { requestType: "DocumentKey", responseType: `WithKey<${docName}>` },
|
|
26
|
-
query: {
|
|
27
|
-
requestType: "ApiFilter | undefined | null | never",
|
|
28
|
-
responseType: `WithKey<${docName}>[]`,
|
|
29
|
-
},
|
|
30
|
-
count: {
|
|
31
|
-
requestType: "ApiFilter | undefined | null | never",
|
|
32
|
-
responseType: "{ count: number }",
|
|
33
|
-
},
|
|
34
|
-
exists: { requestType: "DocumentKey", responseType: "{ exists: boolean }" },
|
|
35
|
-
});
|
|
36
14
|
export class Extractor {
|
|
37
15
|
filePath;
|
|
38
|
-
checker;
|
|
39
|
-
sourceFile;
|
|
40
16
|
rootDir;
|
|
41
|
-
|
|
42
|
-
mainExtr;
|
|
43
|
-
constructor(filePath, checker, sourceFile, rootDir) {
|
|
17
|
+
constructor(filePath, rootDir) {
|
|
44
18
|
this.filePath = filePath;
|
|
45
|
-
this.checker = checker;
|
|
46
|
-
this.sourceFile = sourceFile;
|
|
47
19
|
this.rootDir = rootDir;
|
|
48
|
-
this.propertyExtr = this.buildPropertyExtr();
|
|
49
|
-
this.mainExtr = this.buildMainExtr();
|
|
50
20
|
}
|
|
51
|
-
run() {
|
|
52
|
-
const
|
|
21
|
+
async run() {
|
|
22
|
+
const imported = await import(this.filePath);
|
|
23
|
+
return {
|
|
53
24
|
templateFilePath: this.filePath,
|
|
54
25
|
templateRepoFilePath: relative(this.rootDir, this.filePath),
|
|
55
|
-
|
|
26
|
+
decorators: Object.values(imported).filter((v) => v instanceof Decorator),
|
|
56
27
|
};
|
|
57
|
-
ts.forEachChild(this.sourceFile, (node) => {
|
|
58
|
-
if (!ts.isClassDeclaration(node))
|
|
59
|
-
return;
|
|
60
|
-
const header = this.header(node);
|
|
61
|
-
if (!header)
|
|
62
|
-
return;
|
|
63
|
-
for (const member of node.members) {
|
|
64
|
-
if (!ts.isPropertyDeclaration(member) || !member.type)
|
|
65
|
-
continue;
|
|
66
|
-
const prop = this.property(member);
|
|
67
|
-
if (!prop)
|
|
68
|
-
continue;
|
|
69
|
-
header.properties.push(prop);
|
|
70
|
-
}
|
|
71
|
-
result.headers.push(header);
|
|
72
|
-
});
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
header(main) {
|
|
76
|
-
for (const opt of Object.values(this.mainExtr)) {
|
|
77
|
-
const res = opt(main);
|
|
78
|
-
if (res)
|
|
79
|
-
return res;
|
|
80
|
-
}
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
property(property) {
|
|
84
|
-
for (const opt of Object.values(this.propertyExtr)) {
|
|
85
|
-
const res = opt(property);
|
|
86
|
-
if (res)
|
|
87
|
-
return res;
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
buildPropertyExtr() {
|
|
92
|
-
const opts = {};
|
|
93
|
-
for (const _key of Object.keys(metaPropertyOptionsMap)) {
|
|
94
|
-
const decoratorType = _key;
|
|
95
|
-
opts[decoratorType] = (property) => {
|
|
96
|
-
const o = this.extractProperty(decoratorType, property.modifiers);
|
|
97
|
-
if (!o)
|
|
98
|
-
return;
|
|
99
|
-
const res = {
|
|
100
|
-
...o,
|
|
101
|
-
[decoratorType]: o,
|
|
102
|
-
propertyKey: property.name.getText(this.sourceFile),
|
|
103
|
-
propertyType: this.extractType(property),
|
|
104
|
-
type: metaPropertyOptionsMap[decoratorType],
|
|
105
|
-
};
|
|
106
|
-
return res;
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return opts;
|
|
110
|
-
}
|
|
111
|
-
buildMainExtr() {
|
|
112
|
-
const opts = {};
|
|
113
|
-
for (const _key of Object.keys(metaMainOptionsMap)) {
|
|
114
|
-
const decoratorType = _key;
|
|
115
|
-
opts[decoratorType] = (cls) => {
|
|
116
|
-
const o = this.extractMain(decoratorType, cls.modifiers);
|
|
117
|
-
if (!o)
|
|
118
|
-
return;
|
|
119
|
-
const templateName = cls.name?.text ?? "<anonymous>";
|
|
120
|
-
o.type = metaMainOptionsMap[decoratorType];
|
|
121
|
-
let routes = {};
|
|
122
|
-
let additionalImports = undefined;
|
|
123
|
-
let namespace = undefined;
|
|
124
|
-
if (o.type === MetaHeadType.mainInterface) {
|
|
125
|
-
routes = this.buildMainExtrRoutes(templateName, o);
|
|
126
|
-
additionalImports = o.additionalImports;
|
|
127
|
-
namespace = o.namespace;
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
...o,
|
|
131
|
-
templateName,
|
|
132
|
-
inputFilePath: this.filePath,
|
|
133
|
-
repoInputFilePath: relative(this.rootDir, this.filePath),
|
|
134
|
-
properties: [],
|
|
135
|
-
routes,
|
|
136
|
-
additionalImports,
|
|
137
|
-
namespace,
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
return opts;
|
|
142
|
-
}
|
|
143
|
-
buildMainExtrRoutes(templateName, o) {
|
|
144
|
-
const routes = {};
|
|
145
|
-
for (const [routeName, _params] of Object.entries(o.routes)) {
|
|
146
|
-
if (typeof _params === "object") {
|
|
147
|
-
const params = _params;
|
|
148
|
-
routes[routeName] = { ...params };
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
// crud
|
|
152
|
-
if (typeof _params === "boolean" && _params) {
|
|
153
|
-
for (const [routeName, params] of Object.entries(crudRoutes(metaRename(templateName, MetaFileType.doc))))
|
|
154
|
-
routes[routeName] = { ...params };
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return routes;
|
|
159
|
-
}
|
|
160
|
-
findDecorator(modifiers, name) {
|
|
161
|
-
return modifiers?.find((m) => {
|
|
162
|
-
if (!ts.isDecorator(m))
|
|
163
|
-
return false;
|
|
164
|
-
const expr = m.expression;
|
|
165
|
-
// bare identifier: @Track
|
|
166
|
-
if (ts.isIdentifier(expr) && expr.text === name)
|
|
167
|
-
return true;
|
|
168
|
-
// call expression: @Tracked("...")
|
|
169
|
-
if (ts.isCallExpression(expr) &&
|
|
170
|
-
ts.isIdentifier(expr.expression) &&
|
|
171
|
-
expr.expression.text === name)
|
|
172
|
-
return true;
|
|
173
|
-
return false;
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
extractType(property) {
|
|
177
|
-
return property.type
|
|
178
|
-
? this.checker.typeToString(this.checker.getTypeFromTypeNode(property.type))
|
|
179
|
-
: "unknown";
|
|
180
|
-
}
|
|
181
|
-
extractProperty(type, modifiers) {
|
|
182
|
-
return this.extractAny(type, modifiers);
|
|
183
|
-
}
|
|
184
|
-
extractMain(type, modifiers) {
|
|
185
|
-
return this.extractAny(type, modifiers);
|
|
186
|
-
}
|
|
187
|
-
extractAny(name, modifiers) {
|
|
188
|
-
const decorator = this.findDecorator(modifiers, name);
|
|
189
|
-
if (!decorator)
|
|
190
|
-
return;
|
|
191
|
-
const expr = decorator.expression;
|
|
192
|
-
if (!ts.isCallExpression(expr) || expr.arguments.length === 0)
|
|
193
|
-
return;
|
|
194
|
-
const first = expr.arguments[0];
|
|
195
|
-
const e = new Evaluate(this.checker);
|
|
196
|
-
// If it's already an object literal, evaluate to a plain object
|
|
197
|
-
if (ts.isObjectLiteralExpression(first))
|
|
198
|
-
return e.run(first);
|
|
199
|
-
// If it's an identifier / enum / referenced const, try to resolve it to a value
|
|
200
|
-
const resolved = e.run(first);
|
|
201
|
-
return typeof resolved === "object" ? resolved : undefined;
|
|
202
28
|
}
|
|
203
29
|
}
|
|
204
30
|
//# sourceMappingURL=Extractor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extractor.js","sourceRoot":"","sources":["../../src/common/Extractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Extractor.js","sourceRoot":"","sources":["../../src/common/Extractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAEtE,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,SAAmB,EACG,EAAE;IACxB,MAAM,OAAO,GAAG,CAAC,MAAM,iBAAiB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7D,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,SAAmB,EACE,EAAE;IACvB,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,OAAO,SAAS;IAEF;IACA;IAFlB,YACkB,QAAgB,EAChB,OAA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