@superblocksteam/util 1.99.99-next.3 → 2.0.0-SNAPSHOT.5a741e4af7fbfccb
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.js +1 -0
- package/{eslint.config.js → eslint.config.mjs} +26 -42
- package/lint-staged.config.mjs +6 -0
- package/package.json +22 -22
- package/src/api-files/api.mts +4 -2
- package/src/api-files/index.ts +7 -0
- package/src/api-files/types.ts +11 -14
- package/src/component-configs.ts +5 -3
- package/src/constants.ts +1 -15
- package/src/data-types.ts +1 -15
- package/src/file-uploader.test.ts +69 -0
- package/src/file-uploader.ts +26 -12
- package/src/index.ts +1 -0
- package/src/login.ts +24 -8
- package/src/mask-unix-signals.ts +1 -1
- package/src/resource-configs.ts +68 -5
- package/src/token-manager.ts +26 -0
- package/src/types.ts +5 -4
- package/src/validation.ts +4 -4
- package/tsconfig.json +3 -2
- package/turbo.json +9 -0
- package/vitest.config.ts +7 -0
- package/.prettierrc +0 -18
- package/dist/api-files/api.d.mts +0 -7
- package/dist/api-files/api.d.mts.map +0 -1
- package/dist/api-files/api.mjs +0 -262
- package/dist/api-files/api.mjs.map +0 -1
- package/dist/api-files/constants.d.ts +0 -6
- package/dist/api-files/constants.d.ts.map +0 -1
- package/dist/api-files/constants.js +0 -9
- package/dist/api-files/constants.js.map +0 -1
- package/dist/api-files/index.d.ts +0 -7
- package/dist/api-files/index.d.ts.map +0 -1
- package/dist/api-files/index.js +0 -13
- package/dist/api-files/index.js.map +0 -1
- package/dist/api-files/types.d.ts +0 -117
- package/dist/api-files/types.d.ts.map +0 -1
- package/dist/api-files/types.js +0 -17
- package/dist/api-files/types.js.map +0 -1
- package/dist/component-configs.d.ts +0 -6
- package/dist/component-configs.d.ts.map +0 -1
- package/dist/component-configs.js +0 -178
- package/dist/component-configs.js.map +0 -1
- package/dist/constants.d.ts +0 -18
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -50
- package/dist/constants.js.map +0 -1
- package/dist/data-types.d.ts +0 -10
- package/dist/data-types.d.ts.map +0 -1
- package/dist/data-types.js +0 -32
- package/dist/data-types.js.map +0 -1
- package/dist/events.d.ts +0 -13
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -17
- package/dist/events.js.map +0 -1
- package/dist/file-uploader.d.ts +0 -3
- package/dist/file-uploader.d.ts.map +0 -1
- package/dist/file-uploader.js +0 -28
- package/dist/file-uploader.js.map +0 -1
- package/dist/generate-component-types.d.ts +0 -3
- package/dist/generate-component-types.d.ts.map +0 -1
- package/dist/generate-component-types.js +0 -45
- package/dist/generate-component-types.js.map +0 -1
- package/dist/identifiers.d.ts +0 -9
- package/dist/identifiers.d.ts.map +0 -1
- package/dist/identifiers.js +0 -68
- package/dist/identifiers.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/localGitRepoState.d.ts +0 -20
- package/dist/localGitRepoState.d.ts.map +0 -1
- package/dist/localGitRepoState.js +0 -3
- package/dist/localGitRepoState.js.map +0 -1
- package/dist/login.d.ts +0 -11
- package/dist/login.d.ts.map +0 -1
- package/dist/login.js +0 -93
- package/dist/login.js.map +0 -1
- package/dist/mask-unix-signals.d.ts +0 -27
- package/dist/mask-unix-signals.d.ts.map +0 -1
- package/dist/mask-unix-signals.js +0 -81
- package/dist/mask-unix-signals.js.map +0 -1
- package/dist/resource-configs.d.ts +0 -61
- package/dist/resource-configs.d.ts.map +0 -1
- package/dist/resource-configs.js +0 -217
- package/dist/resource-configs.js.map +0 -1
- package/dist/types.d.ts +0 -105
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/unreachable.d.ts +0 -2
- package/dist/unreachable.d.ts.map +0 -1
- package/dist/unreachable.js +0 -7
- package/dist/unreachable.js.map +0 -1
- package/dist/validation.d.ts +0 -5
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -152
- package/dist/validation.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -8
package/dist/identifiers.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.suggestIdentifier = suggestIdentifier;
|
|
4
|
-
exports.isValidIdentifier = isValidIdentifier;
|
|
5
|
-
exports.isReservedPropertyName = isReservedPropertyName;
|
|
6
|
-
// convert a string to upper camel case, e.g. "123 & this is my component, foo-bar" -> "123ThisIsMyComponentFooBar"
|
|
7
|
-
function wordsToUpperCamelCase(str) {
|
|
8
|
-
return str
|
|
9
|
-
.split(/[^A-Za-z0-9_]+/)
|
|
10
|
-
.filter(Boolean)
|
|
11
|
-
.map((word) => word[0].toUpperCase() + word.slice(1))
|
|
12
|
-
.join("");
|
|
13
|
-
}
|
|
14
|
-
const digits = "Zero One Two Three Four Five Six Seven Eight Nine".split(" ");
|
|
15
|
-
// convert digits to words, e.g. "123" -> "OneTwoThree"
|
|
16
|
-
function digitsToWords(str) {
|
|
17
|
-
return str.replace(/\d/g, (char) => digits[parseInt(char, 10)] ?? char);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Suggest an identifier based on a label, e.g. `My Component` -> `myComponent`.
|
|
21
|
-
* @param label The label to suggest an identifier for.
|
|
22
|
-
* @param capitalizeFirst Whether to capitalize the first letter of the identifier.
|
|
23
|
-
*/
|
|
24
|
-
function suggestIdentifier(label, capitalizeFirst = false) {
|
|
25
|
-
const upperCamelCase = wordsToUpperCamelCase(label)
|
|
26
|
-
// convert any digits at the start of the string to words as these are not valid in identifiers
|
|
27
|
-
.replace(/^\d+/, digitsToWords);
|
|
28
|
-
if (capitalizeFirst) {
|
|
29
|
-
return upperCamelCase;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return upperCamelCase[0].toLowerCase() + upperCamelCase.slice(1);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const IdentifierRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
36
|
-
function isValidIdentifier(str) {
|
|
37
|
-
return IdentifierRegex.test(str);
|
|
38
|
-
}
|
|
39
|
-
const reservedPropertyNames = new Set([
|
|
40
|
-
"ENTITY_TYPE",
|
|
41
|
-
"bindingPaths",
|
|
42
|
-
"bottomRow",
|
|
43
|
-
"dynamicBindingPathList",
|
|
44
|
-
"dynamicTriggerPathList",
|
|
45
|
-
"gridColumns",
|
|
46
|
-
"gridRows",
|
|
47
|
-
"height",
|
|
48
|
-
"isLoading",
|
|
49
|
-
"isVisible",
|
|
50
|
-
"leftColumn",
|
|
51
|
-
"parentId",
|
|
52
|
-
"rightColumn",
|
|
53
|
-
"snapColumns",
|
|
54
|
-
"snapRows",
|
|
55
|
-
"top",
|
|
56
|
-
"topRow",
|
|
57
|
-
"type",
|
|
58
|
-
"widgetId",
|
|
59
|
-
"widgetLastChange",
|
|
60
|
-
"widgetName",
|
|
61
|
-
"width",
|
|
62
|
-
]);
|
|
63
|
-
function isReservedPropertyName(str) {
|
|
64
|
-
return (reservedPropertyNames.has(str) ||
|
|
65
|
-
// also treat any property name starting with "default_" as reserved since we use this prefix for default properties
|
|
66
|
-
str.startsWith("default_"));
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=identifiers.js.map
|
package/dist/identifiers.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../src/identifiers.ts"],"names":[],"mappings":";;AAqBA,8CASC;AAID,8CAEC;AA2BD,wDAMC;AArED,mHAAmH;AACnH,SAAS,qBAAqB,CAAC,GAAW;IACxC,OAAO,GAAG;SACP,KAAK,CAAC,gBAAgB,CAAC;SACvB,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,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CAAC,GAAW;IAChD,OAAO,CACL,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC;QAC9B,oHAAoH;QACpH,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from "./constants.js";
|
|
2
|
-
export * from "./component-configs.js";
|
|
3
|
-
export * from "./events.js";
|
|
4
|
-
export * from "./file-uploader.js";
|
|
5
|
-
export * from "./login.js";
|
|
6
|
-
export * from "./resource-configs.js";
|
|
7
|
-
export * from "./data-types.js";
|
|
8
|
-
export * from "./types.js";
|
|
9
|
-
export * from "./identifiers.js";
|
|
10
|
-
export * from "./localGitRepoState.js";
|
|
11
|
-
export * from "./unreachable.js";
|
|
12
|
-
export * from "./api-files/types.js";
|
|
13
|
-
export * from "./api-files/index.js";
|
|
14
|
-
export * from "./api-files/constants.js";
|
|
15
|
-
export * from "./mask-unix-signals.js";
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,yDAAuC;AACvC,8CAA4B;AAC5B,qDAAmC;AACnC,6CAA2B;AAC3B,wDAAsC;AACtC,kDAAgC;AAChC,6CAA2B;AAC3B,mDAAiC;AACjC,yDAAuC;AACvC,mDAAiC;AACjC,uDAAqC;AACrC,uDAAqC;AACrC,2DAAyC;AACzC,yDAAuC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ComponentEvent } from "./events.js";
|
|
2
|
-
export type LocalGitRepoState = {
|
|
3
|
-
status: "NO_GIT";
|
|
4
|
-
} | {
|
|
5
|
-
status: "DETACHED";
|
|
6
|
-
} | {
|
|
7
|
-
status: "IN_A_BRANCH";
|
|
8
|
-
localBranchName: string;
|
|
9
|
-
upstream?: {
|
|
10
|
-
remoteName: string;
|
|
11
|
-
url: string;
|
|
12
|
-
pushUrl?: string | null;
|
|
13
|
-
branchName: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export interface ValidateGitSetupRequestBody {
|
|
17
|
-
gitState: LocalGitRepoState;
|
|
18
|
-
event?: ComponentEvent;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=localGitRepoState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localGitRepoState.d.ts","sourceRoot":"","sources":["../src/localGitRepoState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GACtB;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEN,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localGitRepoState.js","sourceRoot":"","sources":["../src/localGitRepoState.ts"],"names":[],"mappings":""}
|
package/dist/login.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type BaseUrl = {
|
|
2
|
-
superblocksBaseUrl: string;
|
|
3
|
-
};
|
|
4
|
-
type TokenWithBaseUrl = BaseUrl & {
|
|
5
|
-
token: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function saveApiToken(superblocksBaseUrl: string, token?: string): Promise<void>;
|
|
8
|
-
export declare function getLocalTokenWithUrlIfExists(): Promise<TokenWithBaseUrl | BaseUrl | undefined>;
|
|
9
|
-
export declare function getLocalTokenWithUrl(): Promise<TokenWithBaseUrl | BaseUrl>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=login.d.ts.map
|
package/dist/login.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAKA,KAAK,OAAO,GAAG;IACb,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,KAAK,gBAAgB,GAAG,OAAO,GAAG;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAsB,YAAY,CAAC,kBAAkB,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,iBAkB5E;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAC3D,gBAAgB,GAAG,OAAO,GAAG,SAAS,CACvC,CAMA;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CACnD,gBAAgB,GAAG,OAAO,CAC3B,CAoBA"}
|
package/dist/login.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.saveApiToken = saveApiToken;
|
|
37
|
-
exports.getLocalTokenWithUrlIfExists = getLocalTokenWithUrlIfExists;
|
|
38
|
-
exports.getLocalTokenWithUrl = getLocalTokenWithUrl;
|
|
39
|
-
const node_os_1 = require("node:os");
|
|
40
|
-
const node_path_1 = require("node:path");
|
|
41
|
-
const fs = __importStar(require("fs-extra"));
|
|
42
|
-
const constants_js_1 = require("./constants.js");
|
|
43
|
-
async function saveApiToken(superblocksBaseUrl, token) {
|
|
44
|
-
try {
|
|
45
|
-
await fs.ensureDir((0, node_path_1.join)((0, node_os_1.homedir)(), ".superblocks"));
|
|
46
|
-
if (token) {
|
|
47
|
-
const tokenConfig = {
|
|
48
|
-
superblocksBaseUrl,
|
|
49
|
-
token,
|
|
50
|
-
};
|
|
51
|
-
await fs.writeJSON((0, node_path_1.join)((0, node_os_1.homedir)(), constants_js_1.TOKEN_CONFIG_PATH), tokenConfig);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
const tokenConfig = {
|
|
55
|
-
superblocksBaseUrl,
|
|
56
|
-
};
|
|
57
|
-
await fs.writeJSON((0, node_path_1.join)((0, node_os_1.homedir)(), constants_js_1.TOKEN_CONFIG_PATH), tokenConfig);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
throw new constants_js_1.FileAccessError("Could not save token");
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async function getLocalTokenWithUrlIfExists() {
|
|
65
|
-
try {
|
|
66
|
-
return await getLocalTokenWithUrl();
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return undefined;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function getLocalTokenWithUrl() {
|
|
73
|
-
try {
|
|
74
|
-
const tokenConfig = await fs.readJSON(process.env.SUPERBLOCKS_AUTH_FILE || (0, node_path_1.join)((0, node_os_1.homedir)(), constants_js_1.TOKEN_CONFIG_PATH));
|
|
75
|
-
if (tokenConfig.token) {
|
|
76
|
-
// user logged in
|
|
77
|
-
return {
|
|
78
|
-
token: tokenConfig.token,
|
|
79
|
-
superblocksBaseUrl: tokenConfig.superblocksBaseUrl,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// user not logged in, but set domain
|
|
84
|
-
return {
|
|
85
|
-
superblocksBaseUrl: tokenConfig.superblocksBaseUrl,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
throw new Error("No local API key found");
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=login.js.map
|
package/dist/login.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,oCAkBC;AAED,oEAQC;AAED,oDAsBC;AAjED,qCAAkC;AAClC,yCAAiC;AACjC,6CAA+B;AAC/B,iDAAoE;AAU7D,KAAK,UAAU,YAAY,CAAC,kBAA0B,EAAE,KAAc;IAC3E,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,SAAS,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,cAAc,CAAC,CAAC,CAAC;QACpD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,WAAW,GAAqB;gBACpC,kBAAkB;gBAClB,KAAK;aACN,CAAC;YACF,MAAM,EAAE,CAAC,SAAS,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,gCAAiB,CAAC,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;aAAM,CAAC;YACN,MAAM,WAAW,GAAY;gBAC3B,kBAAkB;aACnB,CAAC;YACF,MAAM,EAAE,CAAC,SAAS,CAAC,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,gCAAiB,CAAC,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,8BAAe,CAAC,sBAAsB,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,4BAA4B;IAGhD,IAAI,CAAC;QACH,OAAO,MAAM,oBAAoB,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,oBAAoB;IAGxC,IAAI,CAAC;QACH,MAAM,WAAW,GAAqB,MAAM,EAAE,CAAC,QAAQ,CACrD,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,gCAAiB,CAAC,CACxE,CAAC;QACF,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;YACtB,iBAAiB;YACjB,OAAO;gBACL,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;aACnD,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,qCAAqC;YACrC,OAAO;gBACL,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;aACnD,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type ActionResult<T> = {
|
|
2
|
-
success: true;
|
|
3
|
-
returnValue: T;
|
|
4
|
-
} | {
|
|
5
|
-
success: false;
|
|
6
|
-
error: unknown;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Runs an action with some unix signals being masked. This is useful for actions that should not be interrupted and need
|
|
10
|
-
* to be allowed to complete or perform some cleanup. If a signal is received, the action will be notified that it should
|
|
11
|
-
* abort via the `AbortSignal` that is passed to it. The action may or may not choose to abort immediately. The cleanup
|
|
12
|
-
* action is called after the main action and this happens unconditionally, i.e. regardless of whether a signal was received,
|
|
13
|
-
* the main action threw an error, or the main action returned a value. The cleanup action is passed the abort signal and the
|
|
14
|
-
* error (if any) that was thrown by the main action. If a signal was received, the process will exit after the cleanup
|
|
15
|
-
* action has completed. If the main action threw an error, that error will be thrown again. Otherwise, the main action's
|
|
16
|
-
* return value is returned. This function can be thought of as a (unix) signal aware version of `try { … } finally { … }`
|
|
17
|
-
* and `try { … } catch { … } catch { … }`.
|
|
18
|
-
*
|
|
19
|
-
* *Note*: This function registers listeners for some unix signals, so it affects the global behavior of the process. Be
|
|
20
|
-
* careful when using this function in a library.
|
|
21
|
-
*
|
|
22
|
-
* @param action - The main action to execute.
|
|
23
|
-
* @param cleanup - An optional cleanup action to execute when the process is aborted.
|
|
24
|
-
* @returns The result of the `action`.
|
|
25
|
-
*/
|
|
26
|
-
export declare function maskUnixSignals<T>(action: (aborted: AbortSignal) => Promise<T>, cleanup?: (aborted: AbortSignal, actionResult: ActionResult<T>) => Promise<void>): Promise<T>;
|
|
27
|
-
//# sourceMappingURL=mask-unix-signals.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mask-unix-signals.d.ts","sourceRoot":"","sources":["../src/mask-unix-signals.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,CAAC,CAAC,IACtB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,WAAW,EAAE,CAAC,CAAA;CAAE,GACjC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACrC,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,CACR,OAAO,EAAE,WAAW,EACpB,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,KAC1B,OAAO,CAAC,IAAI,CAAC,GACjB,OAAO,CAAC,CAAC,CAAC,CAoDZ"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maskUnixSignals = maskUnixSignals;
|
|
4
|
-
const unixSignalsToMask = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
5
|
-
// The exit code that is used when the process is aborted due to a unix signal
|
|
6
|
-
const exitCode = 254;
|
|
7
|
-
/**
|
|
8
|
-
* Runs an action with some unix signals being masked. This is useful for actions that should not be interrupted and need
|
|
9
|
-
* to be allowed to complete or perform some cleanup. If a signal is received, the action will be notified that it should
|
|
10
|
-
* abort via the `AbortSignal` that is passed to it. The action may or may not choose to abort immediately. The cleanup
|
|
11
|
-
* action is called after the main action and this happens unconditionally, i.e. regardless of whether a signal was received,
|
|
12
|
-
* the main action threw an error, or the main action returned a value. The cleanup action is passed the abort signal and the
|
|
13
|
-
* error (if any) that was thrown by the main action. If a signal was received, the process will exit after the cleanup
|
|
14
|
-
* action has completed. If the main action threw an error, that error will be thrown again. Otherwise, the main action's
|
|
15
|
-
* return value is returned. This function can be thought of as a (unix) signal aware version of `try { … } finally { … }`
|
|
16
|
-
* and `try { … } catch { … } catch { … }`.
|
|
17
|
-
*
|
|
18
|
-
* *Note*: This function registers listeners for some unix signals, so it affects the global behavior of the process. Be
|
|
19
|
-
* careful when using this function in a library.
|
|
20
|
-
*
|
|
21
|
-
* @param action - The main action to execute.
|
|
22
|
-
* @param cleanup - An optional cleanup action to execute when the process is aborted.
|
|
23
|
-
* @returns The result of the `action`.
|
|
24
|
-
*/
|
|
25
|
-
async function maskUnixSignals(action, cleanup) {
|
|
26
|
-
const abortController = new AbortController();
|
|
27
|
-
const abortSignal = abortController.signal;
|
|
28
|
-
const onUnixSignal = (unixSignal) => {
|
|
29
|
-
console.log(`${unixSignal} received, will abort after cleanup`);
|
|
30
|
-
if (unixSignal === "SIGINT") {
|
|
31
|
-
if (!abortSignal.aborted) {
|
|
32
|
-
console.log("Press Ctrl+C again to force abort");
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
console.log("Second SIGINT received, will abort immediately");
|
|
36
|
-
process.exit(exitCode);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Pass the signal as the reason for aborting so that `action` and `cleanup` can know which signal was received
|
|
40
|
-
abortController.abort(unixSignal);
|
|
41
|
-
};
|
|
42
|
-
for (const signal of unixSignalsToMask) {
|
|
43
|
-
process.on(signal, onUnixSignal);
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
let result;
|
|
47
|
-
try {
|
|
48
|
-
const returnValue = await action(abortSignal);
|
|
49
|
-
result = { success: true, returnValue };
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
result = { success: false, error: err };
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
await cleanup?.(abortSignal, result);
|
|
56
|
-
}
|
|
57
|
-
finally {
|
|
58
|
-
// If the process received a (unix) signal, this takes precedence over any error that was thrown by `action` or
|
|
59
|
-
// `cleanup`. So we exit here. Otherwise, we let standard JS error handling take over, e.g. an exception
|
|
60
|
-
// thrown by `cleanup` shadows any exception that was thrown by `action`.
|
|
61
|
-
if (abortSignal.aborted) {
|
|
62
|
-
// The process received a (unix) signal, so we exit here.
|
|
63
|
-
process.exit(exitCode);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (!result.success) {
|
|
67
|
-
// `action` threw an error
|
|
68
|
-
throw result.error;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
// `action` threw an error
|
|
72
|
-
return result.returnValue;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
for (const signal of unixSignalsToMask) {
|
|
77
|
-
process.off(signal, onUnixSignal);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=mask-unix-signals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"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AAC;YACb,MAAM,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC;YACH,MAAM,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;gBAAS,CAAC;YACT,+GAA+G;YAC/G,wGAAwG;YACxG,yEAAyE;YACzE,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACxB,yDAAyD;gBACzD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,0BAA0B;YAC1B,MAAM,MAAM,CAAC,KAAK,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,0BAA0B;YAC1B,OAAO,MAAM,CAAC,WAAW,CAAC;QAC5B,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export type SuperblocksMetadata = {
|
|
2
|
-
cliVersion: string;
|
|
3
|
-
};
|
|
4
|
-
export type SuperblocksResourceType = "APPLICATION" | "BACKEND";
|
|
5
|
-
export type SuperblocksConfigType = "APPLICATION" | "APPLICATION_V2" | "BACKEND";
|
|
6
|
-
export type VersionedResourceConfig = {
|
|
7
|
-
location: string;
|
|
8
|
-
resourceType: SuperblocksResourceType;
|
|
9
|
-
};
|
|
10
|
-
export type SuperblocksResourceConfigMetadata = {
|
|
11
|
-
fileVersion?: string;
|
|
12
|
-
};
|
|
13
|
-
export type SuperblocksResourceConfig = {
|
|
14
|
-
id: string;
|
|
15
|
-
configType: SuperblocksConfigType;
|
|
16
|
-
metadata?: SuperblocksResourceConfigMetadata;
|
|
17
|
-
};
|
|
18
|
-
export type SuperblocksBackendConfig = SuperblocksResourceConfig & SourceFilesContanier & {
|
|
19
|
-
configType: "BACKEND";
|
|
20
|
-
};
|
|
21
|
-
export type SuperblocksApplicationConfig = SuperblocksResourceConfig & {
|
|
22
|
-
configType: "APPLICATION";
|
|
23
|
-
defaultPageId?: string;
|
|
24
|
-
apis?: Record<string, string>;
|
|
25
|
-
appApis?: Record<string, ApiInfo>;
|
|
26
|
-
pages?: Record<string, PageInfo>;
|
|
27
|
-
};
|
|
28
|
-
export type PageInfo = {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
apis?: Record<string, string>;
|
|
32
|
-
pageApis?: Record<string, ApiInfo>;
|
|
33
|
-
};
|
|
34
|
-
export type SourceFilesContanier = {
|
|
35
|
-
sourceFiles?: string[];
|
|
36
|
-
};
|
|
37
|
-
export type ApiInfo = SourceFilesContanier & {
|
|
38
|
-
name: string;
|
|
39
|
-
};
|
|
40
|
-
export type SuperblocksApplicationV2Config = SuperblocksResourceConfig & {
|
|
41
|
-
configType: "APPLICATION_V2";
|
|
42
|
-
};
|
|
43
|
-
export type SuperblocksMonorepoConfig = {
|
|
44
|
-
configType: "ROOT";
|
|
45
|
-
resources: Record<string, VersionedResourceConfig>;
|
|
46
|
-
metadata: SuperblocksMetadata;
|
|
47
|
-
};
|
|
48
|
-
export type SuperblocksConfig = SuperblocksMonorepoConfig | SuperblocksApplicationConfig | SuperblocksApplicationV2Config | SuperblocksBackendConfig;
|
|
49
|
-
/**
|
|
50
|
-
* Get the Superblocks config file from the current directory (and optionally) hierarchy
|
|
51
|
-
* @param checkParentDir Whether to recursively check the parent directory for a Superblocks config file
|
|
52
|
-
*/
|
|
53
|
-
export declare function getSuperblocksMonorepoConfigJson(checkParentDir?: boolean, pathPrefix?: string): Promise<[SuperblocksMonorepoConfig, string]>;
|
|
54
|
-
export declare function getSuperblocksApplicationConfigJson(applicationPath?: string): Promise<SuperblocksApplicationConfig>;
|
|
55
|
-
export declare function getSuperblocksApplicationConfigIfExists(applicationPath: string): Promise<SuperblocksApplicationConfig | undefined>;
|
|
56
|
-
export declare function getSuperblocksApplicationV2ConfigJson(applicationPath?: string): Promise<SuperblocksApplicationV2Config>;
|
|
57
|
-
export declare function getSuperblocksBackendConfigIfExists(backendPath: string): Promise<SuperblocksBackendConfig | undefined>;
|
|
58
|
-
export declare function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig>;
|
|
59
|
-
export declare function getSuperblocksResourceConfigIfExists(): Promise<SuperblocksResourceConfig | undefined>;
|
|
60
|
-
export declare function getResourceIdFromUrl(resourceUrl: any): [string, SuperblocksResourceType];
|
|
61
|
-
//# sourceMappingURL=resource-configs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resource-configs.d.ts","sourceRoot":"","sources":["../src/resource-configs.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG,SAAS,CAAC;AAGhE,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,gBAAgB,GAChB,SAAS,CAAC;AAEd,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,uBAAuB,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,iCAAiC,GAAG;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,qBAAqB,CAAC;IAClC,QAAQ,CAAC,EAAE,iCAAiC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,yBAAyB,GAC9D,oBAAoB,GAAG;IACrB,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC;AAEJ,MAAM,MAAM,4BAA4B,GAAG,y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e,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,4BAA4B,CAAC,CAqBvC;AAED,wBAAsB,uCAAuC,CAC3D,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,4BAA4B,GAAG,SAAS,CAAC,CAgBnD;AAED,wBAAsB,qCAAqC,CACzD,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,8BAA8B,CAAC,CAqBzC;AAED,wBAAsB,mCAAmC,CACvD,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAgB/C;AAED,wBAAsB,+BAA+B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CAkBzF;AAED,wBAAsB,oCAAoC,IAAI,OAAO,CACnE,yBAAyB,GAAG,SAAS,CACtC,CAkBA;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,GAAG,GACf,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAiCnC"}
|
package/dist/resource-configs.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getSuperblocksMonorepoConfigJson = getSuperblocksMonorepoConfigJson;
|
|
40
|
-
exports.getSuperblocksApplicationConfigJson = getSuperblocksApplicationConfigJson;
|
|
41
|
-
exports.getSuperblocksApplicationConfigIfExists = getSuperblocksApplicationConfigIfExists;
|
|
42
|
-
exports.getSuperblocksApplicationV2ConfigJson = getSuperblocksApplicationV2ConfigJson;
|
|
43
|
-
exports.getSuperblocksBackendConfigIfExists = getSuperblocksBackendConfigIfExists;
|
|
44
|
-
exports.getSuperblocksBackendConfigJson = getSuperblocksBackendConfigJson;
|
|
45
|
-
exports.getSuperblocksResourceConfigIfExists = getSuperblocksResourceConfigIfExists;
|
|
46
|
-
exports.getResourceIdFromUrl = getResourceIdFromUrl;
|
|
47
|
-
const path_1 = __importDefault(require("path"));
|
|
48
|
-
const fs = __importStar(require("fs-extra"));
|
|
49
|
-
const constants_js_1 = require("./constants.js");
|
|
50
|
-
/**
|
|
51
|
-
* Get the Superblocks config file from the current directory (and optionally) hierarchy
|
|
52
|
-
* @param checkParentDir Whether to recursively check the parent directory for a Superblocks config file
|
|
53
|
-
*/
|
|
54
|
-
async function getSuperblocksMonorepoConfigJson(checkParentDir = false, pathPrefix = "") {
|
|
55
|
-
const absolutePath = path_1.default.resolve(pathPrefix);
|
|
56
|
-
let hasReachedFilesystemRoot = false;
|
|
57
|
-
try {
|
|
58
|
-
hasReachedFilesystemRoot = path_1.default.parse(absolutePath).root == absolutePath;
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
throw new Error("Could not parse path " + absolutePath);
|
|
62
|
-
}
|
|
63
|
-
let superblocksConfig;
|
|
64
|
-
if ((pathPrefix && !fs.existsSync(absolutePath)) ||
|
|
65
|
-
hasReachedFilesystemRoot) {
|
|
66
|
-
throw new Error("No Superblocks config file found in current directory hierarchy " +
|
|
67
|
-
pathPrefix);
|
|
68
|
-
}
|
|
69
|
-
const attemptedPath = path_1.default.join(absolutePath, constants_js_1.RESOURCE_CONFIG_PATH);
|
|
70
|
-
try {
|
|
71
|
-
superblocksConfig = await fs.readJSON(attemptedPath);
|
|
72
|
-
if (superblocksConfig.configType !== "ROOT") {
|
|
73
|
-
throw new Error("Not the root Superblocks config file");
|
|
74
|
-
}
|
|
75
|
-
return [superblocksConfig, attemptedPath];
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
if (!checkParentDir) {
|
|
79
|
-
// no superblocks config file found
|
|
80
|
-
throw new Error("No Superblocks config file found in current directory " +
|
|
81
|
-
attemptedPath);
|
|
82
|
-
}
|
|
83
|
-
return getSuperblocksMonorepoConfigJson(true, "../" + pathPrefix);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function getSuperblocksApplicationConfigJson(applicationPath) {
|
|
87
|
-
let superblocksConfig;
|
|
88
|
-
try {
|
|
89
|
-
const configPath = applicationPath
|
|
90
|
-
? path_1.default.join(applicationPath, constants_js_1.RESOURCE_CONFIG_PATH)
|
|
91
|
-
: constants_js_1.RESOURCE_CONFIG_PATH;
|
|
92
|
-
superblocksConfig = await fs.readJSON(configPath);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// no superblocks config file found
|
|
96
|
-
throw new Error("This command must be run within a Superblocks app directory.");
|
|
97
|
-
}
|
|
98
|
-
if (superblocksConfig.configType !== "APPLICATION") {
|
|
99
|
-
throw new Error("Please execute this command within a Superblocks application directory.");
|
|
100
|
-
}
|
|
101
|
-
return superblocksConfig;
|
|
102
|
-
}
|
|
103
|
-
async function getSuperblocksApplicationConfigIfExists(applicationPath) {
|
|
104
|
-
let superblocksConfig;
|
|
105
|
-
try {
|
|
106
|
-
const configPath = applicationPath
|
|
107
|
-
? path_1.default.join(applicationPath, constants_js_1.RESOURCE_CONFIG_PATH)
|
|
108
|
-
: constants_js_1.RESOURCE_CONFIG_PATH;
|
|
109
|
-
superblocksConfig = await fs.readJSON(configPath);
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
// no superblocks config file found
|
|
113
|
-
}
|
|
114
|
-
if (superblocksConfig?.configType !== "APPLICATION") {
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
return superblocksConfig;
|
|
118
|
-
}
|
|
119
|
-
async function getSuperblocksApplicationV2ConfigJson(applicationPath) {
|
|
120
|
-
let superblocksConfig;
|
|
121
|
-
try {
|
|
122
|
-
const configPath = applicationPath
|
|
123
|
-
? path_1.default.join(applicationPath, constants_js_1.RESOURCE_CONFIG_PATH)
|
|
124
|
-
: constants_js_1.RESOURCE_CONFIG_PATH;
|
|
125
|
-
superblocksConfig = await fs.readJSON(configPath);
|
|
126
|
-
}
|
|
127
|
-
catch {
|
|
128
|
-
// no superblocks config file found
|
|
129
|
-
throw new Error("This command must be run within a Superblocks app directory.");
|
|
130
|
-
}
|
|
131
|
-
if (superblocksConfig.configType !== "APPLICATION_V2") {
|
|
132
|
-
throw new Error("Please execute this command within a Superblocks application directory.");
|
|
133
|
-
}
|
|
134
|
-
return superblocksConfig;
|
|
135
|
-
}
|
|
136
|
-
async function getSuperblocksBackendConfigIfExists(backendPath) {
|
|
137
|
-
let superblocksConfig;
|
|
138
|
-
try {
|
|
139
|
-
const configPath = backendPath
|
|
140
|
-
? path_1.default.join(backendPath, constants_js_1.RESOURCE_CONFIG_PATH)
|
|
141
|
-
: constants_js_1.RESOURCE_CONFIG_PATH;
|
|
142
|
-
superblocksConfig = await fs.readJSON(configPath);
|
|
143
|
-
}
|
|
144
|
-
catch {
|
|
145
|
-
// no superblocks config file found
|
|
146
|
-
}
|
|
147
|
-
if (superblocksConfig?.configType !== "BACKEND") {
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
return superblocksConfig;
|
|
151
|
-
}
|
|
152
|
-
async function getSuperblocksBackendConfigJson() {
|
|
153
|
-
let superblocksConfig;
|
|
154
|
-
try {
|
|
155
|
-
superblocksConfig = await fs.readJSON(constants_js_1.RESOURCE_CONFIG_PATH);
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
// no superblocks config file found
|
|
159
|
-
throw new Error("This command must be run within a Superblocks backend resource (workflow/job) directory.");
|
|
160
|
-
}
|
|
161
|
-
if (superblocksConfig.configType !== "BACKEND") {
|
|
162
|
-
throw new Error("Please execute this command within a Superblocks backend resource (workflow/job) directory.");
|
|
163
|
-
}
|
|
164
|
-
return superblocksConfig;
|
|
165
|
-
}
|
|
166
|
-
async function getSuperblocksResourceConfigIfExists() {
|
|
167
|
-
let config;
|
|
168
|
-
try {
|
|
169
|
-
config = await getSuperblocksApplicationConfigJson();
|
|
170
|
-
}
|
|
171
|
-
catch {
|
|
172
|
-
// Noop
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
config = await getSuperblocksApplicationV2ConfigJson();
|
|
176
|
-
}
|
|
177
|
-
catch {
|
|
178
|
-
// Noop
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
config = await getSuperblocksBackendConfigJson();
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
// Noop
|
|
185
|
-
}
|
|
186
|
-
return config;
|
|
187
|
-
}
|
|
188
|
-
function getResourceIdFromUrl(resourceUrl) {
|
|
189
|
-
const url = new URL(resourceUrl);
|
|
190
|
-
if (url.pathname.startsWith("/code-mode")) {
|
|
191
|
-
// find the first uuid in the url
|
|
192
|
-
const tokens = url.pathname.split("/");
|
|
193
|
-
const uuid = tokens.find((token) => token.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/));
|
|
194
|
-
if (!uuid) {
|
|
195
|
-
throw new Error(`Failed to parse resource URL: ${resourceUrl}`);
|
|
196
|
-
}
|
|
197
|
-
return [uuid, "APPLICATION"];
|
|
198
|
-
}
|
|
199
|
-
if (url.pathname.startsWith("/applications")) {
|
|
200
|
-
const tokens = url.pathname.split("/");
|
|
201
|
-
if (tokens.length < 2) {
|
|
202
|
-
throw new Error(`Failed to parse resource URL: ${resourceUrl}`);
|
|
203
|
-
}
|
|
204
|
-
if (tokens[2] === "edit") {
|
|
205
|
-
return [tokens[3], "APPLICATION"];
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
return [tokens[2], "APPLICATION"];
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else if (url.pathname.startsWith("/workflows") ||
|
|
212
|
-
url.pathname.startsWith("/scheduled_jobs")) {
|
|
213
|
-
return [url.pathname.split("/")[2], "BACKEND"];
|
|
214
|
-
}
|
|
215
|
-
throw new Error(`Failed to parse resource URL: ${resourceUrl}`);
|
|
216
|
-
}
|
|
217
|
-
//# sourceMappingURL=resource-configs.js.map
|