@cybearl/cypack 1.8.12 → 1.8.14

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/README.md CHANGED
@@ -65,6 +65,7 @@ Frontend utilities
65
65
  #### Cybearl General API System
66
66
  - `getCGASStatus`: Returns the current status of the application, or the application marker only if specified,
67
67
  in the Cybearl General API System (CGAS) format.
68
+ - `fallbackCGASStatus`: The fallback CGAS status, used when the CGAS API is not available.
68
69
 
69
70
  #### URLs utilities
70
71
  Contains utilities to manipulate URLs.
package/frontend.d.ts CHANGED
@@ -82,6 +82,10 @@ type RequestResult<T> = ({ success: true } & SuccessfulRequest<T>) | ({ success:
82
82
  */
83
83
  declare function getCGASStatus(markerOnly: true, baseUrl?: string): Promise<RequestResult<string>>;
84
84
  declare function getCGASStatus(markerOnly?: false, baseUrl?: string): Promise<RequestResult<CGASStatus>>;
85
+ /**
86
+ * The fallback CGAS status, used when the CGAS API is not available.
87
+ */
88
+ declare const fallbackCGASStatus: CGASStatus;
85
89
 
86
90
  /**
87
91
  * Allows to add query parameters to a URL.
@@ -97,4 +101,4 @@ declare function addParamsToUrl(baseUrl: string, params: {
97
101
  */
98
102
  declare const currentUrlOrigin: string | null;
99
103
 
100
- export { addParamsToUrl, currentUrlOrigin, getCGASStatus };
104
+ export { addParamsToUrl, currentUrlOrigin, fallbackCGASStatus, getCGASStatus };
package/frontend.js CHANGED
@@ -1,2 +1,2 @@
1
- async function o(n=false,r="/api/cgas"){return await(await fetch(`${r}/status?markerOnly=${n}`)).json()}function i(n,r){let e=n;for(let[s,t]of Object.entries(r))t==null||t===""||t==="null"||t==="undefined"||(e+=`${e.includes("?")?"&":"?"}${encodeURIComponent(s)}=${encodeURIComponent(t.toString())}`);return e}var u=typeof window<"u"&&window.location.origin?window.location.origin:null;export{i as addParamsToUrl,u as currentUrlOrigin,o as getCGASStatus};//# sourceMappingURL=frontend.js.map
1
+ async function a(n=false,s="/api/cgas"){return await(await fetch(`${s}/status?markerOnly=${n}`)).json()}var o={status:"disabled",marker:"fallback-marker",timestamp:new Date().toISOString(),version:{raw:"unavailable",formatted:"unavailable"},message:"This API is not available, please try again later."};function i(n,s){let e=n;for(let[r,t]of Object.entries(s))t==null||t===""||t==="null"||t==="undefined"||(e+=`${e.includes("?")?"&":"?"}${encodeURIComponent(r)}=${encodeURIComponent(t.toString())}`);return e}var u=typeof window<"u"&&window.location.origin?window.location.origin:null;export{i as addParamsToUrl,u as currentUrlOrigin,o as fallbackCGASStatus,a as getCGASStatus};//# sourceMappingURL=frontend.js.map
2
2
  //# sourceMappingURL=frontend.js.map
package/frontend.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/frontend/cgas/status.ts","../src/frontend/urls.ts"],"names":["getCGASStatus","markerOnly","baseUrl","addParamsToUrl","params","url","key","value","currentUrlOrigin"],"mappings":"AAWA,eAAsBA,EACrBC,CAAAA,CAAa,KAAA,CACbC,CAAAA,CAAU,WAAA,CACoC,CAG9C,OADe,KAAA,CADE,MAAM,KAAA,CAAM,GAAGA,CAAO,CAAA,mBAAA,EAAsBD,CAAU,CAAA,CAAE,GAC3C,IAAA,EAE/B,CCZO,SAASE,EACfD,CAAAA,CACAE,CAAAA,CAGC,CACD,IAAIC,EAAMH,CAAAA,CAEV,IAAA,GAAW,CAACI,CAAAA,CAAKC,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQH,CAAM,EACpBG,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,EAAA,EAAMA,IAAU,MAAA,EAAUA,CAAAA,GAAU,WAAA,GAI3FF,CAAAA,EAAO,GAAGA,CAAAA,CAAI,QAAA,CAAS,GAAG,CAAA,CAAI,IAAM,GAAG,CAAA,EAAG,kBAAA,CAAmBC,CAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBC,CAAAA,CAAM,QAAA,EAAU,CAAC,CAAA,CAAA,CAAA,CAG1G,OAAOF,CACR,CAKO,IAAMG,CAAAA,CAAmB,OAAO,MAAA,CAAW,KAAe,MAAA,CAAO,QAAA,CAAS,MAAA,CAAS,MAAA,CAAO,SAAS,MAAA,CAAS","file":"frontend.js","sourcesContent":["import type { CGASStatus } from \"@/main/types/cgas\"\nimport type { RequestResult } from \"@/main/types/requests\"\n\n/**\n * Get the status of the application via the CGAS API endpoint (that itself uses the `getCGASStatus` function).\n * @param markerOnly Whether to only return the marker (optional, defaults to false).\n * @param baseUrl The base URL of the CGAS API (optional, defaults to \"/api/cgas\").\n * @returns The status of the application, or the marker if `markerOnly` is true.\n */\nexport async function getCGASStatus(markerOnly: true, baseUrl?: string): Promise<RequestResult<string>>\nexport async function getCGASStatus(markerOnly?: false, baseUrl?: string): Promise<RequestResult<CGASStatus>>\nexport async function getCGASStatus(\n\tmarkerOnly = false,\n\tbaseUrl = \"/api/cgas\",\n): Promise<RequestResult<CGASStatus | string>> {\n\tconst response = await fetch(`${baseUrl}/status?markerOnly=${markerOnly}`)\n\tconst result = await response.json()\n\treturn result as RequestResult<CGASStatus | string>\n}\n","/**\n * Allows to add query parameters to a URL.\n * @param baseUrl The base URL to add parameters to.\n * @param params The parameters to add, note that each parameter will be URL-encoded.\n * @returns The URL with the parameters added.\n */\nexport function addParamsToUrl(\n\tbaseUrl: string,\n\tparams: {\n\t\t[key: string]: string | number | boolean | undefined | null\n\t},\n) {\n\tlet url = baseUrl\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tif (value === undefined || value === null || value === \"\" || value === \"null\" || value === \"undefined\") {\n\t\t\tcontinue\n\t\t}\n\n\t\turl += `${url.includes(\"?\") ? \"&\" : \"?\"}${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`\n\t}\n\n\treturn url\n}\n\n/**\n * Get the current URL origin or null if it's not available.\n */\nexport const currentUrlOrigin = typeof window !== \"undefined\" && window.location.origin ? window.location.origin : null\n"]}
1
+ {"version":3,"sources":["../src/frontend/cgas/status.ts","../src/frontend/urls.ts"],"names":["getCGASStatus","markerOnly","baseUrl","fallbackCGASStatus","addParamsToUrl","params","url","key","value","currentUrlOrigin"],"mappings":"AAWA,eAAsBA,CAAAA,CACrBC,EAAa,KAAA,CACbC,CAAAA,CAAU,YACoC,CAG9C,OADe,MADE,MAAM,KAAA,CAAM,GAAGA,CAAO,CAAA,mBAAA,EAAsBD,CAAU,CAAA,CAAE,CAAA,EAC3C,MAE/B,CAKO,IAAME,CAAAA,CAAiC,CAC7C,MAAA,CAAQ,WACR,MAAA,CAAQ,iBAAA,CACR,UAAW,IAAI,IAAA,GAAO,WAAA,EAAY,CAClC,OAAA,CAAS,CACR,GAAA,CAAK,aAAA,CACL,UAAW,aACZ,CAAA,CACA,QAAS,oDACV,EC1BO,SAASC,CAAAA,CACfF,CAAAA,CACAG,CAAAA,CAGC,CACD,IAAIC,CAAAA,CAAMJ,EAEV,IAAA,GAAW,CAACK,EAAKC,CAAK,CAAA,GAAK,OAAO,OAAA,CAAQH,CAAM,CAAA,CACpBG,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,IAAMA,CAAAA,GAAU,MAAA,EAAUA,IAAU,WAAA,GAI3FF,CAAAA,EAAO,GAAGA,CAAAA,CAAI,QAAA,CAAS,GAAG,CAAA,CAAI,GAAA,CAAM,GAAG,GAAG,kBAAA,CAAmBC,CAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBC,EAAM,QAAA,EAAU,CAAC,CAAA,CAAA,CAAA,CAG1G,OAAOF,CACR,CAKO,IAAMG,CAAAA,CAAmB,OAAO,MAAA,CAAW,GAAA,EAAe,OAAO,QAAA,CAAS,MAAA,CAAS,MAAA,CAAO,QAAA,CAAS,MAAA,CAAS","file":"frontend.js","sourcesContent":["import type { CGASStatus } from \"@/main/types/cgas\"\nimport type { RequestResult } from \"@/main/types/requests\"\n\n/**\n * Get the status of the application via the CGAS API endpoint (that itself uses the `getCGASStatus` function).\n * @param markerOnly Whether to only return the marker (optional, defaults to false).\n * @param baseUrl The base URL of the CGAS API (optional, defaults to \"/api/cgas\").\n * @returns The status of the application, or the marker if `markerOnly` is true.\n */\nexport async function getCGASStatus(markerOnly: true, baseUrl?: string): Promise<RequestResult<string>>\nexport async function getCGASStatus(markerOnly?: false, baseUrl?: string): Promise<RequestResult<CGASStatus>>\nexport async function getCGASStatus(\n\tmarkerOnly = false,\n\tbaseUrl = \"/api/cgas\",\n): Promise<RequestResult<CGASStatus | string>> {\n\tconst response = await fetch(`${baseUrl}/status?markerOnly=${markerOnly}`)\n\tconst result = await response.json()\n\treturn result as RequestResult<CGASStatus | string>\n}\n\n/**\n * The fallback CGAS status, used when the CGAS API is not available.\n */\nexport const fallbackCGASStatus: CGASStatus = {\n\tstatus: \"disabled\",\n\tmarker: \"fallback-marker\",\n\ttimestamp: new Date().toISOString(),\n\tversion: {\n\t\traw: \"unavailable\",\n\t\tformatted: \"unavailable\",\n\t},\n\tmessage: \"This API is not available, please try again later.\",\n}\n","/**\n * Allows to add query parameters to a URL.\n * @param baseUrl The base URL to add parameters to.\n * @param params The parameters to add, note that each parameter will be URL-encoded.\n * @returns The URL with the parameters added.\n */\nexport function addParamsToUrl(\n\tbaseUrl: string,\n\tparams: {\n\t\t[key: string]: string | number | boolean | undefined | null\n\t},\n) {\n\tlet url = baseUrl\n\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tif (value === undefined || value === null || value === \"\" || value === \"null\" || value === \"undefined\") {\n\t\t\tcontinue\n\t\t}\n\n\t\turl += `${url.includes(\"?\") ? \"&\" : \"?\"}${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`\n\t}\n\n\treturn url\n}\n\n/**\n * Get the current URL origin or null if it's not available.\n */\nexport const currentUrlOrigin = typeof window !== \"undefined\" && window.location.origin ? window.location.origin : null\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cybearl/cypack",
3
3
  "productName": "CyPack",
4
- "version": "1.8.12",
4
+ "version": "1.8.14",
5
5
  "description": "A set of general utilities for Cybearl projects.",
6
6
  "author": "Cybearl <contact@cybearl.com> (https://www.cybearl.com/)",
7
7
  "license": "MIT",