@shware/http 0.3.3 → 0.3.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/dist/cache/index.cjs +32 -0
- package/dist/cache/index.cjs.map +1 -0
- package/dist/cache/index.d.cts +9 -0
- package/dist/cache/index.d.ts +9 -0
- package/dist/cache/index.mjs +7 -0
- package/dist/cache/index.mjs.map +1 -0
- package/dist/response.cjs +1 -1
- package/dist/response.cjs.map +1 -1
- package/dist/response.d.cts +1 -1
- package/dist/response.d.ts +1 -1
- package/dist/response.mjs +1 -1
- package/dist/response.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/cache/index.ts
|
|
21
|
+
var cache_exports = {};
|
|
22
|
+
__export(cache_exports, {
|
|
23
|
+
cache: () => cache
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cache_exports);
|
|
26
|
+
function cache(props) {
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
cache
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cache/index.ts"],"sourcesContent":["interface Props<T extends (...args: any[]) => any> {\n name: string;\n key: (...args: Parameters<T>) => string;\n condition?: (...args: Parameters<T>) => boolean;\n fn: T;\n}\n\nexport function cache<T extends (...args: any[]) => any>(props: Props<T>) {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,MAAyC,OAAiB;AAAC;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props<T extends (...args: any[]) => any> {
|
|
2
|
+
name: string;
|
|
3
|
+
key: (...args: Parameters<T>) => string;
|
|
4
|
+
condition?: (...args: Parameters<T>) => boolean;
|
|
5
|
+
fn: T;
|
|
6
|
+
}
|
|
7
|
+
declare function cache<T extends (...args: any[]) => any>(props: Props<T>): void;
|
|
8
|
+
|
|
9
|
+
export { cache };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props<T extends (...args: any[]) => any> {
|
|
2
|
+
name: string;
|
|
3
|
+
key: (...args: Parameters<T>) => string;
|
|
4
|
+
condition?: (...args: Parameters<T>) => boolean;
|
|
5
|
+
fn: T;
|
|
6
|
+
}
|
|
7
|
+
declare function cache<T extends (...args: any[]) => any>(props: Props<T>): void;
|
|
8
|
+
|
|
9
|
+
export { cache };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cache/index.ts"],"sourcesContent":["interface Props<T extends (...args: any[]) => any> {\n name: string;\n key: (...args: Parameters<T>) => string;\n condition?: (...args: Parameters<T>) => boolean;\n fn: T;\n}\n\nexport function cache<T extends (...args: any[]) => any>(props: Props<T>) {}\n"],"mappings":";AAOO,SAAS,MAAyC,OAAiB;AAAC;","names":[]}
|
package/dist/response.cjs
CHANGED
|
@@ -34,7 +34,7 @@ function pageParamsSchema(max = 100, defaultLimit = 20) {
|
|
|
34
34
|
}
|
|
35
35
|
var Cursor = {
|
|
36
36
|
of(prev, next) {
|
|
37
|
-
return { prev: this.encode(prev), next: this.encode(next) };
|
|
37
|
+
return { prev: prev ? this.encode(prev) : "", next: next ? this.encode(next) : "" };
|
|
38
38
|
},
|
|
39
39
|
empty() {
|
|
40
40
|
return { prev: "", next: "" };
|
package/dist/response.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/response.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type Empty = {};\nexport type EntityId = string | number;\nexport type Entity = { id: EntityId };\n\nexport type Response<T = never> = { data: T };\n\nexport type InitParams = { limit: number; parent?: string };\nexport type NextParams = { limit: number; parent?: string; next: string };\nexport type PrevParams = { limit: number; parent?: string; prev: string };\nexport type PageParams = { limit: number; prev?: string; next?: string };\nexport type ParentPageParams = { limit: number; parent: string; prev?: string; next?: string };\n\nexport type PagedResponse<T = never> = { data: T[]; paging: { next: string; prev: string } };\n\nexport function pageParamsSchema(max: number = 100, defaultLimit: number = 20) {\n return z.object({\n limit: z.coerce.number().int().min(1).max(max).default(defaultLimit),\n prev: z.string().optional(),\n next: z.string().optional(),\n });\n}\n\nexport const Cursor = {\n of(prev: bigint | number | string, next: bigint | number | string) {\n return { prev: this.encode(prev), next: this.encode(next) };\n },\n empty() {\n return { prev: '', next: '' };\n },\n encode(id: bigint | number | string): string {\n return Buffer.from(id.toString(), 'utf-8').toString('base64');\n },\n decode<T extends 'bigint' | 'number' | 'string' = 'bigint'>(\n token: string,\n type: T = 'bigint' as T\n ): T extends 'bigint' ? bigint : T extends 'number' ? number : string {\n const value = Buffer.from(token, 'base64').toString('utf-8');\n if (type === 'bigint') return BigInt(value) as any;\n if (type === 'number') return Number(value) as any;\n return value as any;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAkB;AAgBX,SAAS,iBAAiB,MAAc,KAAK,eAAuB,IAAI;AAC7E,SAAO,YAAE,OAAO;AAAA,IACd,OAAO,YAAE,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,YAAY;AAAA,IACnE,MAAM,YAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,YAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,CAAC;AACH;AAEO,IAAM,SAAS;AAAA,EACpB,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/response.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type Empty = {};\nexport type EntityId = string | number;\nexport type Entity = { id: EntityId };\n\nexport type Response<T = never> = { data: T };\n\nexport type InitParams = { limit: number; parent?: string };\nexport type NextParams = { limit: number; parent?: string; next: string };\nexport type PrevParams = { limit: number; parent?: string; prev: string };\nexport type PageParams = { limit: number; prev?: string; next?: string };\nexport type ParentPageParams = { limit: number; parent: string; prev?: string; next?: string };\n\nexport type PagedResponse<T = never> = { data: T[]; paging: { next: string; prev: string } };\n\nexport function pageParamsSchema(max: number = 100, defaultLimit: number = 20) {\n return z.object({\n limit: z.coerce.number().int().min(1).max(max).default(defaultLimit),\n prev: z.string().optional(),\n next: z.string().optional(),\n });\n}\n\nexport const Cursor = {\n of(prev: bigint | number | string | undefined, next: bigint | number | string | undefined) {\n return { prev: prev ? this.encode(prev) : '', next: next ? this.encode(next) : '' };\n },\n empty() {\n return { prev: '', next: '' };\n },\n encode(id: bigint | number | string): string {\n return Buffer.from(id.toString(), 'utf-8').toString('base64');\n },\n decode<T extends 'bigint' | 'number' | 'string' = 'bigint'>(\n token: string,\n type: T = 'bigint' as T\n ): T extends 'bigint' ? bigint : T extends 'number' ? number : string {\n const value = Buffer.from(token, 'base64').toString('utf-8');\n if (type === 'bigint') return BigInt(value) as any;\n if (type === 'number') return Number(value) as any;\n return value as any;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAkB;AAgBX,SAAS,iBAAiB,MAAc,KAAK,eAAuB,IAAI;AAC7E,SAAO,YAAE,OAAO;AAAA,IACd,OAAO,YAAE,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,YAAY;AAAA,IACnE,MAAM,YAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,YAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,CAAC;AACH;AAEO,IAAM,SAAS;AAAA,EACpB,GAAG,MAA4C,MAA4C;AACzF,WAAO,EAAE,MAAM,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,MAAM,OAAO,KAAK,OAAO,IAAI,IAAI,GAAG;AAAA,EACpF;AAAA,EACA,QAAQ;AACN,WAAO,EAAE,MAAM,IAAI,MAAM,GAAG;AAAA,EAC9B;AAAA,EACA,OAAO,IAAsC;AAC3C,WAAO,OAAO,KAAK,GAAG,SAAS,GAAG,OAAO,EAAE,SAAS,QAAQ;AAAA,EAC9D;AAAA,EACA,OACE,OACA,OAAU,UAC0D;AACpE,UAAM,QAAQ,OAAO,KAAK,OAAO,QAAQ,EAAE,SAAS,OAAO;AAC3D,QAAI,SAAS,SAAU,QAAO,OAAO,KAAK;AAC1C,QAAI,SAAS,SAAU,QAAO,OAAO,KAAK;AAC1C,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/response.d.cts
CHANGED
|
@@ -46,7 +46,7 @@ declare function pageParamsSchema(max?: number, defaultLimit?: number): z.ZodObj
|
|
|
46
46
|
next: z.ZodOptional<z.ZodString>;
|
|
47
47
|
}, z.core.$strip>;
|
|
48
48
|
declare const Cursor: {
|
|
49
|
-
of(prev: bigint | number | string, next: bigint | number | string): {
|
|
49
|
+
of(prev: bigint | number | string | undefined, next: bigint | number | string | undefined): {
|
|
50
50
|
prev: string;
|
|
51
51
|
next: string;
|
|
52
52
|
};
|
package/dist/response.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ declare function pageParamsSchema(max?: number, defaultLimit?: number): z.ZodObj
|
|
|
46
46
|
next: z.ZodOptional<z.ZodString>;
|
|
47
47
|
}, z.core.$strip>;
|
|
48
48
|
declare const Cursor: {
|
|
49
|
-
of(prev: bigint | number | string, next: bigint | number | string): {
|
|
49
|
+
of(prev: bigint | number | string | undefined, next: bigint | number | string | undefined): {
|
|
50
50
|
prev: string;
|
|
51
51
|
next: string;
|
|
52
52
|
};
|
package/dist/response.mjs
CHANGED
|
@@ -9,7 +9,7 @@ function pageParamsSchema(max = 100, defaultLimit = 20) {
|
|
|
9
9
|
}
|
|
10
10
|
var Cursor = {
|
|
11
11
|
of(prev, next) {
|
|
12
|
-
return { prev: this.encode(prev), next: this.encode(next) };
|
|
12
|
+
return { prev: prev ? this.encode(prev) : "", next: next ? this.encode(next) : "" };
|
|
13
13
|
},
|
|
14
14
|
empty() {
|
|
15
15
|
return { prev: "", next: "" };
|
package/dist/response.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/response.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type Empty = {};\nexport type EntityId = string | number;\nexport type Entity = { id: EntityId };\n\nexport type Response<T = never> = { data: T };\n\nexport type InitParams = { limit: number; parent?: string };\nexport type NextParams = { limit: number; parent?: string; next: string };\nexport type PrevParams = { limit: number; parent?: string; prev: string };\nexport type PageParams = { limit: number; prev?: string; next?: string };\nexport type ParentPageParams = { limit: number; parent: string; prev?: string; next?: string };\n\nexport type PagedResponse<T = never> = { data: T[]; paging: { next: string; prev: string } };\n\nexport function pageParamsSchema(max: number = 100, defaultLimit: number = 20) {\n return z.object({\n limit: z.coerce.number().int().min(1).max(max).default(defaultLimit),\n prev: z.string().optional(),\n next: z.string().optional(),\n });\n}\n\nexport const Cursor = {\n of(prev: bigint | number | string, next: bigint | number | string) {\n return { prev: this.encode(prev), next: this.encode(next) };\n },\n empty() {\n return { prev: '', next: '' };\n },\n encode(id: bigint | number | string): string {\n return Buffer.from(id.toString(), 'utf-8').toString('base64');\n },\n decode<T extends 'bigint' | 'number' | 'string' = 'bigint'>(\n token: string,\n type: T = 'bigint' as T\n ): T extends 'bigint' ? bigint : T extends 'number' ? number : string {\n const value = Buffer.from(token, 'base64').toString('utf-8');\n if (type === 'bigint') return BigInt(value) as any;\n if (type === 'number') return Number(value) as any;\n return value as any;\n },\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAgBX,SAAS,iBAAiB,MAAc,KAAK,eAAuB,IAAI;AAC7E,SAAO,EAAE,OAAO;AAAA,IACd,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,YAAY;AAAA,IACnE,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,CAAC;AACH;AAEO,IAAM,SAAS;AAAA,EACpB,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/response.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type Empty = {};\nexport type EntityId = string | number;\nexport type Entity = { id: EntityId };\n\nexport type Response<T = never> = { data: T };\n\nexport type InitParams = { limit: number; parent?: string };\nexport type NextParams = { limit: number; parent?: string; next: string };\nexport type PrevParams = { limit: number; parent?: string; prev: string };\nexport type PageParams = { limit: number; prev?: string; next?: string };\nexport type ParentPageParams = { limit: number; parent: string; prev?: string; next?: string };\n\nexport type PagedResponse<T = never> = { data: T[]; paging: { next: string; prev: string } };\n\nexport function pageParamsSchema(max: number = 100, defaultLimit: number = 20) {\n return z.object({\n limit: z.coerce.number().int().min(1).max(max).default(defaultLimit),\n prev: z.string().optional(),\n next: z.string().optional(),\n });\n}\n\nexport const Cursor = {\n of(prev: bigint | number | string | undefined, next: bigint | number | string | undefined) {\n return { prev: prev ? this.encode(prev) : '', next: next ? this.encode(next) : '' };\n },\n empty() {\n return { prev: '', next: '' };\n },\n encode(id: bigint | number | string): string {\n return Buffer.from(id.toString(), 'utf-8').toString('base64');\n },\n decode<T extends 'bigint' | 'number' | 'string' = 'bigint'>(\n token: string,\n type: T = 'bigint' as T\n ): T extends 'bigint' ? bigint : T extends 'number' ? number : string {\n const value = Buffer.from(token, 'base64').toString('utf-8');\n if (type === 'bigint') return BigInt(value) as any;\n if (type === 'number') return Number(value) as any;\n return value as any;\n },\n};\n"],"mappings":";AAAA,SAAS,SAAS;AAgBX,SAAS,iBAAiB,MAAc,KAAK,eAAuB,IAAI;AAC7E,SAAO,EAAE,OAAO;AAAA,IACd,OAAO,EAAE,OAAO,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,QAAQ,YAAY;AAAA,IACnE,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,IAC1B,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,CAAC;AACH;AAEO,IAAM,SAAS;AAAA,EACpB,GAAG,MAA4C,MAA4C;AACzF,WAAO,EAAE,MAAM,OAAO,KAAK,OAAO,IAAI,IAAI,IAAI,MAAM,OAAO,KAAK,OAAO,IAAI,IAAI,GAAG;AAAA,EACpF;AAAA,EACA,QAAQ;AACN,WAAO,EAAE,MAAM,IAAI,MAAM,GAAG;AAAA,EAC9B;AAAA,EACA,OAAO,IAAsC;AAC3C,WAAO,OAAO,KAAK,GAAG,SAAS,GAAG,OAAO,EAAE,SAAS,QAAQ;AAAA,EAC9D;AAAA,EACA,OACE,OACA,OAAU,UAC0D;AACpE,UAAM,QAAQ,OAAO,KAAK,OAAO,QAAQ,EAAE,SAAS,OAAO;AAC3D,QAAI,SAAS,SAAU,QAAO,OAAO,KAAK;AAC1C,QAAI,SAAS,SAAU,QAAO,OAAO,KAAK;AAC1C,WAAO;AAAA,EACT;AACF;","names":[]}
|