@scalar/helpers 0.2.2 → 0.2.4
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 +13 -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/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,18 @@
|
|
|
1
1
|
# @scalar/helpers
|
|
2
2
|
|
|
3
|
+
## 0.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7581](https://github.com/scalar/scalar/pull/7581): fix: npm publish job
|
|
8
|
+
- [#7567](https://github.com/scalar/scalar/pull/7567): feat: add code samples to client v2
|
|
9
|
+
|
|
10
|
+
## 0.2.3
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#7575](https://github.com/scalar/scalar/pull/7575): feat: add support for object examples + hide body when empty
|
|
15
|
+
|
|
3
16
|
## 0.2.2
|
|
4
17
|
|
|
5
18
|
### 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
|
+
}
|
|
@@ -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.4",
|
|
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.0"
|
|
95
95
|
},
|
|
96
96
|
"scripts": {
|
|
97
97
|
"build": "scalar-build-esbuild",
|