@superblocksteam/util 1.9.3 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resource-configs.d.ts +21 -7
- package/dist/resource-configs.js +18 -1
- package/package.json +1 -1
- package/src/resource-configs.ts +49 -12
|
@@ -6,21 +6,34 @@ export type VersionedResourceConfig = {
|
|
|
6
6
|
location: string;
|
|
7
7
|
resourceType: SuperblocksResourceType;
|
|
8
8
|
};
|
|
9
|
+
export type SuperblocksResourceConfigMetadata = {
|
|
10
|
+
fileVersion?: string;
|
|
11
|
+
};
|
|
9
12
|
export type SuperblocksResourceConfig = {
|
|
10
13
|
id: string;
|
|
14
|
+
metadata?: SuperblocksResourceConfigMetadata;
|
|
11
15
|
};
|
|
12
|
-
export type SuperblocksBackendConfig = SuperblocksResourceConfig & {
|
|
16
|
+
export type SuperblocksBackendConfig = SuperblocksResourceConfig & SourceFilesContanier & {
|
|
13
17
|
configType: "BACKEND";
|
|
14
18
|
};
|
|
15
19
|
export type SuperblocksApplicationConfig = SuperblocksResourceConfig & {
|
|
16
20
|
configType: "APPLICATION";
|
|
17
21
|
defaultPageId?: string;
|
|
18
|
-
apis
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
apis?: Record<string, string>;
|
|
23
|
+
appApis?: Record<string, ApiInfo>;
|
|
24
|
+
pages?: Record<string, PageInfo>;
|
|
25
|
+
};
|
|
26
|
+
export type PageInfo = {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
apis?: Record<string, string>;
|
|
30
|
+
pageApis?: Record<string, ApiInfo>;
|
|
31
|
+
};
|
|
32
|
+
export type SourceFilesContanier = {
|
|
33
|
+
sourceFiles?: string[];
|
|
34
|
+
};
|
|
35
|
+
export type ApiInfo = SourceFilesContanier & {
|
|
36
|
+
name: string;
|
|
24
37
|
};
|
|
25
38
|
export type SuperblocksMonorepoConfig = {
|
|
26
39
|
configType: "ROOT";
|
|
@@ -35,5 +48,6 @@ export type SuperblocksConfig = SuperblocksMonorepoConfig | SuperblocksApplicati
|
|
|
35
48
|
export declare function getSuperblocksMonorepoConfigJson(checkParentDir?: boolean, pathPrefix?: string): Promise<[SuperblocksMonorepoConfig, string]>;
|
|
36
49
|
export declare function getSuperblocksApplicationConfigJson(applicationPath?: string): Promise<SuperblocksApplicationConfig>;
|
|
37
50
|
export declare function getSuperblocksApplicationConfigIfExists(applicationPath: string): Promise<SuperblocksApplicationConfig | undefined>;
|
|
51
|
+
export declare function getSuperblocksBackendConfigIfExists(backendPath: string): Promise<SuperblocksBackendConfig | undefined>;
|
|
38
52
|
export declare function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig>;
|
|
39
53
|
export declare function getSuperblocksResourceConfigIfExists(): Promise<SuperblocksResourceConfig | undefined>;
|
package/dist/resource-configs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigIfExists = exports.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
3
|
+
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksBackendConfigIfExists = exports.getSuperblocksApplicationConfigIfExists = exports.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
@@ -76,6 +76,23 @@ async function getSuperblocksApplicationConfigIfExists(applicationPath) {
|
|
|
76
76
|
return superblocksConfig;
|
|
77
77
|
}
|
|
78
78
|
exports.getSuperblocksApplicationConfigIfExists = getSuperblocksApplicationConfigIfExists;
|
|
79
|
+
async function getSuperblocksBackendConfigIfExists(backendPath) {
|
|
80
|
+
let superblocksConfig;
|
|
81
|
+
try {
|
|
82
|
+
const configPath = backendPath
|
|
83
|
+
? path_1.default.join(backendPath, constants_1.RESOURCE_CONFIG_PATH)
|
|
84
|
+
: constants_1.RESOURCE_CONFIG_PATH;
|
|
85
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// no superblocks config file found
|
|
89
|
+
}
|
|
90
|
+
if ((superblocksConfig === null || superblocksConfig === void 0 ? void 0 : superblocksConfig.configType) !== "BACKEND") {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return superblocksConfig;
|
|
94
|
+
}
|
|
95
|
+
exports.getSuperblocksBackendConfigIfExists = getSuperblocksBackendConfigIfExists;
|
|
79
96
|
async function getSuperblocksBackendConfigJson() {
|
|
80
97
|
let superblocksConfig;
|
|
81
98
|
try {
|
package/package.json
CHANGED
package/src/resource-configs.ts
CHANGED
|
@@ -13,26 +13,43 @@ export type VersionedResourceConfig = {
|
|
|
13
13
|
resourceType: SuperblocksResourceType;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export type SuperblocksResourceConfigMetadata = {
|
|
17
|
+
fileVersion?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
16
20
|
export type SuperblocksResourceConfig = {
|
|
17
21
|
id: string;
|
|
22
|
+
metadata?: SuperblocksResourceConfigMetadata;
|
|
18
23
|
};
|
|
19
24
|
|
|
20
|
-
export type SuperblocksBackendConfig = SuperblocksResourceConfig &
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
export type SuperblocksBackendConfig = SuperblocksResourceConfig &
|
|
26
|
+
SourceFilesContanier & {
|
|
27
|
+
configType: "BACKEND";
|
|
28
|
+
};
|
|
23
29
|
|
|
24
30
|
export type SuperblocksApplicationConfig = SuperblocksResourceConfig & {
|
|
25
31
|
configType: "APPLICATION";
|
|
26
32
|
defaultPageId?: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// @deprecated use pageApis appApis for new format
|
|
34
|
+
apis?: Record<string, string>; // used for pre-0.2.0 format
|
|
35
|
+
appApis?: Record<string, ApiInfo>; // used for 0.2.0+ format
|
|
36
|
+
pages?: Record<string, PageInfo>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type PageInfo = {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
// @deprecated use pageApis instead
|
|
43
|
+
apis?: Record<string, string>; // used for pre-0.2.0 format
|
|
44
|
+
pageApis?: Record<string, ApiInfo>; // used for 0.2.0+ format
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type SourceFilesContanier = {
|
|
48
|
+
sourceFiles?: string[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type ApiInfo = SourceFilesContanier & {
|
|
52
|
+
name: string;
|
|
36
53
|
};
|
|
37
54
|
|
|
38
55
|
export type SuperblocksMonorepoConfig = {
|
|
@@ -137,6 +154,26 @@ export async function getSuperblocksApplicationConfigIfExists(
|
|
|
137
154
|
return superblocksConfig as SuperblocksApplicationConfig;
|
|
138
155
|
}
|
|
139
156
|
|
|
157
|
+
export async function getSuperblocksBackendConfigIfExists(
|
|
158
|
+
backendPath: string
|
|
159
|
+
): Promise<SuperblocksBackendConfig | undefined> {
|
|
160
|
+
let superblocksConfig: SuperblocksBackendConfig | undefined;
|
|
161
|
+
try {
|
|
162
|
+
const configPath = backendPath
|
|
163
|
+
? path.join(backendPath, RESOURCE_CONFIG_PATH)
|
|
164
|
+
: RESOURCE_CONFIG_PATH;
|
|
165
|
+
superblocksConfig = await fs.readJSON(configPath);
|
|
166
|
+
} catch {
|
|
167
|
+
// no superblocks config file found
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (superblocksConfig?.configType !== "BACKEND") {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return superblocksConfig as SuperblocksBackendConfig;
|
|
175
|
+
}
|
|
176
|
+
|
|
140
177
|
export async function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig> {
|
|
141
178
|
let superblocksConfig;
|
|
142
179
|
try {
|