@superblocksteam/util 0.0.17 → 0.0.19

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.
@@ -2,3 +2,4 @@ export declare function getComponentConfigs(generateTypesFiles: boolean): Promis
2
2
  configs: Record<string, any>;
3
3
  hasError: boolean;
4
4
  }>;
5
+ export declare const getContentType: (filename: string) => string;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComponentConfigs = void 0;
3
+ exports.getContentType = exports.getComponentConfigs = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const child_process_1 = require("child_process");
6
6
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
7
7
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  const fs = tslib_1.__importStar(require("fs-extra"));
9
+ const mimeTypes = tslib_1.__importStar(require("mime-types"));
9
10
  const constants_1 = require("./constants");
10
11
  const generate_component_types_1 = require("./generate-component-types");
11
12
  const validation_1 = require("./validation");
@@ -128,3 +129,11 @@ async function getComponentConfigs(generateTypesFiles) {
128
129
  };
129
130
  }
130
131
  exports.getComponentConfigs = getComponentConfigs;
132
+ const getContentType = (filename) => {
133
+ const mimeType = mimeTypes.lookup(filename);
134
+ if (!mimeType) {
135
+ return "";
136
+ }
137
+ return mimeType;
138
+ };
139
+ exports.getContentType = getContentType;
@@ -0,0 +1 @@
1
+ export declare const getBucketeerUrlFromSuperblocksUrl: (superblocksBaseUrl: string) => string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBucketeerUrlFromSuperblocksUrl = void 0;
4
+ const lodash_1 = require("lodash");
5
+ // retrieves bucketeer base URL given the superblocks server base URL
6
+ const getBucketeerUrlFromSuperblocksUrl = (superblocksBaseUrl) => {
7
+ // if superblocks base URL is an EE, return bucketeer's dev URL
8
+ if (!(0, lodash_1.isEmpty)(superblocksBaseUrl.match(new RegExp("pr-.*.superblocks.dev")))) {
9
+ return "https://bucketeer.dev.superblocks.com";
10
+ }
11
+ switch (superblocksBaseUrl) {
12
+ case "https://eu.superblocks.com":
13
+ return "https://bucketeer.eu.superblocks.com";
14
+ case "https://staging.superblocks.com":
15
+ return "https://bucketeer.staging.superblocks.com";
16
+ case "https://app.superblocks.com":
17
+ case "https://app.superblockshq.com":
18
+ return "https://bucketeer.superblocks.com";
19
+ case "https://dev.superblocks.com":
20
+ return "https://bucketeer.dev.superblocks.com";
21
+ case "http://localhost:3000":
22
+ default:
23
+ return "http://localhost:8030";
24
+ }
25
+ };
26
+ exports.getBucketeerUrlFromSuperblocksUrl = getBucketeerUrlFromSuperblocksUrl;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./constants";
2
2
  export * from "./component-configs";
3
+ export * from "./file-uploader";
3
4
  export * from "./login";
4
5
  export * from "./resource-configs";
5
6
  export * from "./input-types";
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./constants"), exports);
5
5
  tslib_1.__exportStar(require("./component-configs"), exports);
6
+ tslib_1.__exportStar(require("./file-uploader"), exports);
6
7
  tslib_1.__exportStar(require("./login"), exports);
7
8
  tslib_1.__exportStar(require("./resource-configs"), exports);
8
9
  tslib_1.__exportStar(require("./input-types"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/util",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "main": "dist/index.js",
5
5
  "homepage": "https://www.superblocks.com",
6
6
  "scripts": {
@@ -15,9 +15,11 @@
15
15
  "description": "",
16
16
  "dependencies": {
17
17
  "ajv": "^8.12.0",
18
- "better-ajv-errors": "^1.2.0"
18
+ "better-ajv-errors": "^1.2.0",
19
+ "mime-types": "^2.1.35"
19
20
  },
20
21
  "devDependencies": {
22
+ "@types/mime-types": "^2.1.1",
21
23
  "@typescript-eslint/eslint-plugin": "^5.60.1",
22
24
  "@typescript-eslint/parser": "^5.60.1",
23
25
  "eslint": "^8.45.0",
@@ -2,6 +2,7 @@ import { execFile } from "child_process";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import * as fs from "fs-extra";
5
+ import * as mimeTypes from "mime-types";
5
6
  import { CUSTOM_COMPONENTS_PATH } from "./constants";
6
7
  import { generateComponentTypesFile } from "./generate-component-types";
7
8
  import { validateCustomComponents } from "./validation";
@@ -143,3 +144,11 @@ export async function getComponentConfigs(
143
144
  hasError,
144
145
  };
145
146
  }
147
+
148
+ export const getContentType = (filename: string): string => {
149
+ const mimeType = mimeTypes.lookup(filename);
150
+ if (!mimeType) {
151
+ return "";
152
+ }
153
+ return mimeType as string;
154
+ };
@@ -0,0 +1,26 @@
1
+ import { isEmpty } from "lodash";
2
+
3
+ // retrieves bucketeer base URL given the superblocks server base URL
4
+ export const getBucketeerUrlFromSuperblocksUrl = (
5
+ superblocksBaseUrl: string
6
+ ): string => {
7
+ // if superblocks base URL is an EE, return bucketeer's dev URL
8
+ if (!isEmpty(superblocksBaseUrl.match(new RegExp("pr-.*.superblocks.dev")))) {
9
+ return "https://bucketeer.dev.superblocks.com";
10
+ }
11
+
12
+ switch (superblocksBaseUrl) {
13
+ case "https://eu.superblocks.com":
14
+ return "https://bucketeer.eu.superblocks.com";
15
+ case "https://staging.superblocks.com":
16
+ return "https://bucketeer.staging.superblocks.com";
17
+ case "https://app.superblocks.com":
18
+ case "https://app.superblockshq.com":
19
+ return "https://bucketeer.superblocks.com";
20
+ case "https://dev.superblocks.com":
21
+ return "https://bucketeer.dev.superblocks.com";
22
+ case "http://localhost:3000":
23
+ default:
24
+ return "http://localhost:8030";
25
+ }
26
+ };
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./constants";
2
2
  export * from "./component-configs";
3
+ export * from "./file-uploader";
3
4
  export * from "./login";
4
5
  export * from "./resource-configs";
5
6
  export * from "./input-types";