@quickql/react 1.0.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.
@@ -0,0 +1,57 @@
1
+ /**
2
+ * QuickQL Core Client
3
+ *
4
+ * Standard HTTP client for interacting with QuickQL servers across
5
+ * all JavaScript environments. Handles batching, caching, and plugins.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ import { Query, Mutation, QuickQLRequest, QuickQLResponse, QuickQLError } from './types';
12
+ export interface ClientOptions {
13
+ endpoint: string;
14
+ headers?: Record<string, string>;
15
+ timeout?: number;
16
+ retry?: number;
17
+ cacheTTL?: number;
18
+ plugins?: QuickQLPlugin[];
19
+ }
20
+ export type LifecycleHook = 'beforeRequest' | 'afterResponse' | 'onError';
21
+ export interface QuickQLPlugin {
22
+ name: string;
23
+ onBeforeRequest?: (request: QuickQLRequest, context: any) => QuickQLRequest | Promise<QuickQLRequest>;
24
+ onAfterResponse?: (response: QuickQLResponse, context: any) => QuickQLResponse | Promise<QuickQLResponse>;
25
+ onError?: (error: QuickQLError, context: any) => void | Promise<void>;
26
+ }
27
+ /**
28
+ * Universal QuickQL Client for Browser and Node.js
29
+ */
30
+ export declare class QuickQLClient {
31
+ private cache;
32
+ private options;
33
+ constructor(options: ClientOptions);
34
+ /**
35
+ * Main Query operation.
36
+ */
37
+ query<T = any>(query: Query, alias?: string): Promise<QuickQLResponse<T>>;
38
+ /**
39
+ * Main Mutation operation.
40
+ */
41
+ mutation<T = any>(mutation: Mutation, alias?: string): Promise<QuickQLResponse<T>>;
42
+ /**
43
+ * Batch multiple queries and mutations.
44
+ */
45
+ batch(items: (Query | Mutation)[], transaction?: boolean): Promise<QuickQLResponse<any>>;
46
+ /**
47
+ * Low-level execution logic with plugin support.
48
+ */
49
+ private execute;
50
+ private handleError;
51
+ private getCacheKey;
52
+ private getFromCache;
53
+ private setInCache;
54
+ clearCache(): void;
55
+ setHeaders(headers: Record<string, string>): void;
56
+ }
57
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../core/src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAC/D,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,eAAe,GAAG,SAAS,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACtG,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC1G,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAqD;IAClE,OAAO,CAAC,OAAO,CAA0B;gBAE7B,OAAO,EAAE,aAAa;IAelC;;OAEG;IACG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,GAAE,MAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAoBvF;;OAEG;IACG,QAAQ,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAE,MAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAWhG;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,QAAQ,CAAC,EAAE,EAAE,WAAW,UAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAS5F;;OAEG;YACW,OAAO;IAgDrB,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,UAAU;IASX,UAAU;IAIV,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGlD"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * QuickQL Core Client
3
+ *
4
+ * Standard HTTP client for interacting with QuickQL servers across
5
+ * all JavaScript environments. Handles batching, caching, and plugins.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ /**
12
+ * Universal QuickQL Client for Browser and Node.js
13
+ */
14
+ export class QuickQLClient {
15
+ cache = new Map();
16
+ options;
17
+ constructor(options) {
18
+ this.options = {
19
+ endpoint: options.endpoint,
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ 'X-QuickQL-Version': '1.0.0',
23
+ ...(options.headers || {})
24
+ },
25
+ timeout: options.timeout || 15000,
26
+ retry: options.retry || 1,
27
+ cacheTTL: options.cacheTTL || 0,
28
+ plugins: options.plugins || []
29
+ };
30
+ }
31
+ /**
32
+ * Main Query operation.
33
+ */
34
+ async query(query, alias = 'data') {
35
+ const key = this.getCacheKey({ query, alias });
36
+ const cached = this.getFromCache(key);
37
+ if (cached)
38
+ return cached;
39
+ try {
40
+ const response = await this.execute({
41
+ queries: { [alias]: query }
42
+ });
43
+ const res = response;
44
+ if (res.data && !res.errors) {
45
+ this.setInCache(key, res);
46
+ }
47
+ return res;
48
+ }
49
+ catch (error) {
50
+ return this.handleError(error);
51
+ }
52
+ }
53
+ /**
54
+ * Main Mutation operation.
55
+ */
56
+ async mutation(mutation, alias = 'data') {
57
+ try {
58
+ const response = await this.execute({
59
+ mutations: { [alias]: mutation }
60
+ });
61
+ return response;
62
+ }
63
+ catch (error) {
64
+ return this.handleError(error);
65
+ }
66
+ }
67
+ /**
68
+ * Batch multiple queries and mutations.
69
+ */
70
+ async batch(items, transaction = false) {
71
+ try {
72
+ const response = await this.execute({ batch: items, transaction });
73
+ return response;
74
+ }
75
+ catch (error) {
76
+ return this.handleError(error);
77
+ }
78
+ }
79
+ /**
80
+ * Low-level execution logic with plugin support.
81
+ */
82
+ async execute(request, retries = this.options.retry) {
83
+ let currentRequest = request;
84
+ // Trigger onBeforeRequest hooks
85
+ for (const plugin of this.options.plugins) {
86
+ if (plugin.onBeforeRequest) {
87
+ currentRequest = await plugin.onBeforeRequest(currentRequest, this);
88
+ }
89
+ }
90
+ const controller = new AbortController();
91
+ const timeoutId = setTimeout(() => controller.abort(), this.options.timeout);
92
+ try {
93
+ const response = await fetch(this.options.endpoint, {
94
+ method: 'POST',
95
+ headers: this.options.headers,
96
+ body: JSON.stringify(currentRequest),
97
+ signal: controller.signal
98
+ });
99
+ clearTimeout(timeoutId);
100
+ if (!response.ok) {
101
+ throw new Error(`QuickQL Client Error: ${response.status} ${response.statusText}`);
102
+ }
103
+ let data = await response.json();
104
+ // Trigger onAfterResponse hooks
105
+ for (const plugin of this.options.plugins) {
106
+ if (plugin.onAfterResponse) {
107
+ data = await plugin.onAfterResponse(data, this);
108
+ }
109
+ }
110
+ return data;
111
+ }
112
+ catch (error) {
113
+ clearTimeout(timeoutId);
114
+ if (retries > 0 && error.name !== 'AbortError') {
115
+ return this.execute(request, retries - 1);
116
+ }
117
+ throw error;
118
+ }
119
+ }
120
+ handleError(error) {
121
+ const isTimeout = error.name === 'AbortError';
122
+ const quickError = {
123
+ type: isTimeout ? 'NETWORK' : 'INTERNAL',
124
+ message: error.message || 'Unknown QuickQL Client error',
125
+ code: isTimeout ? 'TIMEOUT' : 'CLIENT_EXCEPTION'
126
+ };
127
+ // Trigger plugins
128
+ for (const plugin of this.options.plugins) {
129
+ if (plugin.onError) {
130
+ plugin.onError(quickError, this);
131
+ }
132
+ }
133
+ return {
134
+ data: null,
135
+ errors: [quickError]
136
+ };
137
+ }
138
+ getCacheKey(request) {
139
+ return JSON.stringify(request);
140
+ }
141
+ getFromCache(key) {
142
+ const cached = this.cache.get(key);
143
+ if (cached && cached.expiry > Date.now()) {
144
+ return cached.value;
145
+ }
146
+ this.cache.delete(key);
147
+ return null;
148
+ }
149
+ setInCache(key, value) {
150
+ if (this.options.cacheTTL > 0) {
151
+ this.cache.set(key, {
152
+ value,
153
+ expiry: Date.now() + this.options.cacheTTL
154
+ });
155
+ }
156
+ }
157
+ clearCache() {
158
+ this.cache.clear();
159
+ }
160
+ setHeaders(headers) {
161
+ this.options.headers = { ...this.options.headers, ...headers };
162
+ }
163
+ }
164
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../core/src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAwBH;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,KAAK,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC1D,OAAO,CAA0B;IAEzC,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG;YACb,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,mBAAmB,EAAE,OAAO;gBAC5B,GAAG,CAAC,OAAO,CAAC,OAAO,I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1
+ /**
2
+ * QuickQL Core SDK
3
+ *
4
+ * Shared logic and client for the QuickQL ecosystem.
5
+ * Managed by Udinmo Inc.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ export * from './types';
12
+ export * from './client';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * QuickQL Core SDK
3
+ *
4
+ * Shared logic and client for the QuickQL ecosystem.
5
+ * Managed by Udinmo Inc.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ export * from './types';
12
+ export * from './client';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * QuickQL Core Types
3
+ *
4
+ * Shared type definitions for queries, mutations, and responses.
5
+ * Ensured parity between server and client expectations.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ /**
12
+ * QuickQL Core Types - Refined for Production
13
+ */
14
+ export type Operator = 'eq' | 'ne' | 'gt' | 'lt' | 'in' | 'contains' | 'startsWith' | 'endsWith';
15
+ export type WhereValue = string | number | boolean | Array<string | number | boolean> | null;
16
+ export type WhereCondition = {
17
+ [operator in Operator]?: WhereValue;
18
+ } | WhereValue;
19
+ export type LogicalCondition = {
20
+ AND?: (WhereClause | LogicalCondition)[];
21
+ OR?: (WhereClause | LogicalCondition)[];
22
+ };
23
+ export type WhereClause = {
24
+ [field: string]: WhereCondition | LogicalCondition;
25
+ };
26
+ export type IncludeClause = {
27
+ [relation: string]: Partial<Query>;
28
+ };
29
+ export type OrderDirection = 'asc' | 'desc';
30
+ export type OrderBy = {
31
+ [field: string]: OrderDirection;
32
+ };
33
+ export interface Query {
34
+ from: string;
35
+ select?: string[];
36
+ alias?: string;
37
+ where?: WhereClause | LogicalCondition;
38
+ include?: IncludeClause;
39
+ limit?: number;
40
+ offset?: number;
41
+ orderBy?: OrderBy;
42
+ aggregate?: {
43
+ count?: boolean;
44
+ sum?: string;
45
+ avg?: string;
46
+ max?: string;
47
+ min?: string;
48
+ };
49
+ directives?: Record<string, any>;
50
+ }
51
+ export type MutationType = 'create' | 'update' | 'delete';
52
+ export interface Mutation {
53
+ type: MutationType;
54
+ collection: string;
55
+ data?: Record<string, unknown>;
56
+ where?: WhereClause | LogicalCondition;
57
+ select?: string[];
58
+ }
59
+ export interface QuickQLRequest {
60
+ queries?: Record<string, Query>;
61
+ mutations?: Record<string, Mutation>;
62
+ batch?: (Query | Mutation)[];
63
+ transaction?: boolean;
64
+ }
65
+ export interface QuickQLError {
66
+ type: 'VALIDATION' | 'NETWORK' | 'AUTH' | 'INTERNAL' | 'NOT_FOUND' | 'SECURITY';
67
+ message: string;
68
+ code?: string;
69
+ path?: string[];
70
+ stack?: string;
71
+ }
72
+ export interface QuickQLResponse<T = unknown> {
73
+ data: T | null;
74
+ errors?: QuickQLError[];
75
+ meta?: {
76
+ count?: number;
77
+ total?: number;
78
+ executionTime?: number;
79
+ hints?: string[];
80
+ };
81
+ }
82
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../core/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG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AAI,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * QuickQL Core Types
3
+ *
4
+ * Shared type definitions for queries, mutations, and responses.
5
+ * Ensured parity between server and client expectations.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../core/src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * QuickQL React Bindings
3
+ *
4
+ * Provides React Hooks (useQuickQL) and Context Providers for seamless
5
+ * data fetching in React 18/19 and Next.js applications.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+ import React from 'react';
12
+ import { QuickQLClient, ClientOptions, Query, QuickQLError } from '@quickql/core';
13
+ export interface QuickQLProviderProps {
14
+ options?: ClientOptions;
15
+ client?: QuickQLClient;
16
+ children: React.ReactNode;
17
+ }
18
+ /**
19
+ * Universal QuickQL Provider for React Apps
20
+ */
21
+ export declare const QuickQLProvider: React.FC<QuickQLProviderProps>;
22
+ export declare const useQuickQLClient: () => QuickQLClient;
23
+ export interface UseQuickQLOptions {
24
+ enabled?: boolean;
25
+ }
26
+ /**
27
+ * Hook to fetch data using QuickQL queries.
28
+ */
29
+ export declare function useQuickQL<T = any>(query: Query | null, config?: UseQuickQLOptions): {
30
+ data: T | null;
31
+ loading: boolean;
32
+ error: QuickQLError[] | null;
33
+ refetch: () => Promise<void>;
34
+ };
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAuF,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAmB,YAAY,EAAE,MAAM,eAAe,CAAC;AAQnG,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAY1D,CAAC;AAEF,eAAO,MAAM,gBAAgB,qBAM5B,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,GAAE,iBAAsB;;;;;EAiCtF"}
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * QuickQL React Bindings
4
+ *
5
+ * Provides React Hooks (useQuickQL) and Context Providers for seamless
6
+ * data fetching in React 18/19 and Next.js applications.
7
+ *
8
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
9
+ * Author: Udinmo Inc. <engineering@udinmo.com>
10
+ * License: MIT
11
+ */
12
+ import { createContext, useContext, useMemo, useState, useEffect, useCallback } from 'react';
13
+ import { QuickQLClient } from '@quickql/core';
14
+ const QuickQLContext = createContext(null);
15
+ /**
16
+ * Universal QuickQL Provider for React Apps
17
+ */
18
+ export const QuickQLProvider = ({ options, client, children }) => {
19
+ const instance = useMemo(() => {
20
+ if (client)
21
+ return client;
22
+ if (options)
23
+ return new QuickQLClient(options);
24
+ throw new Error('QuickQLProvider requires either a "client" instance or "options".');
25
+ }, [client, options?.endpoint]);
26
+ return (_jsx(QuickQLContext.Provider, { value: { client: instance }, children: children }));
27
+ };
28
+ export const useQuickQLClient = () => {
29
+ const context = useContext(QuickQLContext);
30
+ if (!context) {
31
+ throw new Error('useQuickQLClient must be used within a QuickQLProvider');
32
+ }
33
+ return context.client;
34
+ };
35
+ /**
36
+ * Hook to fetch data using QuickQL queries.
37
+ */
38
+ export function useQuickQL(query, config = {}) {
39
+ const client = useQuickQLClient();
40
+ const [data, setData] = useState(null);
41
+ const [loading, setLoading] = useState(false);
42
+ const [error, setError] = useState(null);
43
+ const queryKey = useMemo(() => JSON.stringify(query), [query]);
44
+ const fetchData = useCallback(async () => {
45
+ if (!query)
46
+ return;
47
+ setLoading(true);
48
+ setError(null);
49
+ try {
50
+ const response = await client.query(query);
51
+ if (response.errors) {
52
+ setError(response.errors);
53
+ }
54
+ else {
55
+ setData(response.data);
56
+ }
57
+ }
58
+ catch (e) {
59
+ setError([{ type: 'INTERNAL', message: e.message || 'Hook Error' }]);
60
+ }
61
+ finally {
62
+ setLoading(false);
63
+ }
64
+ }, [client, queryKey]);
65
+ useEffect(() => {
66
+ if (config.enabled !== false && query) {
67
+ fetchData();
68
+ }
69
+ }, [fetchData, config.enabled, queryKey]);
70
+ return { data, loading, error, refetch: fetchData };
71
+ }
72
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAU,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAuD,MAAM,eAAe,CAAC;AAMnG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"React Hooks and Providers for QuickQL by Udinmo Inc.",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "author": "Udinmo Inc. <engineering@udinmo.com>",
8
+ "license": "MIT",
9
+ "scripts": {
10
+ "build": "tsc"
11
+ },
12
+ "dependencies": {
13
+ "@quickql/core": "^1.0.0"
14
+ },
15
+ "peerDependencies": {
16
+ "react": "^19.x"
17
+ }
18
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * QuickQL React Bindings
3
+ *
4
+ * Provides React Hooks (useQuickQL) and Context Providers for seamless
5
+ * data fetching in React 18/19 and Next.js applications.
6
+ *
7
+ * (c) 2024-2026 Udinmo Inc. All rights reserved.
8
+ * Author: Udinmo Inc. <engineering@udinmo.com>
9
+ * License: MIT
10
+ */
11
+
12
+ import React, { createContext, useContext, useMemo, useState, useEffect, useCallback, useRef } from 'react';
13
+ import { QuickQLClient, ClientOptions, Query, QuickQLResponse, QuickQLError } from '@quickql/core';
14
+
15
+ interface QuickQLContextValue {
16
+ client: QuickQLClient;
17
+ }
18
+
19
+ const QuickQLContext = createContext<QuickQLContextValue | null>(null);
20
+
21
+ export interface QuickQLProviderProps {
22
+ options?: ClientOptions;
23
+ client?: QuickQLClient;
24
+ children: React.ReactNode;
25
+ }
26
+
27
+ /**
28
+ * Universal QuickQL Provider for React Apps
29
+ */
30
+ export const QuickQLProvider: React.FC<QuickQLProviderProps> = ({ options, client, children }) => {
31
+ const instance = useMemo(() => {
32
+ if (client) return client;
33
+ if (options) return new QuickQLClient(options);
34
+ throw new Error('QuickQLProvider requires either a "client" instance or "options".');
35
+ }, [client, options?.endpoint]);
36
+
37
+ return (
38
+ <QuickQLContext.Provider value={{ client: instance }}>
39
+ {children}
40
+ </QuickQLContext.Provider>
41
+ );
42
+ };
43
+
44
+ export const useQuickQLClient = () => {
45
+ const context = useContext(QuickQLContext);
46
+ if (!context) {
47
+ throw new Error('useQuickQLClient must be used within a QuickQLProvider');
48
+ }
49
+ return context.client;
50
+ };
51
+
52
+ export interface UseQuickQLOptions {
53
+ enabled?: boolean;
54
+ }
55
+
56
+ /**
57
+ * Hook to fetch data using QuickQL queries.
58
+ */
59
+ export function useQuickQL<T = any>(query: Query | null, config: UseQuickQLOptions = {}) {
60
+ const client = useQuickQLClient();
61
+ const [data, setData] = useState<T | null>(null);
62
+ const [loading, setLoading] = useState(false);
63
+ const [error, setError] = useState<QuickQLError[] | null>(null);
64
+
65
+ const queryKey = useMemo(() => JSON.stringify(query), [query]);
66
+
67
+ const fetchData = useCallback(async () => {
68
+ if (!query) return;
69
+ setLoading(true);
70
+ setError(null);
71
+ try {
72
+ const response = await client.query<T>(query);
73
+ if (response.errors) {
74
+ setError(response.errors);
75
+ } else {
76
+ setData(response.data);
77
+ }
78
+ } catch (e: any) {
79
+ setError([{ type: 'INTERNAL', message: e.message || 'Hook Error' }]);
80
+ } finally {
81
+ setLoading(false);
82
+ }
83
+ }, [client, queryKey]);
84
+
85
+ useEffect(() => {
86
+ if (config.enabled !== false && query) {
87
+ fetchData();
88
+ }
89
+ }, [fetchData, config.enabled, queryKey]);
90
+
91
+ return { data, loading, error, refetch: fetchData };
92
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist"
5
+ },
6
+ "include": ["src"]
7
+ }