@akanjs/base 0.0.39 → 0.0.41

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/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/base",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/base.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ export declare class Enum<T> {
2
+ readonly values: T[];
3
+ readonly value: T;
4
+ readonly valueMap: Map<T, number>;
5
+ constructor(values: T[]);
6
+ has(value: T): boolean;
7
+ indexOf(value: T): number;
8
+ find(callback: (value: T, index: number, array: T[]) => boolean): T;
9
+ findIndex(callback: (value: T, index: number, array: T[]) => boolean): number;
10
+ filter(callback: (value: T, index: number, array: T[]) => boolean): T[];
11
+ map<R>(callback: (value: T, index: number, array: T[]) => R): R[];
12
+ forEach(callback: (value: T, index: number, array: T[]) => void): void;
13
+ }
14
+ export declare const enumOf: <T>(values: T[]) => Enum<T>;
15
+ export type enumOf<E> = E extends Enum<infer T> ? T : never;
16
+ export type EnumType<E> = E extends Enum<infer T> ? T : never;
17
+ export declare class DataList<Light extends {
18
+ id: string;
19
+ }> {
20
+ #private;
21
+ length: number;
22
+ values: Light[];
23
+ constructor(data?: Light[] | DataList<Light>);
24
+ indexOf(id: string): number;
25
+ set(value: Light): this;
26
+ delete(id: string): this;
27
+ get(id: string): Light | undefined;
28
+ at(idx: number): Light | undefined;
29
+ pickAt(idx: number): Light;
30
+ pick(id: string): Light;
31
+ has(id: string): boolean;
32
+ find(fn: (value: Light, idx: number) => boolean): Light | undefined;
33
+ findIndex(fn: (value: Light, idx: number) => boolean): number;
34
+ some(fn: (value: Light, idx: number) => boolean): boolean;
35
+ every(fn: (value: Light, idx: number) => boolean): boolean;
36
+ forEach(fn: (value: Light, idx: number) => void): void;
37
+ map<T>(fn: (value: Light, idx: number) => T): T[];
38
+ flatMap<T>(fn: (value: Light, idx: number, array: Light[]) => T | readonly T[]): T[];
39
+ sort(fn: (a: Light, b: Light) => number): DataList<Light>;
40
+ filter(fn: (value: Light, idx: number) => boolean): DataList<Light>;
41
+ reduce<T>(fn: (acc: T, value: Light, idx: number) => T, initialValue: T): T;
42
+ slice(start: number, end?: number): DataList<Light>;
43
+ save(): DataList<Light>;
44
+ [Symbol.iterator](): ArrayIterator<Light>;
45
+ }
46
+ export declare const version = "0.9.0";
47
+ export declare const logo = "\n _ _ _ \n / \\ | | ____ _ _ __ (_)___ \n / _ \\ | |/ / _' | '_ \\ | / __|\n / ___ \\| < (_| | | | |_ | \\__ \\\n /_/ \\_\\_|\\_\\__,_|_| |_(_)/ |___/\n |__/ ver 0.9.0\n? See more details on docs https://www.akanjs.com/docs\n\u2605 Star Akanjs on GitHub https://github.com/aka-bassman/akanjs\n\n";
@@ -0,0 +1,48 @@
1
+ import type { SshOptions } from "tunnel-ssh";
2
+ export type Environment = "testing" | "debug" | "develop" | "main";
3
+ export interface BaseEnv {
4
+ repoName: string;
5
+ serveDomain: string;
6
+ appName: string;
7
+ environment: Environment;
8
+ operationType: "server" | "client";
9
+ operationMode: "local" | "edge" | "cloud" | "module";
10
+ networkType: "mainnet" | "testnet" | "debugnet";
11
+ tunnelUsername: string;
12
+ tunnelPassword: string;
13
+ }
14
+ export type BackendEnv = BaseEnv & {
15
+ hostname: string | null;
16
+ appCode: number;
17
+ mongo: {
18
+ username?: string;
19
+ password?: string;
20
+ sshOptions?: SshOptions;
21
+ };
22
+ redis?: {
23
+ sshOptions?: SshOptions;
24
+ };
25
+ port?: number;
26
+ mongoUri?: string;
27
+ redisUri?: string;
28
+ meiliUri?: string;
29
+ onCleanup?: () => Promise<void>;
30
+ };
31
+ export declare const baseEnv: BaseEnv;
32
+ export type BaseClientEnv = BaseEnv & {
33
+ side: "server" | "client";
34
+ renderMode: "ssr" | "csr";
35
+ websocket: boolean;
36
+ clientHost: string;
37
+ clientPort: number;
38
+ clientHttpProtocol: "http:" | "https:";
39
+ clientHttpUri: string;
40
+ serverHost: string;
41
+ serverPort: number;
42
+ serverHttpProtocol: "http:" | "https:";
43
+ serverHttpUri: string;
44
+ serverGraphqlUri: string;
45
+ serverWsProtocol: "ws:" | "wss:";
46
+ serverWsUri: string;
47
+ };
48
+ export declare const baseClientEnv: BaseClientEnv;
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./base";
2
+ export * from "./baseEnv";
3
+ export * from "./scalar";
4
+ export * from "./types";
@@ -0,0 +1,46 @@
1
+ import dayjsLib, { Dayjs } from "dayjs";
2
+ import type { ReadStream } from "fs";
3
+ import type { Readable } from "stream";
4
+ import type { GraphQLJSON, GraphQLUpload, Type } from "./types";
5
+ export { Dayjs };
6
+ export declare const dayjs: typeof dayjsLib;
7
+ export declare class BaseObject {
8
+ id: string;
9
+ createdAt: Dayjs;
10
+ updatedAt: Dayjs;
11
+ removedAt: Dayjs | null;
12
+ }
13
+ export declare class Int {
14
+ __Scalar__: "int";
15
+ }
16
+ export declare class Upload {
17
+ __Scalar__: "upload";
18
+ filename: string;
19
+ mimetype: string;
20
+ encoding: string;
21
+ createReadStream: () => ReadStream | Readable;
22
+ }
23
+ export declare class Float {
24
+ __Scalar__: "float";
25
+ }
26
+ export declare class ID {
27
+ __Scalar__: "id";
28
+ }
29
+ export declare class JSON {
30
+ __Scalar__: "json";
31
+ }
32
+ export type SingleFieldType = Int | Float | StringConstructor | BooleanConstructor | ID | DateConstructor | JSON | Type | GraphQLJSON | GraphQLUpload;
33
+ export declare const getNonArrayModel: <T = Type>(arraiedModel: T | T[]) => [T, number];
34
+ export declare const arraiedModel: <T = any>(modelRef: T, arrDepth?: number) => T | T[];
35
+ export declare const applyFnToArrayObjects: (arraiedData: any, fn: (arg: any) => any) => any[];
36
+ export declare const gqlScalars: readonly [StringConstructor, BooleanConstructor, DateConstructor, typeof ID, typeof Int, typeof Float, typeof Upload, typeof JSON, MapConstructor];
37
+ export type GqlScalar = (typeof gqlScalars)[number];
38
+ export declare const gqlScalarNames: readonly ["ID", "Int", "Float", "String", "Boolean", "Date", "Upload", "JSON", "Map"];
39
+ export type GqlScalarName = (typeof gqlScalarNames)[number];
40
+ export declare const scalarSet: Set<MapConstructor | typeof Int | typeof Upload | typeof Float | typeof ID | typeof JSON | StringConstructor | BooleanConstructor | DateConstructor>;
41
+ export declare const scalarNameMap: Map<MapConstructor | typeof Int | typeof Upload | typeof Float | typeof ID | typeof JSON | StringConstructor | BooleanConstructor | DateConstructor, "ID" | "Int" | "Float" | "String" | "Boolean" | "Date" | "Upload" | "JSON" | "Map">;
42
+ export declare const scalarArgMap: Map<MapConstructor | typeof Int | typeof Upload | typeof Float | typeof ID | typeof JSON | StringConstructor | BooleanConstructor | DateConstructor, any>;
43
+ export declare const scalarDefaultMap: Map<MapConstructor | typeof Int | typeof Upload | typeof Float | typeof ID | typeof JSON | StringConstructor | BooleanConstructor | DateConstructor, any>;
44
+ export declare const isGqlClass: (modelRef: Type) => boolean;
45
+ export declare const isGqlScalar: (modelRef: Type) => boolean;
46
+ export declare const isGqlMap: (modelRef: any) => boolean;
package/src/types.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ export type { SshOptions } from "tunnel-ssh";
2
+ export type Type<T = any> = new (...args: any[]) => T;
3
+ export type BufferLike = string | Buffer | DataView | number | ArrayBufferView | Uint8Array | ArrayBuffer | SharedArrayBuffer | readonly any[] | readonly number[];
4
+ export type GetObject<T> = Omit<{
5
+ [K in keyof T]: T[K];
6
+ }, "prototype">;
7
+ export type OptionOf<Obj> = {
8
+ [K in keyof Obj]?: Obj[K] | null;
9
+ };
10
+ export type UnType<T> = T extends new (...args: any) => infer U ? U : never;
11
+ export interface GraphQLUpload {
12
+ name: string;
13
+ description: string;
14
+ specifiedByUrl: string;
15
+ serialize: any;
16
+ parseValue: any;
17
+ parseLiteral: any;
18
+ extensions: any;
19
+ astNode: any;
20
+ extensionASTNodes: any;
21
+ toConfig(): any;
22
+ toString(): string;
23
+ toJSON(): string;
24
+ inspect(): string;
25
+ }
26
+ export interface GraphQLJSON<TInternal = unknown, TExternal = TInternal> {
27
+ name: string;
28
+ description: string;
29
+ specifiedByURL: string;
30
+ serialize: any;
31
+ parseValue: any;
32
+ parseLiteral: any;
33
+ extensions: any;
34
+ astNode: any;
35
+ extensionASTNodes: any;
36
+ get [Symbol.toStringTag](): string;
37
+ toConfig(): any;
38
+ toString(): string;
39
+ toJSON(): string;
40
+ }