@akanjs/signal 0.0.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/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # akan
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build akan` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test akan` to execute the unit tests via [Jest](https://jestjs.io).
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/index.js ADDED
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var signal_exports = {};
16
+ module.exports = __toCommonJS(signal_exports);
17
+ __reExport(signal_exports, require("./src"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./src")
21
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@akanjs/signal",
3
+ "version": "0.0.4",
4
+ "type": "commonjs",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/akan-team/akanjs.git",
11
+ "directory": "pkgs/@akanjs/signal"
12
+ },
13
+ "dependencies": {
14
+ "@urql/core": "5.1.0",
15
+ "bull": "4.16.5",
16
+ "dayjs": "1.11.13",
17
+ "express": "4.21.2",
18
+ "immer": "10.1.1",
19
+ "mongoose": "8.9.3",
20
+ "next": "15.1.3",
21
+ "pluralize": "8.0.0",
22
+ "react": "18.2.0",
23
+ "react-dom": "18.2.0",
24
+ "reflect-metadata": "0.2.2",
25
+ "socket.io": "4.8.1",
26
+ "socket.io-client": "4.8.1",
27
+ "tunnel-ssh": "5.2.0"
28
+ },
29
+ "main": "./index.js"
30
+ }
@@ -0,0 +1,51 @@
1
+ import { type Client as GqlClient } from "@urql/core";
2
+ import { type Socket } from "socket.io-client";
3
+ interface SubscribeOption {
4
+ key: string;
5
+ roomId: string;
6
+ message: {
7
+ [key: string]: any;
8
+ };
9
+ }
10
+ declare class SocketIo {
11
+ socket: Socket;
12
+ roomSubscribeMap: Map<string, SubscribeOption>;
13
+ constructor(uri: string);
14
+ on(event: string, callback: (data: any) => void): void;
15
+ removeListener(event: string, callback?: (data: any) => void): void;
16
+ removeAllListeners(): void;
17
+ hasListeners(event: string): boolean;
18
+ emit(key: string, data: any): void;
19
+ subscribe(option: {
20
+ key: string;
21
+ roomId: string;
22
+ message: {
23
+ [key: string]: any;
24
+ };
25
+ handleEvent: (data: any) => void;
26
+ }): void;
27
+ unsubscribe(roomId: string, handleEvent: (data: any) => void): void;
28
+ disconnect(): this;
29
+ }
30
+ declare class Client {
31
+ static globalIoMap: Map<string, SocketIo>;
32
+ static tokenStore: Map<Client, string>;
33
+ waitUntilWebSocketConnected(ws?: string): Promise<true | undefined>;
34
+ isInitialized: boolean;
35
+ uri: string;
36
+ ws: string;
37
+ gql: GqlClient;
38
+ jwt: string | undefined | null;
39
+ getJwt(): Promise<string | null>;
40
+ io: SocketIo | null;
41
+ init(data?: Partial<Client>): void;
42
+ setIo(ws?: string): void;
43
+ getIo(ws?: string): SocketIo;
44
+ setLink(uri?: string): void;
45
+ setJwt(jwt: string): void;
46
+ reset(): void;
47
+ clone(data?: Partial<Client>): Client;
48
+ terminate(): void;
49
+ }
50
+ export declare const client: Client;
51
+ export type { Client, SocketIo };
package/src/client.js ADDED
@@ -0,0 +1,164 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var client_exports = {};
19
+ __export(client_exports, {
20
+ client: () => client
21
+ });
22
+ module.exports = __toCommonJS(client_exports);
23
+ var import_base = require("@akanjs/base");
24
+ var import_common = require("@akanjs/common");
25
+ var import_core = require("@urql/core");
26
+ var import_socket = require("socket.io-client");
27
+ class SocketIo {
28
+ socket;
29
+ roomSubscribeMap = /* @__PURE__ */ new Map();
30
+ constructor(uri) {
31
+ this.socket = (0, import_socket.io)(uri, { transports: ["websocket"] });
32
+ this.socket.on("connect", () => {
33
+ this.roomSubscribeMap.forEach((option) => {
34
+ this.socket.emit(option.key, { ...option.message, __subscribe__: true });
35
+ });
36
+ });
37
+ }
38
+ on(event, callback) {
39
+ this.socket.on(event, callback);
40
+ }
41
+ removeListener(event, callback) {
42
+ this.socket.removeListener(event, callback);
43
+ }
44
+ removeAllListeners() {
45
+ this.socket.removeAllListeners();
46
+ }
47
+ hasListeners(event) {
48
+ return this.socket.hasListeners(event);
49
+ }
50
+ emit(key, data) {
51
+ this.socket.emit(key, data);
52
+ }
53
+ subscribe(option) {
54
+ if (!this.roomSubscribeMap.has(option.roomId)) {
55
+ this.roomSubscribeMap.set(option.roomId, option);
56
+ this.socket.emit(option.key, { ...option.message, __subscribe__: true });
57
+ }
58
+ this.socket.on(option.roomId, option.handleEvent);
59
+ }
60
+ unsubscribe(roomId, handleEvent) {
61
+ this.socket.removeListener(roomId, handleEvent);
62
+ const option = this.roomSubscribeMap.get(roomId);
63
+ if (this.hasListeners(roomId) || !option)
64
+ return;
65
+ this.roomSubscribeMap.delete(roomId);
66
+ this.socket.emit(option.key, { ...option.message, __subscribe__: false });
67
+ }
68
+ disconnect() {
69
+ this.socket.disconnect();
70
+ return this;
71
+ }
72
+ }
73
+ class Client {
74
+ static globalIoMap = /* @__PURE__ */ new Map();
75
+ static tokenStore = /* @__PURE__ */ new Map();
76
+ async waitUntilWebSocketConnected(ws = import_base.baseClientEnv.serverWsUri) {
77
+ if (import_base.baseClientEnv.side === "server")
78
+ return true;
79
+ while (!this.getIo(ws).socket.connected) {
80
+ import_common.Logger.verbose("waiting for websocket to initialize...");
81
+ await (0, import_common.sleep)(300);
82
+ }
83
+ }
84
+ isInitialized = false;
85
+ uri = import_base.baseClientEnv.serverGraphqlUri;
86
+ ws = import_base.baseClientEnv.serverWsUri;
87
+ gql = (0, import_core.createClient)({ url: this.uri, fetch, exchanges: [import_core.cacheExchange, import_core.fetchExchange] });
88
+ jwt = null;
89
+ async getJwt() {
90
+ const isNextServer = import_base.baseClientEnv.side === "server" && import_base.baseEnv.operationType === "client";
91
+ if (isNextServer) {
92
+ const nextHeaders = require("next/headers");
93
+ return (await nextHeaders.cookies?.())?.get("jwt")?.value ?? (await nextHeaders.headers?.())?.get("jwt") ?? this.jwt ?? null;
94
+ } else
95
+ return Client.tokenStore.get(this) ?? null;
96
+ }
97
+ io = null;
98
+ init(data = {}) {
99
+ Object.assign(this, data);
100
+ this.setLink(data.uri);
101
+ this.setIo(data.ws);
102
+ this.isInitialized = true;
103
+ }
104
+ setIo(ws = import_base.baseClientEnv.serverWsUri) {
105
+ this.ws = ws;
106
+ const existingIo = Client.globalIoMap.get(ws);
107
+ if (existingIo) {
108
+ this.io = existingIo;
109
+ return;
110
+ }
111
+ this.io = new SocketIo(ws);
112
+ Client.globalIoMap.set(ws, this.io);
113
+ }
114
+ getIo(ws = import_base.baseClientEnv.serverWsUri) {
115
+ const existingIo = Client.globalIoMap.get(ws);
116
+ if (existingIo)
117
+ return existingIo;
118
+ const io2 = new SocketIo(ws);
119
+ Client.globalIoMap.set(ws, io2);
120
+ return io2;
121
+ }
122
+ setLink(uri = import_base.baseClientEnv.serverGraphqlUri) {
123
+ this.uri = uri;
124
+ this.gql = (0, import_core.createClient)({
125
+ url: this.uri,
126
+ fetch,
127
+ exchanges: [import_core.cacheExchange, import_core.fetchExchange],
128
+ // requestPolicy: "network-only",
129
+ fetchOptions: () => {
130
+ return {
131
+ headers: {
132
+ "apollo-require-preflight": "true",
133
+ ...this.jwt ? { authorization: `Bearer ${this.jwt}` } : {}
134
+ }
135
+ };
136
+ }
137
+ });
138
+ }
139
+ setJwt(jwt) {
140
+ Client.tokenStore.set(this, jwt);
141
+ }
142
+ reset() {
143
+ this.io?.disconnect();
144
+ this.io = null;
145
+ this.jwt = null;
146
+ }
147
+ clone(data = {}) {
148
+ const newClient = new Client();
149
+ newClient.init({ ...this, ...data });
150
+ if (data.jwt)
151
+ Client.tokenStore.set(newClient, data.jwt);
152
+ return newClient;
153
+ }
154
+ terminate() {
155
+ this.reset();
156
+ Client.globalIoMap.forEach((io2) => io2.disconnect());
157
+ this.isInitialized = false;
158
+ }
159
+ }
160
+ const client = new Client();
161
+ // Annotate the CommonJS export names for ESM import in node:
162
+ 0 && (module.exports = {
163
+ client
164
+ });
package/src/doc.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { type Type } from "@akanjs/base";
2
+ import { ArgMeta, SignalType } from "./signalDecorators";
3
+ export declare const makeRequestExample: (sigRef: Type, key: string) => {
4
+ [key: string]: any;
5
+ };
6
+ export declare const getExampleData: (argMetas: ArgMeta[], signalType?: SignalType) => {
7
+ [key: string]: any;
8
+ };
9
+ export declare const makeResponseExample: (sigRef: Type, key: string) => string | number | boolean | object | null;
package/src/doc.js ADDED
@@ -0,0 +1,107 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var doc_exports = {};
19
+ __export(doc_exports, {
20
+ getExampleData: () => getExampleData,
21
+ makeRequestExample: () => makeRequestExample,
22
+ makeResponseExample: () => makeResponseExample
23
+ });
24
+ module.exports = __toCommonJS(doc_exports);
25
+ var import_base = require("@akanjs/base");
26
+ var import_constant = require("@akanjs/constant");
27
+ var import_signalDecorators = require("./signalDecorators");
28
+ class ResponseExampleStorage {
29
+ }
30
+ const getPredefinedRequestExample = (modelRef) => {
31
+ return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
32
+ };
33
+ const getPredefinedResponseExample = (modelRef) => {
34
+ return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
35
+ };
36
+ const getResponseExample = (ref) => {
37
+ const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(ref);
38
+ const existing = getPredefinedRequestExample(modelRef);
39
+ if (existing)
40
+ return existing;
41
+ const isScalar = (0, import_base.isGqlScalar)(modelRef);
42
+ if (isScalar)
43
+ return (0, import_base.arraiedModel)((0, import_constant.getScalarExample)(modelRef), arrDepth);
44
+ const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
45
+ const example = {};
46
+ fieldMetas.forEach((fieldMeta) => {
47
+ if (fieldMeta.example)
48
+ example[fieldMeta.key] = fieldMeta.example;
49
+ else if (fieldMeta.enum)
50
+ example[fieldMeta.key] = (0, import_base.arraiedModel)(fieldMeta.enum.values[0], fieldMeta.arrDepth);
51
+ else
52
+ example[fieldMeta.key] = getResponseExample(fieldMeta.modelRef);
53
+ });
54
+ const result = (0, import_base.arraiedModel)(example, arrDepth);
55
+ Reflect.defineMetadata(ref, result, ResponseExampleStorage.prototype);
56
+ return result;
57
+ };
58
+ class RequestExampleStorage {
59
+ }
60
+ const getRequestExample = (ref) => {
61
+ const existing = getPredefinedRequestExample(ref);
62
+ if (existing)
63
+ return existing;
64
+ const fieldMetas = (0, import_constant.getFieldMetas)(ref);
65
+ const example = {};
66
+ const isScalar = (0, import_base.isGqlScalar)(ref);
67
+ if (isScalar)
68
+ return (0, import_constant.getScalarExample)(ref);
69
+ else {
70
+ fieldMetas.forEach((fieldMeta) => {
71
+ if (!fieldMeta.isScalar && fieldMeta.isClass)
72
+ example[fieldMeta.key] = "ObjectID";
73
+ else
74
+ example[fieldMeta.key] = fieldMeta.example ?? fieldMeta.enum ? (0, import_base.arraiedModel)(fieldMeta.example ?? (fieldMeta.enum?.values)[0], fieldMeta.optArrDepth) : (0, import_base.arraiedModel)(getRequestExample(fieldMeta.modelRef), fieldMeta.arrDepth);
75
+ });
76
+ }
77
+ Reflect.defineMetadata(ref, example, RequestExampleStorage.prototype);
78
+ return example;
79
+ };
80
+ const makeRequestExample = (sigRef, key) => {
81
+ const [argMetas] = (0, import_signalDecorators.getArgMetas)(sigRef, key);
82
+ return getExampleData(argMetas);
83
+ };
84
+ const getExampleData = (argMetas, signalType = "graphql") => Object.fromEntries(
85
+ argMetas.filter((argMeta) => argMeta.type !== "Upload").map((argMeta) => {
86
+ const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
87
+ const example = argMeta.argsOption.example ?? getRequestExample(argRef);
88
+ return [
89
+ argMeta.name,
90
+ (0, import_base.arraiedModel)(
91
+ signalType === "restapi" && argRef.prototype === import_base.JSON.prototype ? JSON.stringify(example, null, 2) : example,
92
+ argArrDepth
93
+ )
94
+ ];
95
+ })
96
+ );
97
+ const makeResponseExample = (sigRef, key) => {
98
+ const gqlMeta = (0, import_signalDecorators.getGqlMeta)(sigRef, key);
99
+ const example = getResponseExample(gqlMeta.returns());
100
+ return example;
101
+ };
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ getExampleData,
105
+ makeRequestExample,
106
+ makeResponseExample
107
+ });
package/src/gql.d.ts ADDED
@@ -0,0 +1,226 @@
1
+ import { DataList, Dayjs, Type, Upload } from "@akanjs/base";
2
+ import { FetchPolicy } from "@akanjs/common";
3
+ import { ConstantModel, DocumentModel, FilterType, ProtoFile, QueryOf, SortOf } from "@akanjs/constant";
4
+ import { type Client } from ".";
5
+ import { type ArgMeta, type DefaultSignal, type GqlMeta, type SliceMeta } from "./signalDecorators";
6
+ export declare class GqlStorage {
7
+ }
8
+ export declare class FragmentStorage {
9
+ }
10
+ export declare class PurifyStorage {
11
+ }
12
+ export declare class DefaultStorage {
13
+ }
14
+ export declare class CrystalizeStorage {
15
+ }
16
+ export type PurifyFunc<I, M> = (self: DefaultOf<Pick<M, keyof I extends keyof M ? keyof I : never>>, isChild?: boolean) => DocumentModel<I> | null;
17
+ export type CrystalizeFunc<M> = (self: {
18
+ [K in keyof M as M[K] extends (...args: any) => any ? never : K]: M[K];
19
+ }, isChild?: boolean) => M;
20
+ export type FieldState<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends Dayjs ? T : T extends any[] ? T : T extends {
21
+ id: string;
22
+ } ? T | null : T;
23
+ export type DefaultOf<S> = S extends infer T ? {
24
+ [K in keyof T]: FieldState<T[K]>;
25
+ } : never;
26
+ export interface FetchInitForm<Input, Full, Filter extends FilterType> {
27
+ page?: number;
28
+ limit?: number;
29
+ sort?: SortOf<Filter> | symbol;
30
+ default?: Partial<DefaultOf<Input>>;
31
+ invalidate?: boolean;
32
+ insight?: boolean;
33
+ }
34
+ export type ServerInit<T extends string, Light, Insight = any, QueryArgs = any[], Filter extends FilterType = any> = SliceMeta & {
35
+ [K in `${Uncapitalize<T>}ObjList`]: Light[];
36
+ } & {
37
+ [K in `${Uncapitalize<T>}ObjInsight`]: Insight;
38
+ } & {
39
+ [K in `pageOf${Capitalize<T>}`]: number;
40
+ } & {
41
+ [K in `lastPageOf${Capitalize<T>}`]: number;
42
+ } & {
43
+ [K in `limitOf${Capitalize<T>}`]: number;
44
+ } & {
45
+ [K in `queryArgsOf${Capitalize<T>}`]: QueryArgs;
46
+ } & {
47
+ [K in `sortOf${Capitalize<T>}`]: SortOf<Filter>;
48
+ } & {
49
+ [K in `${Uncapitalize<T>}InitAt`]: Date;
50
+ };
51
+ export type ClientInit<T extends string, Light, Insight = any, QueryArgs = any[], Filter extends FilterType = any> = Promise<ServerInit<T, Light, Insight, QueryArgs, Filter>> | ServerInit<T, Light, Insight, QueryArgs, Filter>;
52
+ export type ServerView<T extends string, M> = {
53
+ refName: T;
54
+ } & {
55
+ [K in `${Uncapitalize<T>}Obj`]: M;
56
+ } & {
57
+ [K in `${Uncapitalize<T>}ViewAt`]: Date;
58
+ };
59
+ export type ClientView<T extends string, M> = Promise<ServerView<T, M>> | ServerView<T, M>;
60
+ export type ServerEdit<T extends string, M> = {
61
+ refName: T;
62
+ } & {
63
+ [K in `${Uncapitalize<T>}Obj`]: M;
64
+ } & {
65
+ [K in `${Uncapitalize<T>}ViewAt`]: Date;
66
+ };
67
+ export type ClientEdit<T extends string, M> = Promise<ServerEdit<T, M>> | ServerEdit<T, M>;
68
+ export type GqlScalarUtil<T extends string, M, I = M> = {
69
+ [K in `default${Capitalize<T>}`]: DefaultOf<M>;
70
+ } & {
71
+ [K in `purify${Capitalize<T>}`]: PurifyFunc<DocumentModel<I>, M>;
72
+ } & {
73
+ [K in `crystalize${Capitalize<T>}`]: CrystalizeFunc<M>;
74
+ };
75
+ type FilterSkipLimitSort<Args, Filter> = Args extends [
76
+ ...args: infer QueryArgs,
77
+ skip: number | null,
78
+ limit: number | null,
79
+ sort: string | null
80
+ ] ? QueryArgs : never;
81
+ export type FilterListArgs<Args, Filter> = FilterOutInternalArgs<FilterSkipLimitSort<FilterOutInternalArgs<Args>, Filter>>;
82
+ export type FilterStateArgs<Args, Filter> = FilterSkipLimitSort<FilterOutInternalArgs<Args>, Filter>;
83
+ export type DbGraphQL<T extends string, Input, Full, Light extends {
84
+ id: string;
85
+ }, Insight, Filter extends FilterType, Fetch, Signal> = {
86
+ refName: string;
87
+ slices: SliceMeta[];
88
+ } & GetWsMessageOf<Signal> & GetWsPubsubOf<Signal> & GqlScalarUtil<T, Full> & {
89
+ [K in `lightCrystalize${Capitalize<T>}`]: CrystalizeFunc<Light>;
90
+ } & {
91
+ [K in `default${Capitalize<T>}Insight`]: Insight;
92
+ } & {
93
+ [K in `add${Capitalize<T>}Files`]: (fileList: FileList, parentId?: string, option?: FetchPolicy) => Promise<ProtoFile[]>;
94
+ } & {
95
+ [K in `merge${Capitalize<T>}`]: (modelOrId: Full | string, data: Partial<DocumentModel<Input>>, option?: FetchPolicy) => Promise<Full>;
96
+ } & {
97
+ [K in `view${Capitalize<T>}`]: (id: string, option?: FetchPolicy) => Promise<{
98
+ [K in Uncapitalize<T>]: Full;
99
+ } & {
100
+ [K in `${Uncapitalize<T>}View`]: ServerView<T, Full>;
101
+ }>;
102
+ } & {
103
+ [K in `get${Capitalize<T>}View`]: (id: string, option?: FetchPolicy) => ClientView<T, Full>;
104
+ } & {
105
+ [K in `edit${Capitalize<T>}`]: (id: string, option?: FetchPolicy) => Promise<{
106
+ [K in Uncapitalize<T>]: Full;
107
+ } & {
108
+ [K in `${Uncapitalize<T>}Edit`]: ServerEdit<T, Full>;
109
+ }>;
110
+ } & {
111
+ [K in `get${Capitalize<T>}Edit`]: (id: string, option?: FetchPolicy) => ClientEdit<T, Full>;
112
+ } & Fetch & {
113
+ [K in `init${Capitalize<T>}`]: (query?: QueryOf<DocumentModel<Full>>, option?: FetchPolicy & FetchInitForm<Input, Full, Filter>) => Promise<{
114
+ [K in `${Uncapitalize<T>}Init`]: ServerInit<T, Light, Insight, [query?: QueryOf<DocumentModel<Full>>], Filter>;
115
+ } & {
116
+ [K in `${Uncapitalize<T>}List`]: DataList<Light>;
117
+ } & {
118
+ [K in `${Uncapitalize<T>}Insight`]: Insight;
119
+ }>;
120
+ } & {
121
+ [K in `get${Capitalize<T>}Init`]: (query?: QueryOf<DocumentModel<Full>>, option?: FetchPolicy & FetchInitForm<Input, Full, Filter>) => ClientInit<T, Light, Insight, [query?: QueryOf<DocumentModel<Full>>], Filter>;
122
+ } & {
123
+ [K in keyof Signal as K extends `${T}List${infer Suffix}` ? `init${Capitalize<T>}${Suffix}` : never]: K extends `${T}List${infer Suffix}` ? Signal[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: [
124
+ ...queryArgs: FilterListArgs<Args, Filter>,
125
+ option?: FetchPolicy & FetchInitForm<Input, Full, Filter>
126
+ ]) => Promise<{
127
+ [K in `${Uncapitalize<T>}Init${Suffix}`]: ServerInit<T, Light, Insight, FilterListArgs<Args, Filter>, Filter>;
128
+ } & {
129
+ [K in `${Uncapitalize<T>}List${Suffix}`]: DataList<Light>;
130
+ } & {
131
+ [K in `${Uncapitalize<T>}Insight${Suffix}`]: Insight;
132
+ }> : never : never;
133
+ } & {
134
+ [K in keyof Signal as K extends `${T}List${infer Suffix}` ? `get${Capitalize<T>}Init${Suffix}` : never]: K extends `${T}List${infer Suffix}` ? Signal[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: [
135
+ ...queryArgs: FilterListArgs<Args, Filter>,
136
+ option?: FetchPolicy & FetchInitForm<Input, Full, Filter>
137
+ ]) => ClientInit<T, Light, Insight, FilterListArgs<Args, Filter>, Filter> : never : never;
138
+ };
139
+ type ConvertArg<T> = T extends Upload[] ? FileList : T;
140
+ type IsInternalArgs<T> = T extends {
141
+ __InternalArg__: any;
142
+ } ? true : T extends {
143
+ __InternalArg__: any;
144
+ } | null ? true : false;
145
+ export type FilterOutInternalArgs<T> = T extends [arg: infer Head, ...args: infer Rest] ? IsInternalArgs<Head> extends true ? FilterOutInternalArgs<Rest> : Head extends undefined ? [arg?: ConvertArg<Head> | undefined, ...args: FilterOutInternalArgs<Rest>] : Head extends null ? [arg?: ConvertArg<Head> | undefined, ...args: FilterOutInternalArgs<Rest>] : [
146
+ arg: ConvertArg<Head>,
147
+ ...args: FilterOutInternalArgs<Rest>
148
+ ] : [];
149
+ type FunctionToTuple<F extends (...args: any) => any> = F extends (...args: infer A) => any ? A : never;
150
+ type TupleToFunction<T extends any[], R> = (...args: [...args: T, option?: FetchPolicy]) => R;
151
+ export type RemoveInternalArgs<F extends (...args: any) => any, Returns = ReturnType<F>> = TupleToFunction<FilterOutInternalArgs<FunctionToTuple<F>>, Returns>;
152
+ type ApplyPromise<T> = T extends (...args: infer Args) => infer Return ? Return extends Promise<any> ? T : (...args: Args) => Promise<Return> : never;
153
+ type ApplyVoidReturn<T> = T extends (...args: infer Args) => any ? (...args: Args) => void : never;
154
+ export type GetQueryMutationOf<Sig, M = unknown> = {
155
+ [K in keyof Sig as K extends keyof M ? never : Sig[K] extends (...args: any) => Promise<{
156
+ __Returns__: string;
157
+ }> ? never : K]: Sig[K] extends (...args: any) => any ? ApplyPromise<RemoveInternalArgs<Sig[K]>> : never;
158
+ };
159
+ export type GetWsMessageOf<Sig> = {
160
+ [K in keyof Sig as Sig[K] extends (...args: any) => Promise<{
161
+ __Returns__: "Emit";
162
+ }> ? K : Sig[K] extends (...args: any) => {
163
+ __Returns__: "Emit";
164
+ } ? K : never]: Sig[K] extends (...args: any) => any ? ApplyVoidReturn<RemoveInternalArgs<Sig[K], void>> : never;
165
+ } & {
166
+ [K in keyof Sig as K extends string ? Sig[K] extends (...args: any) => Promise<{
167
+ __Returns__: "Emit";
168
+ }> | {
169
+ __Returns__: "Emit";
170
+ } ? `listen${Capitalize<K>}` : never : never]: Sig[K] extends (...args: any) => any ? (handleEvent: (data: Awaited<ReturnType<Sig[K]>>) => any, options?: FetchPolicy) => () => void : never;
171
+ };
172
+ export type GetWsPubsubOf<Sig> = {
173
+ [K in keyof Sig as K extends string ? Sig[K] extends (...args: any) => Promise<{
174
+ __Returns__: "Subscribe";
175
+ }> ? `subscribe${Capitalize<K>}` : Sig[K] extends (...args: any) => {
176
+ __Returns__: "Subscribe";
177
+ } ? `subscribe${Capitalize<K>}` : never : never]: Sig[K] extends (...args: infer Args) => Promise<{
178
+ __Returns__: "Subscribe";
179
+ } & infer Return> ? (...args: [...args: FilterOutInternalArgs<Args>, onData: (data: Return) => void, fetchPolicy?: FetchPolicy]) => () => void : Sig[K] extends (...args: infer Args) => {
180
+ __Returns__: "Subscribe";
181
+ } & infer Return ? (...args: [...args: FilterOutInternalArgs<Args>, onData: (data: Return) => void, fetchPolicy?: FetchPolicy]) => () => void : never;
182
+ };
183
+ export declare const scalarUtilOf: <T extends string, M>(name: T, target: Type<M>) => GqlScalarUtil<T, M>;
184
+ type LightWeightFetch<Fetch, Full, Light> = {
185
+ [K in keyof Fetch]: Fetch[K] extends (...args: infer Args) => Promise<Full[]> ? (...args: Args) => Promise<Light[]> : Fetch[K];
186
+ };
187
+ export declare const getGqlOnStorage: (refName: string) => {
188
+ [key: string]: any;
189
+ };
190
+ export declare const gqlOf: <T extends string, Input, Full extends {
191
+ id: string;
192
+ }, Light extends {
193
+ id: string;
194
+ }, Insight, Summary, Filter extends FilterType, Signal>(constant: ConstantModel<T, Input, Full, Light, Insight, Filter, Summary>, sigRef: Type<Signal>, option?: {
195
+ overwrite?: {
196
+ [key: string]: any;
197
+ };
198
+ }) => DbGraphQL<T, Input, Full, Light, Insight, Filter, LightWeightFetch<GetQueryMutationOf<Signal & DefaultSignal<T, Input, Full, Light, Insight, Filter>, Full>, Full, Light>, Signal>;
199
+ export declare const makeDefault: <T>(target: Type<T>, option?: {
200
+ isChild?: boolean;
201
+ overwrite?: any;
202
+ }) => DefaultOf<T>;
203
+ export declare const makePurify: <I, M = I>(target: Type<I>, option?: {
204
+ overwrite?: any;
205
+ }) => PurifyFunc<I, M>;
206
+ export declare const makeCrystalize: <M>(target: Type<M>, option?: {
207
+ overwrite?: any;
208
+ partial?: string[];
209
+ }) => CrystalizeFunc<M>;
210
+ export declare const makeFragment: (target: Type, option?: {
211
+ overwrite?: any;
212
+ excludeSelf?: boolean;
213
+ partial?: string[];
214
+ }) => string;
215
+ export declare const getGqlStr: (modelRef: Type, gqlMeta: GqlMeta, argMetas: ArgMeta[], returnRef: Type, partial?: string[]) => string;
216
+ export declare const serializeArg: (argMeta: ArgMeta, value: any) => object[] | null;
217
+ export declare const deserializeArg: (argMeta: ArgMeta, value: any) => object[] | null;
218
+ export declare const fetchOf: <Signal>(sigRef: Type<Signal>) => GetWsMessageOf<Signal> & GetWsPubsubOf<Signal> & GetQueryMutationOf<Signal>;
219
+ type CustomFetch<T> = Omit<T, "client" | "clone"> & {
220
+ client: Client;
221
+ clone: (option?: {
222
+ jwt: string | null;
223
+ }) => CustomFetch<T>;
224
+ };
225
+ export declare const makeFetch: <F1 extends object, F2 extends object, F3 extends object, F4 extends object, F5 extends object, F6 extends object, F7 extends object, F8 extends object, F9 extends object, F10 extends object>(fetch1: F1, fetch2?: Partial<F2>, fetch3?: Partial<F3>, fetch4?: Partial<F4>, fetch5?: Partial<F5>, fetch6?: Partial<F6>, fetch7?: Partial<F7>, fetch8?: Partial<F8>, fetch9?: Partial<F9>, fetch10?: Partial<F10>) => CustomFetch<F10 & F9 & F8 & F7 & F6 & F5 & F4 & F3 & F2 & F1>;
226
+ export {};