ag-common 0.0.394 → 0.0.396
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/api/helpers/api.js +1 -1
- package/dist/api/helpers/enforceDynamoProvisionCap.js +4 -3
- package/dist/api/helpers/sqs.js +2 -2
- package/dist/api/helpers/ssm.js +2 -2
- package/dist/common/helpers/binary.js +3 -3
- package/dist/common/helpers/string/base64.d.ts +2 -0
- package/dist/common/helpers/string/base64.js +7 -0
- package/dist/common/helpers/string/chunk.d.ts +1 -0
- package/dist/common/helpers/string/chunk.js +5 -0
- package/dist/common/helpers/string/contains.d.ts +20 -0
- package/dist/common/helpers/string/contains.js +33 -0
- package/dist/common/helpers/string/getExtendedStringSegment.d.ts +19 -0
- package/dist/common/helpers/string/getExtendedStringSegment.js +44 -0
- package/dist/common/helpers/string/index.d.ts +10 -0
- package/dist/common/helpers/string/index.js +26 -0
- package/dist/common/helpers/string/json.d.ts +7 -0
- package/dist/common/helpers/string/json.js +21 -0
- package/dist/common/helpers/string/object.d.ts +7 -0
- package/dist/common/helpers/string/object.js +23 -0
- package/dist/common/helpers/string/surround.d.ts +8 -0
- package/dist/common/helpers/string/surround.js +10 -0
- package/dist/common/helpers/string/trim.d.ts +2 -0
- package/dist/common/helpers/string/trim.js +24 -0
- package/dist/common/helpers/string/truncate.d.ts +1 -0
- package/dist/common/helpers/string/truncate.js +10 -0
- package/dist/common/helpers/string/url.d.ts +9 -0
- package/dist/common/helpers/string/url.js +31 -0
- package/dist/ui/components/Confirm/Modal.js +1 -1
- package/dist/ui/components/DashboardAuthValidation/index.js +2 -2
- package/dist/ui/components/HeadersRaw/index.js +1 -1
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +2 -4
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +4 -4
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +11 -12
- package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +13 -3
- package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +2 -2
- package/dist/ui/components/Prompt/Modal.js +1 -1
- package/dist/ui/components/Search/AutoHideSearchBox.js +2 -2
- package/dist/ui/components/Search/Base.js +2 -2
- package/dist/ui/components/Search/Dialog.js +2 -2
- package/dist/ui/components/Search/SearchBox.js +4 -3
- package/dist/ui/components/Toast/base.js +2 -2
- package/dist/ui/helpers/axiosHelper.js +4 -3
- package/dist/ui/helpers/callOpenApi/cached.js +4 -4
- package/dist/ui/helpers/cookie/get.d.ts +0 -4
- package/dist/ui/helpers/cookie/get.js +6 -21
- package/dist/ui/helpers/cookie/index.d.ts +1 -0
- package/dist/ui/helpers/cookie/index.js +1 -0
- package/dist/ui/helpers/cookie/raw.d.ts +26 -0
- package/dist/ui/helpers/cookie/raw.js +67 -0
- package/dist/ui/helpers/cookie/set.d.ts +0 -1
- package/dist/ui/helpers/cookie/set.js +8 -43
- package/dist/ui/helpers/routes.js +2 -2
- package/dist/ui/helpers/useQueryString.js +2 -2
- package/package.json +1 -1
- package/dist/common/helpers/string.d.ts +0 -64
- package/dist/common/helpers/string.js +0 -210
package/dist/api/helpers/api.js
CHANGED
|
@@ -45,8 +45,8 @@ const stripPKs = (record, keepPk = true) => {
|
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
49
48
|
// @ts-ignore
|
|
49
|
+
// eslint-disable-next-line
|
|
50
50
|
const { PK, PK1, PK2, PK3, PK4, PK5, L1, L2, L3, L4, L5, L6, type } = record, rest = __rest(record, ["PK", "PK1", "PK2", "PK3", "PK4", "PK5", "L1", "L2", "L3", "L4", "L5", "L6", "type"]);
|
|
51
51
|
if (keepPk) {
|
|
52
52
|
//@ts-ignore
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.enforceDynamoProvisionCap = void 0;
|
|
4
4
|
const log_1 = require("../../common/helpers/log");
|
|
5
5
|
const math_1 = require("../../common/helpers/math");
|
|
6
|
-
const
|
|
6
|
+
const json_1 = require("../../common/helpers/string/json");
|
|
7
|
+
const trim_1 = require("../../common/helpers/string/trim");
|
|
7
8
|
const extractSum = ({ str, regex }) => {
|
|
8
9
|
var _a;
|
|
9
10
|
return (0, math_1.sumArray)(((_a = str
|
|
10
|
-
.match(regex)) === null || _a === void 0 ? void 0 : _a.map((s2) => (0,
|
|
11
|
+
.match(regex)) === null || _a === void 0 ? void 0 : _a.map((s2) => (0, trim_1.trim)(s2.substring(s2.indexOf(':') + 1), ':', ',', ' ')).filter((r) => r && Number(r)).map((r) => Number(r))) || []);
|
|
11
12
|
};
|
|
12
13
|
/** ensure that dynamo tables in stack dont exceed passed in provisioned limits */
|
|
13
14
|
const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, mustEqual = false, }) => {
|
|
@@ -17,7 +18,7 @@ const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, must
|
|
|
17
18
|
}
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
20
|
const t = tables[0];
|
|
20
|
-
const s = (0,
|
|
21
|
+
const s = (0, json_1.safeStringify)(t.node._children.Resource.node.scope);
|
|
21
22
|
const reads = extractSum({ str: s, regex: /readCapacityUnits.*/gim });
|
|
22
23
|
const writes = extractSum({ str: s, regex: /writeCapacityUnits.*/gim });
|
|
23
24
|
(0, log_1.warn)(`dynamo table provisioned reads:${reads}/${readsMax}`);
|
package/dist/api/helpers/sqs.js
CHANGED
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.sendMessages = exports.setSqs = exports.sqs = void 0;
|
|
16
16
|
const sqs_1 = __importDefault(require("aws-sdk/clients/sqs"));
|
|
17
|
-
const
|
|
17
|
+
const hashCode_1 = require("../../common/helpers/hashCode");
|
|
18
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
19
19
|
exports.sqs = new sqs_1.default();
|
|
20
20
|
const setSqs = (region) => {
|
|
@@ -26,7 +26,7 @@ const sendMessages = (items, queueUrl) => __awaiter(void 0, void 0, void 0, func
|
|
|
26
26
|
QueueUrl: queueUrl,
|
|
27
27
|
Entries: items.map((i) => ({
|
|
28
28
|
MessageBody: JSON.stringify(i),
|
|
29
|
-
Id: (0,
|
|
29
|
+
Id: (0, hashCode_1.hashCode)(JSON.stringify(i)),
|
|
30
30
|
})),
|
|
31
31
|
};
|
|
32
32
|
const put = yield exports.sqs.sendMessageBatch(req).promise();
|
package/dist/api/helpers/ssm.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadSsmStringList = exports.loadSsmString = exports.saveToSsm = void 0;
|
|
4
4
|
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
-
const
|
|
5
|
+
const base64_1 = require("../../common/helpers/string/base64");
|
|
6
6
|
/**
|
|
7
7
|
* save a value to ssm
|
|
8
8
|
* @param param0
|
|
9
9
|
*/
|
|
10
10
|
const saveToSsm = ({ stack, path, value, }) => {
|
|
11
|
-
const name = (0,
|
|
11
|
+
const name = (0, base64_1.toBase64)(path);
|
|
12
12
|
new aws_cdk_lib_1.aws_ssm.StringParameter(stack, name, {
|
|
13
13
|
allowedPattern: '.*',
|
|
14
14
|
description: `${name} (cdk)`,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.base64ToBinary = exports.arrayBufferToBase64 = void 0;
|
|
4
|
-
const
|
|
4
|
+
const base64_1 = require("./string/base64");
|
|
5
5
|
function toBuffer(ab) {
|
|
6
6
|
const buffer = new Buffer(ab.byteLength);
|
|
7
7
|
const view = new Uint8Array(ab);
|
|
@@ -11,7 +11,7 @@ function toBuffer(ab) {
|
|
|
11
11
|
return buffer;
|
|
12
12
|
}
|
|
13
13
|
function toArrayBuffer(base64) {
|
|
14
|
-
const binary_string = (0,
|
|
14
|
+
const binary_string = (0, base64_1.fromBase64)(base64);
|
|
15
15
|
const len = binary_string.length;
|
|
16
16
|
const bytes = new Uint8Array(len);
|
|
17
17
|
for (let i = 0; i < len; i += 1) {
|
|
@@ -31,7 +31,7 @@ function arrayBufferToBase64(buffer) {
|
|
|
31
31
|
for (let i = 0; i < len; i += 1) {
|
|
32
32
|
binary += String.fromCharCode(bytes[i]);
|
|
33
33
|
}
|
|
34
|
-
return (0,
|
|
34
|
+
return (0, base64_1.toBase64)(binary);
|
|
35
35
|
}
|
|
36
36
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
37
37
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromBase64 = exports.toBase64 = void 0;
|
|
4
|
+
const toBase64 = (str) => Buffer.from(str).toString('base64');
|
|
5
|
+
exports.toBase64 = toBase64;
|
|
6
|
+
const fromBase64 = (str) => Buffer.from(decodeURIComponent(str), 'base64').toString();
|
|
7
|
+
exports.fromBase64 = fromBase64;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chunkString: (str: string, length: number) => string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* returns >-1 if found
|
|
3
|
+
* @param str
|
|
4
|
+
* @param args
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function containsInsensitiveIndex({ str, fromLast, }: {
|
|
8
|
+
/**
|
|
9
|
+
* if true, will return highest number. default false
|
|
10
|
+
*/
|
|
11
|
+
fromLast?: boolean;
|
|
12
|
+
str: string;
|
|
13
|
+
}, ...args: string[]): number;
|
|
14
|
+
/**
|
|
15
|
+
* returns true if text is found
|
|
16
|
+
* @param str
|
|
17
|
+
* @param args
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
export declare const containsInsensitive: (str: string, ...args: string[]) => boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containsInsensitive = exports.containsInsensitiveIndex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* returns >-1 if found
|
|
6
|
+
* @param str
|
|
7
|
+
* @param args
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
|
|
11
|
+
if (!str || !args) {
|
|
12
|
+
return -1;
|
|
13
|
+
}
|
|
14
|
+
const largs = args.map((a) => a.toLowerCase());
|
|
15
|
+
const lstr = str.toLowerCase();
|
|
16
|
+
const finds = largs
|
|
17
|
+
.map((arg) => (fromLast ? lstr.lastIndexOf(arg) : lstr.indexOf(arg)))
|
|
18
|
+
.filter((s) => s !== -1)
|
|
19
|
+
.sort();
|
|
20
|
+
if (finds.length === 0) {
|
|
21
|
+
return -1;
|
|
22
|
+
}
|
|
23
|
+
return !fromLast ? finds[0] : finds[finds.length - 1];
|
|
24
|
+
}
|
|
25
|
+
exports.containsInsensitiveIndex = containsInsensitiveIndex;
|
|
26
|
+
/**
|
|
27
|
+
* returns true if text is found
|
|
28
|
+
* @param str
|
|
29
|
+
* @param args
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
|
|
33
|
+
exports.containsInsensitive = containsInsensitive;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface IGetExtendedStringSegment {
|
|
2
|
+
/** based on original full text */
|
|
3
|
+
outerStart: number;
|
|
4
|
+
/** based on original full text */
|
|
5
|
+
outerEnd: number;
|
|
6
|
+
/** words including the gaps (probably what you want) */
|
|
7
|
+
outerText: string;
|
|
8
|
+
/** the start index of the searched term in outerText */
|
|
9
|
+
innerStart: number;
|
|
10
|
+
/** the end index of the searched term in outerText */
|
|
11
|
+
innerEnd: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* will return a piece of text around a found term, and the index it was found
|
|
15
|
+
* @param hay
|
|
16
|
+
* @param needle
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare const getExtendedStringSegment: (hay: string, needle: string, blocksOnEitherSide?: number, gapChars?: string[]) => undefined | IGetExtendedStringSegment;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExtendedStringSegment = void 0;
|
|
4
|
+
const contains_1 = require("./contains");
|
|
5
|
+
/**
|
|
6
|
+
* will return a piece of text around a found term, and the index it was found
|
|
7
|
+
* @param hay
|
|
8
|
+
* @param needle
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
const getExtendedStringSegment = (hay, needle, blocksOnEitherSide = 5,
|
|
12
|
+
/** can override this if space bounded words are required */
|
|
13
|
+
gapChars = ['\n', '\r\n']) => {
|
|
14
|
+
const fi = (0, contains_1.containsInsensitiveIndex)({ str: hay }, needle);
|
|
15
|
+
if (fi === -1) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
let start = fi;
|
|
19
|
+
//we want to extend the partial content back to -(gap) gapChars
|
|
20
|
+
for (let a = 0; a <= blocksOnEitherSide; a += 1) {
|
|
21
|
+
const newstartI = (0, contains_1.containsInsensitiveIndex)({ str: hay.substring(0, start), fromLast: true }, ...gapChars);
|
|
22
|
+
if (newstartI !== -1) {
|
|
23
|
+
start = newstartI;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//and forward
|
|
27
|
+
let end = fi + needle.length;
|
|
28
|
+
for (let a = 0; a <= blocksOnEitherSide; a += 1) {
|
|
29
|
+
const newEndI = (0, contains_1.containsInsensitiveIndex)({ str: hay.substring(end) }, ...gapChars);
|
|
30
|
+
if (newEndI !== -1) {
|
|
31
|
+
end += newEndI + 1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const outerText = hay.substring(start, end);
|
|
35
|
+
const innerStart = outerText.toLowerCase().indexOf(needle.toLowerCase());
|
|
36
|
+
return {
|
|
37
|
+
outerStart: start,
|
|
38
|
+
outerEnd: end,
|
|
39
|
+
outerText,
|
|
40
|
+
innerStart,
|
|
41
|
+
innerEnd: innerStart + needle.length,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.getExtendedStringSegment = getExtendedStringSegment;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './base64';
|
|
2
|
+
export * from './chunk';
|
|
3
|
+
export * from './contains';
|
|
4
|
+
export * from './getExtendedStringSegment';
|
|
5
|
+
export * from './json';
|
|
6
|
+
export * from './object';
|
|
7
|
+
export * from './surround';
|
|
8
|
+
export * from './trim';
|
|
9
|
+
export * from './truncate';
|
|
10
|
+
export * from './url';
|
|
@@ -0,0 +1,26 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base64"), exports);
|
|
18
|
+
__exportStar(require("./chunk"), exports);
|
|
19
|
+
__exportStar(require("./contains"), exports);
|
|
20
|
+
__exportStar(require("./getExtendedStringSegment"), exports);
|
|
21
|
+
__exportStar(require("./json"), exports);
|
|
22
|
+
__exportStar(require("./object"), exports);
|
|
23
|
+
__exportStar(require("./surround"), exports);
|
|
24
|
+
__exportStar(require("./trim"), exports);
|
|
25
|
+
__exportStar(require("./truncate"), exports);
|
|
26
|
+
__exportStar(require("./url"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeStringify = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* safely handles circular references
|
|
6
|
+
* @param obj
|
|
7
|
+
* @param indent
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
const safeStringify = (obj, indent = 2) => {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
let cache = [];
|
|
13
|
+
const retVal = JSON.stringify(obj, (_key, value) => typeof value === 'object' && value !== null
|
|
14
|
+
? cache.includes(value)
|
|
15
|
+
? undefined // Duplicate reference found, discard key
|
|
16
|
+
: cache.push(value) && value // Store value in our collection
|
|
17
|
+
: value, indent);
|
|
18
|
+
cache = null;
|
|
19
|
+
return retVal;
|
|
20
|
+
};
|
|
21
|
+
exports.safeStringify = safeStringify;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* object to string - can be used for querystring a=b&c=d etc
|
|
3
|
+
* @param raw eg a=b&c=d
|
|
4
|
+
* @param splitKeyValue eg =
|
|
5
|
+
* @param splitKeys eg &
|
|
6
|
+
*/
|
|
7
|
+
export declare function stringToObject(raw: string, splitKeyValue: string, splitKeys: string): Record<string, string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringToObject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* object to string - can be used for querystring a=b&c=d etc
|
|
6
|
+
* @param raw eg a=b&c=d
|
|
7
|
+
* @param splitKeyValue eg =
|
|
8
|
+
* @param splitKeys eg &
|
|
9
|
+
*/
|
|
10
|
+
function stringToObject(raw, splitKeyValue, splitKeys) {
|
|
11
|
+
const ret = {};
|
|
12
|
+
if (!stringToObject) {
|
|
13
|
+
return ret;
|
|
14
|
+
}
|
|
15
|
+
raw.split(splitKeys).forEach((set) => {
|
|
16
|
+
const [k, v] = set.split(splitKeyValue);
|
|
17
|
+
if (k) {
|
|
18
|
+
ret[k] = v;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return ret;
|
|
22
|
+
}
|
|
23
|
+
exports.stringToObject = stringToObject;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** surround a substring of text with a value */
|
|
2
|
+
export declare const surround: <T>({ text, start, end, surround, }: {
|
|
3
|
+
text: string;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
/** contains will be true when between start + end */
|
|
7
|
+
surround: (s: string, contains: boolean) => T;
|
|
8
|
+
}) => T[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.surround = void 0;
|
|
4
|
+
/** surround a substring of text with a value */
|
|
5
|
+
const surround = ({ text, start, end, surround, }) => [
|
|
6
|
+
surround(text.slice(0, start), false),
|
|
7
|
+
surround(text.slice(start, end), true),
|
|
8
|
+
surround(text.slice(end), false),
|
|
9
|
+
];
|
|
10
|
+
exports.surround = surround;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trim = exports.trimSide = void 0;
|
|
4
|
+
function trimSide(str, fromStart = true, ...params) {
|
|
5
|
+
const pstr = params.join('');
|
|
6
|
+
if (!str) {
|
|
7
|
+
return str;
|
|
8
|
+
}
|
|
9
|
+
const ret = str.replace(new RegExp(`[${pstr}]*$`, 'g'), '');
|
|
10
|
+
if (fromStart) {
|
|
11
|
+
return ret.replace(new RegExp(`^[${pstr}]*`, 'g'), '');
|
|
12
|
+
}
|
|
13
|
+
return ret;
|
|
14
|
+
}
|
|
15
|
+
exports.trimSide = trimSide;
|
|
16
|
+
function trim(str, ...params) {
|
|
17
|
+
if (!str) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
str = trimSide(str, true, ...params);
|
|
21
|
+
str = trimSide(str, false, ...params);
|
|
22
|
+
return str;
|
|
23
|
+
}
|
|
24
|
+
exports.trim = trim;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function truncate(str: string | null | undefined, n: number, ellip: string): string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.truncate = void 0;
|
|
4
|
+
function truncate(str, n, ellip) {
|
|
5
|
+
if (!str) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
return str.length > n ? str.substr(0, n - 1) + ellip : str;
|
|
9
|
+
}
|
|
10
|
+
exports.truncate = truncate;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidUrl = exports.niceUrl = void 0;
|
|
4
|
+
const trim_1 = require("./trim");
|
|
5
|
+
/**
|
|
6
|
+
* removes protocol, and trailing slashes
|
|
7
|
+
*/
|
|
8
|
+
const niceUrl = (siteUrl) => {
|
|
9
|
+
if (!siteUrl) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
let niceSiteUrl = siteUrl
|
|
13
|
+
.substring(siteUrl.indexOf(':') + 1)
|
|
14
|
+
.replace('sc-domain:', '')
|
|
15
|
+
.replace('https://', '')
|
|
16
|
+
.replace('http://', '');
|
|
17
|
+
niceSiteUrl = (0, trim_1.trim)(niceSiteUrl, '/');
|
|
18
|
+
return { siteUrl, niceSiteUrl };
|
|
19
|
+
};
|
|
20
|
+
exports.niceUrl = niceUrl;
|
|
21
|
+
function isValidUrl(raw) {
|
|
22
|
+
let url;
|
|
23
|
+
try {
|
|
24
|
+
url = new URL(raw);
|
|
25
|
+
}
|
|
26
|
+
catch (_) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
30
|
+
}
|
|
31
|
+
exports.isValidUrl = isValidUrl;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DashboardAuthValidation = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const log_1 = require("../../../common/helpers/log");
|
|
9
|
-
const
|
|
9
|
+
const base64_1 = require("../../../common/helpers/string/base64");
|
|
10
10
|
const useGranularHook_1 = require("../../helpers/useGranularHook");
|
|
11
11
|
const useQueryString_1 = require("../../helpers/useQueryString");
|
|
12
12
|
const Loader_1 = require("../Loader");
|
|
@@ -41,7 +41,7 @@ const DashboardAuthValidation = ({ rc: { request, pushPath }, cac: { error: auth
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
if (request.url.query.state && isAuthenticated) {
|
|
44
|
-
const decoded = JSON.parse((0,
|
|
44
|
+
const decoded = JSON.parse((0, base64_1.fromBase64)(request.url.query.state));
|
|
45
45
|
if (decoded.redirect) {
|
|
46
46
|
void pushPath(decoded.redirect);
|
|
47
47
|
return { render: react_1.default.createElement(react_1.default.Fragment, null), openApiDisabled: true };
|
|
@@ -32,7 +32,7 @@ const HeadersRaw = ({ title, image, SiteShort, FullSiteUrl, siteDesc, }) => {
|
|
|
32
32
|
react_1.default.createElement("meta", { key: "14", itemProp: "url", content: FullSiteUrl }),
|
|
33
33
|
react_1.default.createElement("meta", { key: "15", name: "twitter:url", content: FullSiteUrl }),
|
|
34
34
|
react_1.default.createElement("meta", { key: "16", property: "og:type", content: "website" }),
|
|
35
|
-
react_1.default.createElement("meta", { key: "17", name: "twitter:card", content: "
|
|
35
|
+
react_1.default.createElement("meta", { key: "17", name: "twitter:card", content: "summary_large_image" }),
|
|
36
36
|
react_1.default.createElement("meta", { key: "18", name: "robots", content: "index, follow" }),
|
|
37
37
|
...imagearr,
|
|
38
38
|
];
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getSecurityLine = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const string_1 = require("../../../../../common/helpers/string");
|
|
9
8
|
const common_1 = require("../../helpers/common");
|
|
10
9
|
const getSecurityLine = (p, { operation }) => {
|
|
11
10
|
const sec = (0, common_1.getSecurity)(p, { operation });
|
|
@@ -20,9 +19,8 @@ const getSecurityLine = (p, { operation }) => {
|
|
|
20
19
|
react_1.default.createElement("span", null, "--header "),
|
|
21
20
|
react_1.default.createElement(common_1.Highlight, null,
|
|
22
21
|
"'",
|
|
23
|
-
|
|
24
|
-
":",
|
|
25
|
-
' ',
|
|
22
|
+
sec.name,
|
|
23
|
+
": ",
|
|
26
24
|
react_1.default.createElement(common_1.Highlight2, null, p.apiKey || '(API KEY)'),
|
|
27
25
|
"'"))),
|
|
28
26
|
};
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Curl = void 0;
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const array_1 = require("../../../../common/helpers/array");
|
|
10
|
+
const common_1 = require("../helpers/common");
|
|
11
11
|
const joinJsx_1 = require("../helpers/joinJsx");
|
|
12
12
|
const getCurlLines_1 = require("./helpers/getCurlLines");
|
|
13
13
|
const Base = styled_1.default.div `
|
|
@@ -22,13 +22,13 @@ const Curl = ({ ops, p, }) => {
|
|
|
22
22
|
verb.toUpperCase()),
|
|
23
23
|
react_1.default.createElement(react_1.default.Fragment, null,
|
|
24
24
|
"--url ",
|
|
25
|
-
react_1.default.createElement(
|
|
25
|
+
react_1.default.createElement(common_1.Highlight, null,
|
|
26
26
|
"'",
|
|
27
27
|
fullApiUrl,
|
|
28
28
|
"'")),
|
|
29
29
|
...(headerLines || []),
|
|
30
30
|
bodyLine,
|
|
31
|
-
].filter(
|
|
31
|
+
].filter(array_1.notEmpty);
|
|
32
32
|
return react_1.default.createElement(Base, null, (0, joinJsx_1.joinJsxWithSlash)(rows));
|
|
33
33
|
};
|
|
34
34
|
exports.Curl = Curl;
|
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getRequestOptions = void 0;
|
|
7
7
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const common_1 = require("
|
|
10
|
-
const common_2 = require("../../helpers/common");
|
|
9
|
+
const common_1 = require("../../helpers/common");
|
|
11
10
|
const joinJsx_1 = require("../../helpers/joinJsx");
|
|
12
11
|
const rb = react_1.default.createElement(react_1.default.Fragment, null, "}");
|
|
13
12
|
const lb = react_1.default.createElement(react_1.default.Fragment, null, "{");
|
|
@@ -15,28 +14,28 @@ const Lpad = styled_1.default.div `
|
|
|
15
14
|
padding-left: 0.5rem;
|
|
16
15
|
`;
|
|
17
16
|
const getRequestOptions = (p, ops) => {
|
|
18
|
-
const { nice } = (0,
|
|
17
|
+
const { nice } = (0, common_1.getBodyJson)(p) || {};
|
|
19
18
|
if (!nice) {
|
|
20
19
|
return undefined;
|
|
21
20
|
}
|
|
22
|
-
const sec = (0,
|
|
21
|
+
const sec = (0, common_1.getSecurity)(p, ops);
|
|
23
22
|
const h1 = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
24
23
|
' ',
|
|
25
|
-
react_1.default.createElement(
|
|
24
|
+
react_1.default.createElement(common_1.Highlight, null, "'Content-Type'"),
|
|
26
25
|
":",
|
|
27
26
|
' ',
|
|
28
|
-
react_1.default.createElement(
|
|
27
|
+
react_1.default.createElement(common_1.Highlight, null, "'application/json'")));
|
|
29
28
|
let h2;
|
|
30
29
|
if (sec) {
|
|
31
30
|
h2 = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
32
31
|
' ',
|
|
33
|
-
react_1.default.createElement(
|
|
32
|
+
react_1.default.createElement(common_1.Highlight, null,
|
|
34
33
|
"'",
|
|
35
|
-
|
|
34
|
+
sec.name,
|
|
36
35
|
"'"),
|
|
37
36
|
":",
|
|
38
37
|
' ',
|
|
39
|
-
react_1.default.createElement(
|
|
38
|
+
react_1.default.createElement(common_1.Highlight, null,
|
|
40
39
|
"'",
|
|
41
40
|
p.apiKey || '(API KEY)',
|
|
42
41
|
"'")));
|
|
@@ -49,9 +48,9 @@ const getRequestOptions = (p, ops) => {
|
|
|
49
48
|
","));
|
|
50
49
|
const body = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
50
|
"body: ",
|
|
52
|
-
react_1.default.createElement(
|
|
51
|
+
react_1.default.createElement(common_1.Highlight2, null, "JSON"),
|
|
53
52
|
".",
|
|
54
|
-
react_1.default.createElement(
|
|
53
|
+
react_1.default.createElement(common_1.Highlight, null, "stringify"),
|
|
55
54
|
"(",
|
|
56
55
|
nice,
|
|
57
56
|
")"));
|
|
@@ -60,7 +59,7 @@ const getRequestOptions = (p, ops) => {
|
|
|
60
59
|
lb,
|
|
61
60
|
react_1.default.createElement(Lpad, null,
|
|
62
61
|
"method: ",
|
|
63
|
-
react_1.default.createElement(
|
|
62
|
+
react_1.default.createElement(common_1.Highlight, null,
|
|
64
63
|
"'",
|
|
65
64
|
ops.verb.toUpperCase(),
|
|
66
65
|
"'"),
|