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.
Files changed (56) hide show
  1. package/dist/api/helpers/api.js +1 -1
  2. package/dist/api/helpers/enforceDynamoProvisionCap.js +4 -3
  3. package/dist/api/helpers/sqs.js +2 -2
  4. package/dist/api/helpers/ssm.js +2 -2
  5. package/dist/common/helpers/binary.js +3 -3
  6. package/dist/common/helpers/string/base64.d.ts +2 -0
  7. package/dist/common/helpers/string/base64.js +7 -0
  8. package/dist/common/helpers/string/chunk.d.ts +1 -0
  9. package/dist/common/helpers/string/chunk.js +5 -0
  10. package/dist/common/helpers/string/contains.d.ts +20 -0
  11. package/dist/common/helpers/string/contains.js +33 -0
  12. package/dist/common/helpers/string/getExtendedStringSegment.d.ts +19 -0
  13. package/dist/common/helpers/string/getExtendedStringSegment.js +44 -0
  14. package/dist/common/helpers/string/index.d.ts +10 -0
  15. package/dist/common/helpers/string/index.js +26 -0
  16. package/dist/common/helpers/string/json.d.ts +7 -0
  17. package/dist/common/helpers/string/json.js +21 -0
  18. package/dist/common/helpers/string/object.d.ts +7 -0
  19. package/dist/common/helpers/string/object.js +23 -0
  20. package/dist/common/helpers/string/surround.d.ts +8 -0
  21. package/dist/common/helpers/string/surround.js +10 -0
  22. package/dist/common/helpers/string/trim.d.ts +2 -0
  23. package/dist/common/helpers/string/trim.js +24 -0
  24. package/dist/common/helpers/string/truncate.d.ts +1 -0
  25. package/dist/common/helpers/string/truncate.js +10 -0
  26. package/dist/common/helpers/string/url.d.ts +9 -0
  27. package/dist/common/helpers/string/url.js +31 -0
  28. package/dist/ui/components/Confirm/Modal.js +1 -1
  29. package/dist/ui/components/DashboardAuthValidation/index.js +2 -2
  30. package/dist/ui/components/HeadersRaw/index.js +1 -1
  31. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +2 -4
  32. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +4 -4
  33. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +11 -12
  34. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +13 -3
  35. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +2 -2
  36. package/dist/ui/components/Prompt/Modal.js +1 -1
  37. package/dist/ui/components/Search/AutoHideSearchBox.js +2 -2
  38. package/dist/ui/components/Search/Base.js +2 -2
  39. package/dist/ui/components/Search/Dialog.js +2 -2
  40. package/dist/ui/components/Search/SearchBox.js +4 -3
  41. package/dist/ui/components/Toast/base.js +2 -2
  42. package/dist/ui/helpers/axiosHelper.js +4 -3
  43. package/dist/ui/helpers/callOpenApi/cached.js +4 -4
  44. package/dist/ui/helpers/cookie/get.d.ts +0 -4
  45. package/dist/ui/helpers/cookie/get.js +6 -21
  46. package/dist/ui/helpers/cookie/index.d.ts +1 -0
  47. package/dist/ui/helpers/cookie/index.js +1 -0
  48. package/dist/ui/helpers/cookie/raw.d.ts +26 -0
  49. package/dist/ui/helpers/cookie/raw.js +67 -0
  50. package/dist/ui/helpers/cookie/set.d.ts +0 -1
  51. package/dist/ui/helpers/cookie/set.js +8 -43
  52. package/dist/ui/helpers/routes.js +2 -2
  53. package/dist/ui/helpers/useQueryString.js +2 -2
  54. package/package.json +1 -1
  55. package/dist/common/helpers/string.d.ts +0 -64
  56. package/dist/common/helpers/string.js +0 -210
@@ -1,210 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidUrl = exports.indexOfNumber = exports.stringToObject = exports.chunkString = exports.safeStringify = exports.containsInsensitive = exports.containsInsensitiveIndex = exports.replaceRemove = exports.toTitleCase = exports.niceUrl = exports.truncate = exports.trim = exports.trimSide = exports.csvJSON = 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;
8
- const csvJSON = (csv) => {
9
- const lines = csv.split('\n');
10
- const result = [];
11
- // NOTE: If your columns contain commas in their values, you'll need
12
- // to deal with those before doing the next step
13
- // (you might convert them to &&& or something, then covert them back later)
14
- // jsfiddle showing the issue https://jsfiddle.net/
15
- const headers = lines[0].split(',');
16
- for (let i = 1; i < lines.length; i += 1) {
17
- const obj = {};
18
- const currentline = lines[i].split(',');
19
- for (let j = 0; j < headers.length; j += 1) {
20
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
- // @ts-ignore
22
- obj[headers[j]] = currentline[j];
23
- }
24
- result.push(obj);
25
- }
26
- return result;
27
- };
28
- exports.csvJSON = csvJSON;
29
- function trimSide(str, fromStart = true, ...params) {
30
- const pstr = params.join('');
31
- if (!str) {
32
- return str;
33
- }
34
- const ret = str.replace(new RegExp(`[${pstr}]*$`, 'g'), '');
35
- if (fromStart) {
36
- return ret.replace(new RegExp(`^[${pstr}]*`, 'g'), '');
37
- }
38
- return ret;
39
- }
40
- exports.trimSide = trimSide;
41
- function trim(str, ...params) {
42
- if (!str) {
43
- return '';
44
- }
45
- str = trimSide(str, true, ...params);
46
- str = trimSide(str, false, ...params);
47
- return str;
48
- }
49
- exports.trim = trim;
50
- function truncate(str, n, ellip) {
51
- if (!str) {
52
- return undefined;
53
- }
54
- return str.length > n ? str.substr(0, n - 1) + ellip : str;
55
- }
56
- exports.truncate = truncate;
57
- /**
58
- * removes protocol, and trailing slashes
59
- */
60
- const niceUrl = (siteUrl) => {
61
- if (!siteUrl) {
62
- return undefined;
63
- }
64
- let niceSiteUrl = siteUrl
65
- .substring(siteUrl.indexOf(':') + 1)
66
- .replace('sc-domain:', '')
67
- .replace('https://', '')
68
- .replace('http://', '');
69
- niceSiteUrl = trim(niceSiteUrl, '/');
70
- return { siteUrl, niceSiteUrl };
71
- };
72
- exports.niceUrl = niceUrl;
73
- /**
74
- * string -> String
75
- * @param str
76
- * @returns
77
- */
78
- function toTitleCase(str) {
79
- if (!str) {
80
- return str;
81
- }
82
- return str.replace(/\w\S*/g, (txt) => txt && txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase());
83
- }
84
- exports.toTitleCase = toTitleCase;
85
- /**
86
- * remove all found params from str
87
- * @param str
88
- * @param params allows single chars and/or strings
89
- * @returns
90
- */
91
- function replaceRemove(str, ...params) {
92
- const replaceSingles = [];
93
- const replaceStrings = [];
94
- params.forEach((p) => {
95
- if (typeof p !== 'string') {
96
- throw new Error('trim only supports strings');
97
- }
98
- if (p.length === 1) {
99
- replaceSingles.push(p);
100
- }
101
- else {
102
- replaceStrings.push(p);
103
- }
104
- });
105
- let firstLength = 0;
106
- let changedLength = 0;
107
- let ret = str;
108
- const singleRegex = `[${replaceSingles.join('')}]*`;
109
- const stringRegex = `(${replaceStrings.map((s) => `(${s})`).join('|')})*`;
110
- do {
111
- firstLength = ret.length;
112
- ret = ret.replace(new RegExp(stringRegex, 'gim'), '');
113
- ret = ret.replace(new RegExp(singleRegex, 'gim'), '');
114
- changedLength = ret.length;
115
- } while (changedLength < firstLength);
116
- return ret;
117
- }
118
- exports.replaceRemove = replaceRemove;
119
- /**
120
- * returns >-1 if found
121
- * @param str
122
- * @param args
123
- * @returns
124
- */
125
- function containsInsensitiveIndex({ str, fromLast = false, }, ...args) {
126
- if (!str || !args) {
127
- return -1;
128
- }
129
- const largs = args.map((a) => a.toLowerCase());
130
- const lstr = str.toLowerCase();
131
- const finds = largs
132
- .map((arg) => (fromLast ? lstr.lastIndexOf(arg) : lstr.indexOf(arg)))
133
- .filter((s) => s !== -1)
134
- .sort();
135
- if (finds.length === 0) {
136
- return -1;
137
- }
138
- return !fromLast ? finds[0] : finds[finds.length - 1];
139
- }
140
- exports.containsInsensitiveIndex = containsInsensitiveIndex;
141
- /**
142
- * returns true if text is found
143
- * @param str
144
- * @param args
145
- * @returns
146
- */
147
- const containsInsensitive = (str, ...args) => containsInsensitiveIndex({ str }, ...args) !== -1;
148
- exports.containsInsensitive = containsInsensitive;
149
- /**
150
- * safely handles circular references
151
- * @param obj
152
- * @param indent
153
- * @returns
154
- */
155
- const safeStringify = (obj, indent = 2) => {
156
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
- let cache = [];
158
- const retVal = JSON.stringify(obj, (_key, value) => typeof value === 'object' && value !== null
159
- ? cache.includes(value)
160
- ? undefined // Duplicate reference found, discard key
161
- : cache.push(value) && value // Store value in our collection
162
- : value, indent);
163
- cache = null;
164
- return retVal;
165
- };
166
- exports.safeStringify = safeStringify;
167
- const chunkString = (str, length) => str.match(new RegExp(`.{1,${length}}`, 'g'));
168
- exports.chunkString = chunkString;
169
- /**
170
- * object to string - can be used for querystring a=b&c=d etc
171
- * @param raw eg a=b&c=d
172
- * @param splitKeyValue eg =
173
- * @param splitKeys eg &
174
- */
175
- function stringToObject(raw, splitKeyValue, splitKeys) {
176
- const ret = {};
177
- if (!stringToObject) {
178
- return ret;
179
- }
180
- raw.split(splitKeys).forEach((set) => {
181
- const [k, v] = set.split(splitKeyValue);
182
- if (k) {
183
- ret[k] = v;
184
- }
185
- });
186
- return ret;
187
- }
188
- exports.stringToObject = stringToObject;
189
- const indexOfNumber = (str, char, num = 0) => {
190
- let ret = -1;
191
- for (let c = 0; c <= num; c += 1) {
192
- ret = str.indexOf(char, ret + 1);
193
- }
194
- if (ret === -1) {
195
- return undefined;
196
- }
197
- return ret;
198
- };
199
- exports.indexOfNumber = indexOfNumber;
200
- function isValidUrl(raw) {
201
- let url;
202
- try {
203
- url = new URL(raw);
204
- }
205
- catch (_) {
206
- return false;
207
- }
208
- return url.protocol === 'http:' || url.protocol === 'https:';
209
- }
210
- exports.isValidUrl = isValidUrl;