@luminix/support 0.0.1-beta.1 → 0.0.1-beta.3
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/support.js +2127 -2029
- package/package.json +2 -1
- package/types/Contracts/EventSource.d.ts +1 -2
- package/types/Http/Client.d.ts +2 -0
- package/types/Http/index.d.ts +1 -1
- package/types/PropertyBag.d.ts +24 -0
- package/types/index.d.ts +3 -2
- package/types/Http.d.ts +0 -30
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luminix/support",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.3",
|
|
4
4
|
"module": "dist/support.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"prebuild": "rm -rf types",
|
|
8
9
|
"build": "tsc && vite build",
|
|
9
10
|
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
10
11
|
"lint:fix": "eslint . --report-unused-disable-directives --max-warnings 0 --fix",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Unsubscribe } from 'nanoevents';
|
|
2
|
-
export type Event<TData = any, TSource extends EventSource =
|
|
2
|
+
export type Event<TData = any, TSource extends EventSource = any> = TData & {
|
|
3
3
|
source: TSource;
|
|
4
4
|
};
|
|
5
5
|
export type EventMap = {
|
|
@@ -11,5 +11,4 @@ export default class EventSource<TEvents extends EventMap = EventMap> {
|
|
|
11
11
|
on<E extends keyof TEvents>(event: E, callback: TEvents[E]): Unsubscribe;
|
|
12
12
|
once<E extends keyof TEvents>(event: E, callback: TEvents[E]): void;
|
|
13
13
|
emit<E extends keyof TEvents>(event: E, ...data: Parameters<TEvents[E]>): void;
|
|
14
|
-
static foo(): string;
|
|
15
14
|
}
|
package/types/Http/Client.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export default class Client {
|
|
|
15
15
|
replaceOptions(options: RequestOptions): this;
|
|
16
16
|
withQueryParameters(params: string | object): this;
|
|
17
17
|
replaceQueryParameters(params: string | object): this;
|
|
18
|
+
withData(data: object): this;
|
|
19
|
+
replaceData(data: object): this;
|
|
18
20
|
withBasicAuth(username: string, password: string): this;
|
|
19
21
|
withToken(token: string): this;
|
|
20
22
|
get<TResponse = any>(url: string, query?: string | object): Request<TResponse, any>;
|
package/types/Http/index.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ declare class HttpStatic {
|
|
|
21
21
|
patch<TResponse = any, TData = any>(url: string, data?: TData): Request<TResponse, TData>;
|
|
22
22
|
delete<TResponse = any>(url: string, query?: string | object): Request<TResponse, any>;
|
|
23
23
|
}
|
|
24
|
-
declare const Http: HttpStatic &
|
|
24
|
+
declare const Http: HttpStatic & Record<string, () => Client> & import('../Mixins/Macroable').MacroableInterface<Record<string, () => Client>>;
|
|
25
25
|
export default Http;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as EventSource, Event } from './Contracts/EventSource';
|
|
2
|
+
export type PropertyBagChangeEvent = {
|
|
3
|
+
path: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
type: 'set' | 'merge' | 'delete';
|
|
6
|
+
};
|
|
7
|
+
export type PropertyBagEventMap<T extends object = any> = {
|
|
8
|
+
'change': (e: Event<PropertyBagChangeEvent, PropertyBag<T>>) => void;
|
|
9
|
+
};
|
|
10
|
+
declare class PropertyBag<T extends object> extends EventSource<PropertyBagEventMap<T>> {
|
|
11
|
+
private bag;
|
|
12
|
+
private locked;
|
|
13
|
+
constructor(bag: T);
|
|
14
|
+
get(path: string, defaultValue?: unknown): any;
|
|
15
|
+
set(path: string, value: unknown): void;
|
|
16
|
+
merge(path: string, value: unknown): void;
|
|
17
|
+
has(path: string): boolean;
|
|
18
|
+
delete(path: string): void;
|
|
19
|
+
lock(path: string): void;
|
|
20
|
+
clone(): PropertyBag<T>;
|
|
21
|
+
all(): T;
|
|
22
|
+
isEmpty(): boolean;
|
|
23
|
+
}
|
|
24
|
+
export default PropertyBag;
|
package/types/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { default as Collection } from './Collection';
|
|
2
2
|
import { default as EventSource } from './Contracts/EventSource';
|
|
3
|
-
import { default as Http } from './Http';
|
|
3
|
+
import { default as Http } from './Http/index';
|
|
4
|
+
import { default as PropertyBag } from './PropertyBag';
|
|
4
5
|
import { default as Reducible } from './Mixins/Reducible';
|
|
5
6
|
import { default as Macroable } from './Mixins/Macroable';
|
|
6
7
|
import * as Arr from './Arr';
|
|
7
8
|
import * as Obj from './Obj';
|
|
8
9
|
import * as Query from './Query';
|
|
9
10
|
import * as Str from './Str';
|
|
10
|
-
export { Arr, Collection, EventSource, Http, Reducible, Macroable, Obj, Query, Str, };
|
|
11
|
+
export { Arr, Collection, EventSource, Http, PropertyBag, Reducible, Macroable, Obj, Query, Str, };
|
package/types/Http.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
declare class Response<T = any, D = any> {
|
|
3
|
-
_response: AxiosResponse<T, D>;
|
|
4
|
-
constructor(_response: AxiosResponse<T, D>);
|
|
5
|
-
body(): string;
|
|
6
|
-
json(): D;
|
|
7
|
-
status(): number;
|
|
8
|
-
successful(): boolean;
|
|
9
|
-
failed(): boolean;
|
|
10
|
-
header(header: string): string;
|
|
11
|
-
headers(): Record<string, string>;
|
|
12
|
-
ok(): boolean;
|
|
13
|
-
created(): boolean;
|
|
14
|
-
accepted(): boolean;
|
|
15
|
-
noContent(): boolean;
|
|
16
|
-
movedPermanently(): boolean;
|
|
17
|
-
found(): boolean;
|
|
18
|
-
badRequest(): boolean;
|
|
19
|
-
unauthorized(): boolean;
|
|
20
|
-
paymentRequired(): boolean;
|
|
21
|
-
forbidden(): boolean;
|
|
22
|
-
notFound(): boolean;
|
|
23
|
-
requestTimeout(): boolean;
|
|
24
|
-
conflict(): boolean;
|
|
25
|
-
unprocessableEntity(): boolean;
|
|
26
|
-
tooManyRequests(): boolean;
|
|
27
|
-
serverError(): boolean;
|
|
28
|
-
}
|
|
29
|
-
export declare function get(url: string, query?: string | object): Promise<Response>;
|
|
30
|
-
export {};
|