@superblocksteam/util 0.0.18 → 0.0.20
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/file-uploader.js +0 -1
- package/dist/generate-component-types.js +2 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/resource-configs.d.ts +1 -3
- package/dist/resource-configs.js +16 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.js +2 -0
- package/package.json +1 -1
- package/src/file-uploader.ts +0 -1
- package/src/generate-component-types.ts +2 -9
- package/src/index.ts +1 -0
- package/src/resource-configs.ts +19 -3
- package/src/types.ts +35 -0
package/dist/file-uploader.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.getBucketeerUrlFromSuperblocksUrl = void 0;
|
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
// retrieves bucketeer base URL given the superblocks server base URL
|
|
6
6
|
const getBucketeerUrlFromSuperblocksUrl = (superblocksBaseUrl) => {
|
|
7
|
-
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
8
7
|
// if superblocks base URL is an EE, return bucketeer's dev URL
|
|
9
8
|
if (!(0, lodash_1.isEmpty)(superblocksBaseUrl.match(new RegExp("pr-.*.superblocks.dev")))) {
|
|
10
9
|
return "https://bucketeer.dev.superblocks.com";
|
|
@@ -22,19 +22,12 @@ function generateComponentTypesFile(config) {
|
|
|
22
22
|
// All stateful properties of your component are defined here.
|
|
23
23
|
// These are the properties which are surfaced in the Superblocks properties panel
|
|
24
24
|
// and can be referenced throughout your Superblocks Application
|
|
25
|
-
export interface
|
|
25
|
+
export interface Props {
|
|
26
26
|
${statefulProperties
|
|
27
27
|
.map((v) => renderInputTypeAsTS(v.path, v.inputType, ";", 2) + "\n")
|
|
28
28
|
.join("")}}
|
|
29
29
|
|
|
30
|
-
export interface
|
|
31
|
-
/**
|
|
32
|
-
* Update one (or more) of your component's stateful properties. This will cause the component to rerender,
|
|
33
|
-
* and will also notify any other components in your Application which depend on the updated properties, so they also rerender
|
|
34
|
-
* @param props An object with the properties to update along with their new values
|
|
35
|
-
*/
|
|
36
|
-
updateStatefulProperties: (props: Partial<StatefulProperties>) => void;
|
|
37
|
-
|
|
30
|
+
export interface EventTriggers {
|
|
38
31
|
// Call the subsequent function(s) to trigger event(s) in Superblocks from your component.
|
|
39
32
|
// These events can be wired up to event handlers in your Superblocks App
|
|
40
33
|
${eventHandlers.length === 0
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ tslib_1.__exportStar(require("./file-uploader"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./login"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./resource-configs"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./input-types"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export type SuperblocksMetadata = {
|
|
2
2
|
cliVersion: string;
|
|
3
|
-
lastUpdated: string;
|
|
4
|
-
created: string;
|
|
5
3
|
};
|
|
6
4
|
export type SuperblocksResourceType = "APPLICATION" | "BACKEND";
|
|
7
5
|
export type VersionedResourceConfig = {
|
|
8
6
|
location: string;
|
|
9
|
-
lastUpdated: string;
|
|
10
7
|
resourceType: SuperblocksResourceType;
|
|
11
8
|
};
|
|
12
9
|
export type SuperblocksResourceConfig = {
|
|
@@ -31,6 +28,7 @@ export type SuperblocksConfig = SuperblocksMonorepoConfig | SuperblocksApplicati
|
|
|
31
28
|
* @param checkParentDir Whether to recursively check the parent directory for a Superblocks config file
|
|
32
29
|
*/
|
|
33
30
|
export declare function getSuperblocksMonorepoConfigJson(checkParentDir?: boolean, pathPrefix?: string): Promise<[SuperblocksMonorepoConfig, string]>;
|
|
31
|
+
export declare function updatedMonorepoConfig(version: string): Promise<void>;
|
|
34
32
|
export declare function getSuperblocksApplicationConfigJson(): Promise<SuperblocksApplicationConfig>;
|
|
35
33
|
export declare function getSuperblocksBackendConfigJson(): Promise<SuperblocksBackendConfig>;
|
|
36
34
|
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.getSuperblocksApplicationConfigJson = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
3
|
+
exports.getSuperblocksResourceConfigIfExists = exports.getSuperblocksBackendConfigJson = exports.getSuperblocksApplicationConfigJson = exports.updatedMonorepoConfig = exports.getSuperblocksMonorepoConfigJson = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
6
6
|
const constants_1 = require("./constants");
|
|
@@ -35,6 +35,21 @@ async function getSuperblocksMonorepoConfigJson(checkParentDir = false, pathPref
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
exports.getSuperblocksMonorepoConfigJson = getSuperblocksMonorepoConfigJson;
|
|
38
|
+
async function updatedMonorepoConfig(version) {
|
|
39
|
+
try {
|
|
40
|
+
const [previousConfig, configPath] = await getSuperblocksMonorepoConfigJson(true);
|
|
41
|
+
if (previousConfig.metadata.cliVersion !== version) {
|
|
42
|
+
const newConfig = JSON.parse(JSON.stringify(previousConfig));
|
|
43
|
+
newConfig.metadata.cliVersion = version;
|
|
44
|
+
// update superblocks.json file
|
|
45
|
+
await fs.writeFile(configPath, JSON.stringify(updatedMonorepoConfig, null, 2));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// This might fail for a brand-new project folder, which is deliberately ignored
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.updatedMonorepoConfig = updatedMonorepoConfig;
|
|
38
53
|
async function getSuperblocksApplicationConfigJson() {
|
|
39
54
|
let superblocksConfig;
|
|
40
55
|
try {
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { type UUID } from "node:crypto";
|
|
3
|
+
import { type InputType } from "./input-types";
|
|
4
|
+
export interface StatefulProperty {
|
|
5
|
+
label: string;
|
|
6
|
+
path: string;
|
|
7
|
+
inputType: InputType;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ComponentConfig {
|
|
11
|
+
id: UUID;
|
|
12
|
+
name: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
componentPath: string;
|
|
15
|
+
statefulProperties: StatefulProperty[];
|
|
16
|
+
/**
|
|
17
|
+
* Example: [{
|
|
18
|
+
* label: "On Click",
|
|
19
|
+
* path: "onClick",
|
|
20
|
+
* }]
|
|
21
|
+
*/
|
|
22
|
+
eventHandlers: Array<{
|
|
23
|
+
label: string;
|
|
24
|
+
path: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
package/src/file-uploader.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { isEmpty } from "lodash";
|
|
|
4
4
|
export const getBucketeerUrlFromSuperblocksUrl = (
|
|
5
5
|
superblocksBaseUrl: string
|
|
6
6
|
): string => {
|
|
7
|
-
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
8
7
|
// if superblocks base URL is an EE, return bucketeer's dev URL
|
|
9
8
|
if (!isEmpty(superblocksBaseUrl.match(new RegExp("pr-.*.superblocks.dev")))) {
|
|
10
9
|
return "https://bucketeer.dev.superblocks.com";
|
|
@@ -30,19 +30,12 @@ export function generateComponentTypesFile(config: any) {
|
|
|
30
30
|
// All stateful properties of your component are defined here.
|
|
31
31
|
// These are the properties which are surfaced in the Superblocks properties panel
|
|
32
32
|
// and can be referenced throughout your Superblocks Application
|
|
33
|
-
export interface
|
|
33
|
+
export interface Props {
|
|
34
34
|
${statefulProperties
|
|
35
35
|
.map((v: any) => renderInputTypeAsTS(v.path, v.inputType, ";", 2) + "\n")
|
|
36
36
|
.join("")}}
|
|
37
37
|
|
|
38
|
-
export interface
|
|
39
|
-
/**
|
|
40
|
-
* Update one (or more) of your component's stateful properties. This will cause the component to rerender,
|
|
41
|
-
* and will also notify any other components in your Application which depend on the updated properties, so they also rerender
|
|
42
|
-
* @param props An object with the properties to update along with their new values
|
|
43
|
-
*/
|
|
44
|
-
updateStatefulProperties: (props: Partial<StatefulProperties>) => void;
|
|
45
|
-
|
|
38
|
+
export interface EventTriggers {
|
|
46
39
|
// Call the subsequent function(s) to trigger event(s) in Superblocks from your component.
|
|
47
40
|
// These events can be wired up to event handlers in your Superblocks App
|
|
48
41
|
${
|
package/src/index.ts
CHANGED
package/src/resource-configs.ts
CHANGED
|
@@ -3,15 +3,12 @@ import { RESOURCE_CONFIG_PATH } from "./constants";
|
|
|
3
3
|
|
|
4
4
|
export type SuperblocksMetadata = {
|
|
5
5
|
cliVersion: string;
|
|
6
|
-
lastUpdated: string;
|
|
7
|
-
created: string;
|
|
8
6
|
};
|
|
9
7
|
|
|
10
8
|
export type SuperblocksResourceType = "APPLICATION" | "BACKEND";
|
|
11
9
|
|
|
12
10
|
export type VersionedResourceConfig = {
|
|
13
11
|
location: string;
|
|
14
|
-
lastUpdated: string;
|
|
15
12
|
resourceType: SuperblocksResourceType;
|
|
16
13
|
};
|
|
17
14
|
|
|
@@ -78,6 +75,25 @@ export async function getSuperblocksMonorepoConfigJson(
|
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
|
|
78
|
+
export async function updatedMonorepoConfig(version: string) {
|
|
79
|
+
try {
|
|
80
|
+
const [previousConfig, configPath] = await getSuperblocksMonorepoConfigJson(
|
|
81
|
+
true
|
|
82
|
+
);
|
|
83
|
+
if (previousConfig.metadata.cliVersion !== version) {
|
|
84
|
+
const newConfig = JSON.parse(JSON.stringify(previousConfig));
|
|
85
|
+
newConfig.metadata.cliVersion = version;
|
|
86
|
+
// update superblocks.json file
|
|
87
|
+
await fs.writeFile(
|
|
88
|
+
configPath,
|
|
89
|
+
JSON.stringify(updatedMonorepoConfig, null, 2)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
} catch {
|
|
93
|
+
// This might fail for a brand-new project folder, which is deliberately ignored
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
export async function getSuperblocksApplicationConfigJson(): Promise<SuperblocksApplicationConfig> {
|
|
82
98
|
let superblocksConfig;
|
|
83
99
|
try {
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type UUID } from "node:crypto";
|
|
2
|
+
import { type InputType } from "./input-types";
|
|
3
|
+
|
|
4
|
+
export interface StatefulProperty {
|
|
5
|
+
label: string;
|
|
6
|
+
path: string;
|
|
7
|
+
inputType: InputType;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ComponentConfig {
|
|
12
|
+
id: UUID;
|
|
13
|
+
|
|
14
|
+
// Example: "myComponent"
|
|
15
|
+
name: string;
|
|
16
|
+
|
|
17
|
+
// Example: "My Component"
|
|
18
|
+
displayName: string;
|
|
19
|
+
|
|
20
|
+
// Example: "components/myComponent/component.tsx"
|
|
21
|
+
componentPath: string;
|
|
22
|
+
|
|
23
|
+
statefulProperties: StatefulProperty[];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Example: [{
|
|
27
|
+
* label: "On Click",
|
|
28
|
+
* path: "onClick",
|
|
29
|
+
* }]
|
|
30
|
+
*/
|
|
31
|
+
eventHandlers: Array<{
|
|
32
|
+
label: string;
|
|
33
|
+
path: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|