@scalar/helpers 0.2.2 → 0.2.5
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/CHANGELOG.md +19 -0
- package/dist/array/add-to-map-array.d.ts +5 -0
- package/dist/array/add-to-map-array.d.ts.map +1 -0
- package/dist/array/add-to-map-array.js +9 -0
- package/dist/array/add-to-map-array.js.map +7 -0
- package/dist/object/local-storage.d.ts +16 -5
- package/dist/object/local-storage.d.ts.map +1 -1
- package/dist/object/local-storage.js +16 -5
- package/dist/object/local-storage.js.map +2 -2
- package/dist/object/object-entries.d.ts +3 -0
- package/dist/object/object-entries.d.ts.map +1 -0
- package/dist/object/object-entries.js +5 -0
- package/dist/object/object-entries.js.map +7 -0
- package/dist/regex/replace-variables.d.ts +2 -1
- package/dist/regex/replace-variables.d.ts.map +1 -1
- package/dist/regex/replace-variables.js.map +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @scalar/helpers
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7605](https://github.com/scalar/scalar/pull/7605): fix: all issues for client modal v2 preparation
|
|
8
|
+
|
|
9
|
+
## 0.2.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#7581](https://github.com/scalar/scalar/pull/7581): fix: npm publish job
|
|
14
|
+
- [#7567](https://github.com/scalar/scalar/pull/7567): feat: add code samples to client v2
|
|
15
|
+
|
|
16
|
+
## 0.2.3
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [#7575](https://github.com/scalar/scalar/pull/7575): feat: add support for object examples + hide body when empty
|
|
21
|
+
|
|
3
22
|
## 0.2.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to-map-array.d.ts","sourceRoot":"","sources":["../../src/array/add-to-map-array.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,MAAM,EAAE,OAAO,OAAO,SAIrF,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/array/add-to-map-array.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * A little helper to add a value to a map array where the type is Map<string, any[]>\n */\nexport const addToMapArray = (map: Map<string, unknown[]>, key: string, value: unknown) => {\n const prev = map.get(key) ?? []\n prev.push(value)\n map.set(key, prev)\n}\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,gBAAgB,CAAC,KAA6B,KAAa,UAAmB;AACzF,QAAM,OAAO,IAAI,IAAI,GAAG,KAAK,CAAC;AAC9B,OAAK,KAAK,KAAK;AACf,MAAI,IAAI,KAAK,IAAI;AACnB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,22 +18,33 @@ export declare const LS_KEYS: {
|
|
|
18
18
|
* to ensure we do not have any conflicts
|
|
19
19
|
*/
|
|
20
20
|
export declare const REFERENCE_LS_KEYS: {
|
|
21
|
-
/**
|
|
22
|
-
* We should remove after some time as we no longer store an object
|
|
23
|
-
* @deprecated
|
|
24
|
-
*/
|
|
25
|
-
readonly SELECTED_CLIENT_DEPRECATED: "scalar-reference-selected-client";
|
|
26
21
|
/**
|
|
27
22
|
* Store the selected client as a string in localStorage
|
|
28
23
|
*/
|
|
29
24
|
readonly SELECTED_CLIENT: "scalar-reference-selected-client-v2";
|
|
25
|
+
/**
|
|
26
|
+
* Store the auth schemes as a string in localStorage
|
|
27
|
+
*/
|
|
28
|
+
readonly AUTH_SCHEMES: "scalar-reference-auth-schemes";
|
|
29
|
+
/**
|
|
30
|
+
* Store the selected auth schemes as a string in localStorage
|
|
31
|
+
*/
|
|
32
|
+
readonly SELECTED_AUTH_SCHEMES: "scalar-reference-selected-auth-schemes";
|
|
30
33
|
};
|
|
31
34
|
/**
|
|
32
35
|
* localStorage keys for all client resources
|
|
33
36
|
* to ensure we do not have any conflicts
|
|
34
37
|
*/
|
|
35
38
|
export declare const CLIENT_LS_KEYS: {
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated This key is deprecated and will be removed in a future release.
|
|
41
|
+
* We are now storing the entire document for the api-client instead.
|
|
42
|
+
*/
|
|
36
43
|
readonly AUTH: "scalar-client-auth";
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated This key is deprecated and will be removed in a future release.
|
|
46
|
+
* We are now storing the entire document for the api-client instead.
|
|
47
|
+
*/
|
|
37
48
|
readonly SELECTED_SECURITY_SCHEMES: "scalar-client-selected-security-schemes";
|
|
38
49
|
};
|
|
39
50
|
/** SSR safe alias for localStorage */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/object/local-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../../src/object/local-storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;CAUV,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAA;AAEV;;;GAGG;AACH,eAAO,MAAM,cAAc;IACzB;;;OAGG;;IAEH;;;OAGG;;CAEK,CAAA;AAEV,sCAAsC;AACtC,eAAO,MAAM,gBAAgB;;;;CAOX,CAAA"}
|
|
@@ -11,17 +11,28 @@ const LS_KEYS = {
|
|
|
11
11
|
};
|
|
12
12
|
const REFERENCE_LS_KEYS = {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @deprecated
|
|
14
|
+
* Store the selected client as a string in localStorage
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
SELECTED_CLIENT: "scalar-reference-selected-client-v2",
|
|
18
17
|
/**
|
|
19
|
-
* Store the
|
|
18
|
+
* Store the auth schemes as a string in localStorage
|
|
19
|
+
*/
|
|
20
|
+
AUTH_SCHEMES: "scalar-reference-auth-schemes",
|
|
21
|
+
/**
|
|
22
|
+
* Store the selected auth schemes as a string in localStorage
|
|
20
23
|
*/
|
|
21
|
-
|
|
24
|
+
SELECTED_AUTH_SCHEMES: "scalar-reference-selected-auth-schemes"
|
|
22
25
|
};
|
|
23
26
|
const CLIENT_LS_KEYS = {
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated This key is deprecated and will be removed in a future release.
|
|
29
|
+
* We are now storing the entire document for the api-client instead.
|
|
30
|
+
*/
|
|
24
31
|
AUTH: "scalar-client-auth",
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated This key is deprecated and will be removed in a future release.
|
|
34
|
+
* We are now storing the entire document for the api-client instead.
|
|
35
|
+
*/
|
|
25
36
|
SELECTED_SECURITY_SCHEMES: "scalar-client-selected-security-schemes"
|
|
26
37
|
};
|
|
27
38
|
const safeLocalStorage = () => typeof window === "undefined" ? {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/object/local-storage.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * localStorage keys for resources\n * DO NOT CHANGE THESE AS IT WILL BREAK THE MIGRATION\n */\nexport const LS_KEYS = {\n COLLECTION: 'collection',\n COOKIE: 'cookie',\n ENVIRONMENT: 'environment',\n REQUEST: 'request',\n REQUEST_EXAMPLE: 'requestExample',\n SECURITY_SCHEME: 'securityScheme',\n SERVER: 'server',\n TAG: 'tag',\n WORKSPACE: 'workspace',\n} as const\n\n/**\n * localStorage keys for all reference resources\n * to ensure we do not have any conflicts\n */\nexport const REFERENCE_LS_KEYS = {\n /**\n *
|
|
5
|
-
"mappings": "AAIO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,WAAW;AACb;AAMO,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA
|
|
4
|
+
"sourcesContent": ["/**\n * localStorage keys for resources\n * DO NOT CHANGE THESE AS IT WILL BREAK THE MIGRATION\n */\nexport const LS_KEYS = {\n COLLECTION: 'collection',\n COOKIE: 'cookie',\n ENVIRONMENT: 'environment',\n REQUEST: 'request',\n REQUEST_EXAMPLE: 'requestExample',\n SECURITY_SCHEME: 'securityScheme',\n SERVER: 'server',\n TAG: 'tag',\n WORKSPACE: 'workspace',\n} as const\n\n/**\n * localStorage keys for all reference resources\n * to ensure we do not have any conflicts\n */\nexport const REFERENCE_LS_KEYS = {\n /**\n * Store the selected client as a string in localStorage\n */\n SELECTED_CLIENT: 'scalar-reference-selected-client-v2',\n /**\n * Store the auth schemes as a string in localStorage\n */\n AUTH_SCHEMES: 'scalar-reference-auth-schemes',\n /**\n * Store the selected auth schemes as a string in localStorage\n */\n SELECTED_AUTH_SCHEMES: 'scalar-reference-selected-auth-schemes',\n} as const\n\n/**\n * localStorage keys for all client resources\n * to ensure we do not have any conflicts\n */\nexport const CLIENT_LS_KEYS = {\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n AUTH: 'scalar-client-auth',\n /**\n * @deprecated This key is deprecated and will be removed in a future release.\n * We are now storing the entire document for the api-client instead.\n */\n SELECTED_SECURITY_SCHEMES: 'scalar-client-selected-security-schemes',\n} as const\n\n/** SSR safe alias for localStorage */\nexport const safeLocalStorage = () =>\n typeof window === 'undefined'\n ? {\n getItem: () => null,\n setItem: () => null,\n removeItem: () => null,\n }\n : localStorage\n"],
|
|
5
|
+
"mappings": "AAIO,MAAM,UAAU;AAAA,EACrB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,WAAW;AACb;AAMO,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA,EAI/B,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAIjB,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,uBAAuB;AACzB;AAMO,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5B,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA,EAKN,2BAA2B;AAC7B;AAGO,MAAM,mBAAmB,MAC9B,OAAO,WAAW,cACd;AAAA,EACE,SAAS,MAAM;AAAA,EACf,SAAS,MAAM;AAAA,EACf,YAAY,MAAM;AACpB,IACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-entries.d.ts","sourceRoot":"","sources":["../../src/object/object-entries.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,KAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAC9B,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/object/object-entries.ts"],
|
|
4
|
+
"sourcesContent": ["/** Type safe version of Object.entries */\nexport const objectEntries = <T extends object>(obj: T): [keyof T, T[keyof T]][] =>\n Object.entries(obj) as [keyof T, T[keyof T]][]\n"],
|
|
5
|
+
"mappings": "AACO,MAAM,gBAAgB,CAAmB,QAC9C,OAAO,QAAQ,GAAG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This function takes a string and
|
|
2
|
+
* This function takes a string and replaces both {single} and {{double}} curly brace variables with given values.
|
|
3
|
+
* Use the replacePathVariables and replaceEnvVariables functions if you only need to replace one type of variable.
|
|
3
4
|
*/
|
|
4
5
|
export declare function replaceVariables(value: string, variablesOrCallback: Record<string, string | number> | ((match: string) => string)): string;
|
|
5
6
|
/** Replace {path} variables with their values */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-variables.d.ts","sourceRoot":"","sources":["../../src/regex/replace-variables.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"replace-variables.d.ts","sourceRoot":"","sources":["../../src/regex/replace-variables.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,UAenF;AAED,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,EAAE,YAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,WACtB,CAAA;AAEnE,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,EAAE,YAAW,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,WAChB,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/regex/replace-variables.ts"],
|
|
4
|
-
"sourcesContent": ["import { REGEX } from '@/regex/regex-helpers'\n\n/**\n * This function takes a string and
|
|
5
|
-
"mappings": "AAAA,SAAS,aAAa;
|
|
4
|
+
"sourcesContent": ["import { REGEX } from '@/regex/regex-helpers'\n\n/**\n * This function takes a string and replaces both {single} and {{double}} curly brace variables with given values.\n * Use the replacePathVariables and replaceEnvVariables functions if you only need to replace one type of variable.\n */\nexport function replaceVariables(\n value: string,\n variablesOrCallback: Record<string, string | number> | ((match: string) => string),\n) {\n // Replace all variables (example: {{ baseurl }} with an HTML tag)\n const doubleCurlyBrackets = /{{\\s*([\\w.-]+)\\s*}}/g\n const singleCurlyBrackets = /{\\s*([\\w.-]+)\\s*}/g\n\n const callback = (_: string, match: string): string => {\n if (typeof variablesOrCallback === 'function') {\n return variablesOrCallback(match)\n }\n return variablesOrCallback[match]?.toString() || `{${match}}`\n }\n\n // Loop through all matches and replace the match with the variable value\n return value.replace(doubleCurlyBrackets, callback).replace(singleCurlyBrackets, callback)\n}\n\n/** Replace {path} variables with their values */\nexport const replacePathVariables = (path: string, variables: Record<string, string> = {}) =>\n path.replace(REGEX.PATH, (match, key) => variables[key] ?? match)\n\n/** Replace {{env}} variables with their values */\nexport const replaceEnvVariables = (path: string, variables: Record<string, string> = {}) =>\n path.replace(REGEX.VARIABLES, (match, key) => variables[key] ?? match)\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AAMf,SAAS,iBACd,OACA,qBACA;AAEA,QAAM,sBAAsB;AAC5B,QAAM,sBAAsB;AAE5B,QAAM,WAAW,CAAC,GAAW,UAA0B;AACrD,QAAI,OAAO,wBAAwB,YAAY;AAC7C,aAAO,oBAAoB,KAAK;AAAA,IAClC;AACA,WAAO,oBAAoB,KAAK,GAAG,SAAS,KAAK,IAAI,KAAK;AAAA,EAC5D;AAGA,SAAO,MAAM,QAAQ,qBAAqB,QAAQ,EAAE,QAAQ,qBAAqB,QAAQ;AAC3F;AAGO,MAAM,uBAAuB,CAAC,MAAc,YAAoC,CAAC,MACtF,KAAK,QAAQ,MAAM,MAAM,CAAC,OAAO,QAAQ,UAAU,GAAG,KAAK,KAAK;AAG3D,MAAM,sBAAsB,CAAC,MAAc,YAAoC,CAAC,MACrF,KAAK,QAAQ,MAAM,WAAW,CAAC,OAAO,QAAQ,UAAU,GAAG,KAAK,KAAK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"helpers",
|
|
15
15
|
"js"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.2.
|
|
17
|
+
"version": "0.2.5",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"jsdom": "26.1.0",
|
|
92
92
|
"vite": "7.1.11",
|
|
93
93
|
"vitest": "3.2.4",
|
|
94
|
-
"@scalar/build-tooling": "0.
|
|
94
|
+
"@scalar/build-tooling": "0.4.1"
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
97
|
"build": "scalar-build-esbuild",
|