@ptx-showcase/utils 0.0.4 → 0.1.0
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 +1 -1
- package/dist/build-query-params/index.cjs +1 -0
- package/dist/build-query-params/index.d.ts +1 -0
- package/dist/build-query-params/index.js +11 -0
- package/dist/clean-object/index.cjs +1 -0
- package/dist/clean-object/index.d.ts +6 -0
- package/dist/clean-object/index.js +9 -0
- package/dist/cookies/index.cjs +1 -0
- package/dist/{cookie → cookies}/index.d.ts +5 -6
- package/dist/cookies/index.js +15 -0
- package/dist/cookies-DO7osa3F.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -6
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +0 -0
- package/package.json +28 -9
- package/dist/cookie/index.cjs +0 -1
- package/dist/cookie/index.js +0 -14
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ bun add @ptx-showcase/utils
|
|
|
23
23
|
### Cookie utilities
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { setCookie, getCookie, deleteCookie } from '@ptx-showcase/utils/
|
|
26
|
+
import { setCookie, getCookie, deleteCookie } from '@ptx-showcase/utils/cookies'
|
|
27
27
|
|
|
28
28
|
// set cookie
|
|
29
29
|
setCookie('token', '123')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>{let t=new URLSearchParams;Object.entries(e).forEach(([e,n])=>{n==null||n===``||t.append(e,String(n))});let n=t.toString();return n?`?${n}`:``};exports.buildQueryParams=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const buildQueryParams: (params: Record<string, unknown>) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/build-query-params/index.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = new URLSearchParams();
|
|
4
|
+
Object.entries(e).forEach(([e, n]) => {
|
|
5
|
+
n == null || n === "" || t.append(e, String(n));
|
|
6
|
+
});
|
|
7
|
+
let n = t.toString();
|
|
8
|
+
return n ? `?${n}` : "";
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as buildQueryParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>{let t={};return Object.entries(e).forEach(([e,n])=>{n!=null&&n!==``&&(t[e]=n)}),t};exports.cleanObject=e;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type EmptyValue = undefined | null | '';
|
|
2
|
+
export type CleanObjectResult<T extends Record<string, unknown>> = Partial<{
|
|
3
|
+
[K in keyof T]: Exclude<T[K], EmptyValue>;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const cleanObject: <T extends Record<string, unknown>>(obj: T) => CleanObjectResult<T>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../cookies-DO7osa3F.cjs`);exports.defaultCookieOptions=e.t,exports.deleteCookie=e.n,exports.getCookie=e.r,exports.setCookie=e.i;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const setCookie: (name: string, value: string, options?: CookieOptions) => void
|
|
4
|
-
export declare const getCookie: (name: string) => string | undefined
|
|
5
|
-
export declare const deleteCookie: (name: string, options?: CookieOptions) => void
|
|
6
|
-
export {}
|
|
1
|
+
export type CookieOptions = Cookies.CookieAttributes;
|
|
2
|
+
export declare const defaultCookieOptions: CookieOptions;
|
|
3
|
+
export declare const setCookie: (name: string, value: string, options?: CookieOptions) => void;
|
|
4
|
+
export declare const getCookie: (name: string) => string | undefined;
|
|
5
|
+
export declare const deleteCookie: (name: string, options?: CookieOptions) => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import e from "js-cookie";
|
|
2
|
+
var t = {
|
|
3
|
+
expires: 1 / 24,
|
|
4
|
+
secure: !0,
|
|
5
|
+
sameSite: "Strict"
|
|
6
|
+
}, n = (n, r, i) => {
|
|
7
|
+
e.set(n, r, {
|
|
8
|
+
...t,
|
|
9
|
+
...i
|
|
10
|
+
});
|
|
11
|
+
}, r = (t) => e.get(t), i = (t, n) => {
|
|
12
|
+
e.remove(t, n);
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { t as defaultCookieOptions, i as deleteCookie, r as getCookie, n as setCookie };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`js-cookie`);c=s(c,1);var l={expires:1/24,secure:!0,sameSite:`Strict`},u=(e,t,n)=>{c.default.set(e,t,{...l,...n})},d=e=>c.default.get(e),f=(e,t)=>{c.default.remove(e,t)};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./cookies-DO7osa3F.cjs`),t=require(`./build-query-params/index.cjs`),n=require(`./clean-object/index.cjs`);exports.buildQueryParams=t.buildQueryParams,exports.cleanObject=n.cleanObject,exports.defaultCookieOptions=e.t,exports.deleteCookie=e.n,exports.getCookie=e.r,exports.setCookie=e.i;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { e as hello };
|
|
1
|
+
import { buildQueryParams as e } from "./build-query-params/index.js";
|
|
2
|
+
import { cleanObject as t } from "./clean-object/index.js";
|
|
3
|
+
import { defaultCookieOptions as n, deleteCookie as r, getCookie as i, setCookie as a } from "./cookies/index.js";
|
|
4
|
+
export { e as buildQueryParams, t as cleanObject, n as defaultCookieOptions, r as deleteCookie, i as getCookie, a as setCookie };
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ptx-showcase/utils",
|
|
3
3
|
"author": "ptx-showcase",
|
|
4
4
|
"description": "Shared utilities for PTX Showcase projects",
|
|
5
|
-
"version": "0.0
|
|
5
|
+
"version": "0.1.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"license": "MIT",
|
|
@@ -31,14 +31,30 @@
|
|
|
31
31
|
"require": "./dist/index.cjs",
|
|
32
32
|
"types": "./dist/index.d.ts"
|
|
33
33
|
},
|
|
34
|
-
"./
|
|
35
|
-
"import": "./dist/
|
|
36
|
-
"require": "./dist/
|
|
37
|
-
"types": "./dist/
|
|
34
|
+
"./cookies": {
|
|
35
|
+
"import": "./dist/cookies/index.js",
|
|
36
|
+
"require": "./dist/cookies/index.cjs",
|
|
37
|
+
"types": "./dist/cookies/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./build-query-params": {
|
|
40
|
+
"import": "./dist/build-query-params/index.js",
|
|
41
|
+
"require": "./dist/build-query-params/index.cjs",
|
|
42
|
+
"types": "./dist/build-query-params/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./clean-object": {
|
|
45
|
+
"import": "./dist/clean-object/index.js",
|
|
46
|
+
"require": "./dist/clean-object/index.cjs",
|
|
47
|
+
"types": "./dist/clean-object/index.d.ts"
|
|
48
|
+
},
|
|
49
|
+
"./types": {
|
|
50
|
+
"import": "./dist/types/index.js",
|
|
51
|
+
"require": "./dist/types/index.cjs",
|
|
52
|
+
"types": "./dist/types/index.d.ts"
|
|
38
53
|
}
|
|
39
54
|
},
|
|
40
55
|
"scripts": {
|
|
41
56
|
"dev": "vite",
|
|
57
|
+
"test": "vitest",
|
|
42
58
|
"build": "vite build",
|
|
43
59
|
"preview": "vite preview"
|
|
44
60
|
},
|
|
@@ -46,13 +62,16 @@
|
|
|
46
62
|
"access": "public"
|
|
47
63
|
},
|
|
48
64
|
"devDependencies": {
|
|
49
|
-
"@types/js-cookie": "^3.0.6",
|
|
50
65
|
"@types/node": "^25.6.0",
|
|
66
|
+
"oxlint": "^1.61.0",
|
|
51
67
|
"typescript": "~6.0.3",
|
|
52
|
-
"vite": "^8.0.
|
|
53
|
-
"vite-plugin-dts": "^4.5.4"
|
|
68
|
+
"vite": "^8.0.10",
|
|
69
|
+
"vite-plugin-dts": "^4.5.4",
|
|
70
|
+
"vitest": "^4.1.5"
|
|
54
71
|
},
|
|
55
72
|
"dependencies": {
|
|
56
|
-
"js-cookie": "^3.0.5"
|
|
73
|
+
"js-cookie": "^3.0.5",
|
|
74
|
+
"@types/js-cookie": "^3.0.6",
|
|
75
|
+
"ky": "2.0.2"
|
|
57
76
|
}
|
|
58
77
|
}
|
package/dist/cookie/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`js-cookie`);c=s(c,1);var l=(e,t,n)=>{c.default.set(e,t,{expires:1/24,secure:!0,sameSite:`Strict`,...n})},u=e=>c.default.get(e),d=(e,t)=>{c.default.remove(e,t)};exports.deleteCookie=d,exports.getCookie=u,exports.setCookie=l;
|
package/dist/cookie/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import e from "js-cookie";
|
|
2
|
-
//#region src/cookie/index.ts
|
|
3
|
-
var t = (t, n, r) => {
|
|
4
|
-
e.set(t, n, {
|
|
5
|
-
expires: 1 / 24,
|
|
6
|
-
secure: !0,
|
|
7
|
-
sameSite: "Strict",
|
|
8
|
-
...r
|
|
9
|
-
});
|
|
10
|
-
}, n = (t) => e.get(t), r = (t, n) => {
|
|
11
|
-
e.remove(t, n);
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { r as deleteCookie, n as getCookie, t as setCookie };
|