@xylex-group/athena 1.0.2 → 1.1.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.
- package/README.md +12 -9
- package/dist/{index.mjs → index.cjs} +206 -83
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +84 -0
- package/dist/index.d.ts +51 -25
- package/dist/index.js +200 -83
- package/dist/index.js.map +1 -1
- package/dist/{react.mjs → react.cjs} +35 -45
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +6 -0
- package/dist/react.d.ts +2 -2
- package/dist/react.js +31 -45
- package/dist/react.js.map +1 -1
- package/dist/{types-DzCf3v76.d.mts → types-IHkO67Tl.d.cts} +33 -7
- package/dist/{types-DzCf3v76.d.ts → types-IHkO67Tl.d.ts} +33 -7
- package/package.json +57 -56
- package/dist/index.d.mts +0 -58
- package/dist/index.mjs.map +0 -1
- package/dist/react.d.mts +0 -6
- package/dist/react.mjs.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
1
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
4
2
|
|
|
5
3
|
// src/gateway/use-athena-gateway.ts
|
|
6
4
|
|
|
@@ -19,31 +17,32 @@ function normalizeHeaderValue(value) {
|
|
|
19
17
|
return value ? value : void 0;
|
|
20
18
|
}
|
|
21
19
|
function buildHeaders(config, options) {
|
|
22
|
-
const mergedStripNulls = options?.stripNulls ??
|
|
23
|
-
const finalClient = options?.client ?? config.client ?? DEFAULT_CLIENT;
|
|
24
|
-
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
25
|
-
const finalSupabaseUrl = options?.supabaseUrl ?? config.supabaseUrl;
|
|
26
|
-
const finalSupabaseKey = options?.supabaseKey ?? config.supabaseKey;
|
|
27
|
-
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
20
|
+
const mergedStripNulls = options?.stripNulls ?? true;
|
|
28
21
|
const extraHeaders = {
|
|
29
22
|
...config.headers ?? {},
|
|
30
23
|
...options?.headers ?? {}
|
|
31
24
|
};
|
|
25
|
+
const headerClient = extraHeaders["x-athena-client"] ?? extraHeaders["X-Athena-Client"];
|
|
26
|
+
const finalClient = options?.client ?? config.client ?? (typeof headerClient === "string" ? headerClient : void 0) ?? DEFAULT_CLIENT;
|
|
27
|
+
const finalApiKey = options?.apiKey ?? config.apiKey;
|
|
28
|
+
const finalPublishEvent = options?.publishEvent ?? config.publishEvent;
|
|
32
29
|
const headers = {
|
|
33
30
|
"Content-Type": "application/json"
|
|
34
31
|
};
|
|
35
32
|
if (options?.userId ?? config.userId) {
|
|
36
33
|
headers["X-User-Id"] = options?.userId ?? config.userId ?? "";
|
|
37
34
|
}
|
|
38
|
-
if (options?.companyId ?? config.companyId) {
|
|
39
|
-
headers["X-Company-Id"] = options?.companyId ?? config.companyId ?? "";
|
|
40
|
-
}
|
|
41
35
|
if (options?.organizationId ?? config.organizationId) {
|
|
42
36
|
headers["X-Organization-Id"] = options?.organizationId ?? config.organizationId ?? "";
|
|
43
37
|
}
|
|
44
38
|
if (finalClient) {
|
|
45
39
|
headers["X-Athena-Client"] = finalClient;
|
|
46
40
|
}
|
|
41
|
+
const finalBackend = options?.backend ?? config.backend;
|
|
42
|
+
if (finalBackend) {
|
|
43
|
+
const type = typeof finalBackend === "string" ? finalBackend : finalBackend.type;
|
|
44
|
+
if (type) headers["X-Backend-Type"] = type;
|
|
45
|
+
}
|
|
47
46
|
if (typeof mergedStripNulls === "boolean") {
|
|
48
47
|
headers["X-Strip-Nulls"] = mergedStripNulls ? "true" : "false";
|
|
49
48
|
}
|
|
@@ -54,13 +53,9 @@ function buildHeaders(config, options) {
|
|
|
54
53
|
headers["apikey"] = finalApiKey;
|
|
55
54
|
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
headers["x-supabase-url"] = finalSupabaseUrl;
|
|
59
|
-
}
|
|
60
|
-
if (finalSupabaseKey) {
|
|
61
|
-
headers["x-supabase-key"] = finalSupabaseKey;
|
|
62
|
-
}
|
|
56
|
+
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
63
57
|
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
58
|
+
if (athenaClientKeys.includes(key)) return;
|
|
64
59
|
const normalized = normalizeHeaderValue(value);
|
|
65
60
|
if (normalized) {
|
|
66
61
|
headers[key] = normalized;
|
|
@@ -125,41 +120,35 @@ function createAthenaGatewayClient(config = {}) {
|
|
|
125
120
|
|
|
126
121
|
// src/gateway/use-athena-gateway.ts
|
|
127
122
|
function useAthenaGateway(config) {
|
|
128
|
-
const [isLoading, setIsLoading] =
|
|
129
|
-
const [error, setError] =
|
|
130
|
-
const [lastRequest, setLastRequest] =
|
|
123
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
124
|
+
const [error, setError] = useState(null);
|
|
125
|
+
const [lastRequest, setLastRequest] = useState(
|
|
131
126
|
null
|
|
132
127
|
);
|
|
133
|
-
const [lastResponse, setLastResponse] =
|
|
134
|
-
const client =
|
|
128
|
+
const [lastResponse, setLastResponse] = useState(null);
|
|
129
|
+
const client = useMemo(
|
|
135
130
|
() => createAthenaGatewayClient({
|
|
136
131
|
client: config?.client,
|
|
137
132
|
baseUrl: config?.baseUrl,
|
|
138
133
|
apiKey: config?.apiKey,
|
|
139
|
-
|
|
140
|
-
supabaseKey: config?.supabaseKey,
|
|
134
|
+
backend: config?.backend,
|
|
141
135
|
publishEvent: config?.publishEvent,
|
|
142
|
-
stripNulls: config?.stripNulls,
|
|
143
136
|
headers: config?.headers,
|
|
144
137
|
userId: config?.userId,
|
|
145
|
-
companyId: config?.companyId,
|
|
146
138
|
organizationId: config?.organizationId
|
|
147
139
|
}),
|
|
148
140
|
[
|
|
149
141
|
config?.baseUrl,
|
|
150
142
|
config?.client,
|
|
151
143
|
config?.apiKey,
|
|
152
|
-
config?.
|
|
153
|
-
config?.supabaseKey,
|
|
144
|
+
config?.backend,
|
|
154
145
|
config?.publishEvent,
|
|
155
|
-
config?.stripNulls,
|
|
156
146
|
config?.headers,
|
|
157
147
|
config?.userId,
|
|
158
|
-
config?.companyId,
|
|
159
148
|
config?.organizationId
|
|
160
149
|
]
|
|
161
150
|
);
|
|
162
|
-
const callWithLifecycle =
|
|
151
|
+
const callWithLifecycle = useCallback(
|
|
163
152
|
async (fn, metadata) => {
|
|
164
153
|
const requestLog = {
|
|
165
154
|
endpoint: metadata.endpoint,
|
|
@@ -199,16 +188,13 @@ function useAthenaGateway(config) {
|
|
|
199
188
|
},
|
|
200
189
|
[client]
|
|
201
190
|
);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
[config?.stripNulls]
|
|
205
|
-
);
|
|
206
|
-
const fetchGateway = react.useCallback(
|
|
191
|
+
const defaultStripNulls = true;
|
|
192
|
+
const fetchGateway = useCallback(
|
|
207
193
|
(payload, options) => {
|
|
208
194
|
const normalizedPayload = {
|
|
209
195
|
...payload,
|
|
210
196
|
conditions: payload.conditions ?? [],
|
|
211
|
-
strip_nulls: payload.strip_nulls ?? options?.stripNulls ??
|
|
197
|
+
strip_nulls: payload.strip_nulls ?? options?.stripNulls ?? defaultStripNulls
|
|
212
198
|
};
|
|
213
199
|
return callWithLifecycle(
|
|
214
200
|
() => client.fetchGateway(normalizedPayload, options),
|
|
@@ -220,9 +206,9 @@ function useAthenaGateway(config) {
|
|
|
220
206
|
}
|
|
221
207
|
);
|
|
222
208
|
},
|
|
223
|
-
[callWithLifecycle, client
|
|
209
|
+
[callWithLifecycle, client]
|
|
224
210
|
);
|
|
225
|
-
const insertGateway =
|
|
211
|
+
const insertGateway = useCallback(
|
|
226
212
|
(payload, options) => callWithLifecycle(() => client.insertGateway(payload, options), {
|
|
227
213
|
endpoint: "/gateway/insert",
|
|
228
214
|
method: "PUT",
|
|
@@ -231,12 +217,12 @@ function useAthenaGateway(config) {
|
|
|
231
217
|
}),
|
|
232
218
|
[callWithLifecycle, client]
|
|
233
219
|
);
|
|
234
|
-
const updateGateway =
|
|
220
|
+
const updateGateway = useCallback(
|
|
235
221
|
(payload, options) => {
|
|
236
222
|
const normalizedPayload = {
|
|
237
223
|
...payload,
|
|
238
224
|
conditions: payload.conditions ?? [],
|
|
239
|
-
strip_nulls: payload.strip_nulls ?? options?.stripNulls ??
|
|
225
|
+
strip_nulls: payload.strip_nulls ?? options?.stripNulls ?? defaultStripNulls
|
|
240
226
|
};
|
|
241
227
|
return callWithLifecycle(
|
|
242
228
|
() => client.updateGateway(normalizedPayload, options),
|
|
@@ -248,9 +234,9 @@ function useAthenaGateway(config) {
|
|
|
248
234
|
}
|
|
249
235
|
);
|
|
250
236
|
},
|
|
251
|
-
[callWithLifecycle, client
|
|
237
|
+
[callWithLifecycle, client]
|
|
252
238
|
);
|
|
253
|
-
const deleteGateway =
|
|
239
|
+
const deleteGateway = useCallback(
|
|
254
240
|
(payload, options) => {
|
|
255
241
|
if (!payload.resource_id) {
|
|
256
242
|
throw new Error(
|
|
@@ -277,6 +263,6 @@ function useAthenaGateway(config) {
|
|
|
277
263
|
};
|
|
278
264
|
}
|
|
279
265
|
|
|
280
|
-
|
|
266
|
+
export { useAthenaGateway };
|
|
281
267
|
//# sourceMappingURL=react.js.map
|
|
282
268
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gateway/client.ts","../src/gateway/use-athena-gateway.ts"],"names":["useState","useMemo","useCallback"],"mappings":";;;;;;;AAcA,IAAM,gBAAA,GAAmB,uBAAA;AACzB,IAAM,cAAA,GAAiB,gBAAA;AAEvB,SAAS,kBAAkB,IAAA,EAAc;AACvC,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;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AA,EAAS,UAAA,IACT;AAAA,OACJ;AACA,MAAA,OAAO,iBAAA;AAAA,QACL,MAAM,MAAA,CAAO,aAAA,CAAiB,iBAAA,EAAmB,OAAO,CAAA;AAAA,QACxD;AAAA,UACE,QAAA,EAAU,iBAAA;AAAA,UACV,MAAA,EAAQ,MAAA;AAAA,UACR,OAAA,EAAS,iBAAA;AAAA,UACT;AAAA;AACF,OACF;AAAA,IACF,CAAA;AAAA,IACA,CAAC,iBAAA,EAAmB,MAAA,EAAQ,0BAA0B;AAAA,GACxD;AAEA,EAAA,MAAM,aAAA,GAAgBA,iBAAA;AAAA,IACpB,CACE,SACA,OAAA,KACG;AACH,MAAA,IAAI,CAAC,QAAQ,WAAA,EAAa;AACxB,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SACF;AAAA,MACF;AACA,MAAA,OAAO,iBAAA;AAAA,QACL,MAAM,MAAA,CAAO,aAAA,CAAiB,OAAA,EAAS,OAAO,CAAA;AAAA,QAC9C,EAAE,QAAA,EAAU,iBAAA,EAAmB,MAAA,EAAQ,QAAA,EAAU,SAAS,OAAA;AAAQ,OACpE;AAAA,IACF,CAAA;AAAA,IACA,CAAC,mBAAmB,MAAM;AAAA,GAC5B;AAEA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAS,MAAA,CAAO;AAAA,GAClB;AACF","file":"react.js","sourcesContent":["import type {\r\n AthenaGatewayBaseOptions,\r\n AthenaGatewayCallOptions,\r\n AthenaGatewayEndpointPath,\r\n AthenaGatewayMethod,\r\n AthenaGatewayResponse,\r\n} from \"./types.js\";\r\nimport type {\r\n AthenaDeletePayload,\r\n AthenaFetchPayload,\r\n AthenaInsertPayload,\r\n AthenaUpdatePayload,\r\n} from \"./types.js\";\r\n\r\nconst DEFAULT_BASE_URL = \"https://athena-db.com\";\r\nconst DEFAULT_CLIENT = \"railway_direct\";\r\n\r\nfunction parseResponseText(text: string) {\r\n if (!text) return null;\r\n try {\r\n return JSON.parse(text);\r\n } catch {\r\n return text;\r\n }\r\n}\r\n\r\nfunction normalizeHeaderValue(value?: string | null) {\r\n return value ? value : undefined;\r\n}\r\n\r\nfunction buildHeaders(\r\n config: AthenaGatewayBaseOptions,\r\n options?: AthenaGatewayCallOptions,\r\n): Record<string, string> {\r\n const mergedStripNulls = options?.stripNulls ?? config.stripNulls ?? true;\r\n const finalClient = options?.client ?? config.client ?? DEFAULT_CLIENT;\r\n const finalApiKey = options?.apiKey ?? config.apiKey;\r\n const finalSupabaseUrl = options?.supabaseUrl ?? config.supabaseUrl;\r\n const finalSupabaseKey = options?.supabaseKey ?? config.supabaseKey;\r\n const finalPublishEvent = options?.publishEvent ?? config.publishEvent;\r\n const extraHeaders = {\r\n ...(config.headers ?? {}),\r\n ...(options?.headers ?? {}),\r\n };\r\n\r\n const headers: Record<string, string> = {\r\n \"Content-Type\": \"application/json\",\r\n };\r\n\r\n if (options?.userId ?? config.userId) {\r\n headers[\"X-User-Id\"] = options?.userId ?? config.userId ?? \"\";\r\n }\r\n\r\n if (options?.companyId ?? config.companyId) {\r\n headers[\"X-Company-Id\"] = options?.companyId ?? config.companyId ?? \"\";\r\n }\r\n\r\n if (options?.organizationId ?? config.organizationId) {\r\n headers[\"X-Organization-Id\"] =\r\n options?.organizationId ?? config.organizationId ?? \"\";\r\n }\r\n\r\n if (finalClient) {\r\n headers[\"X-Athena-Client\"] = finalClient;\r\n }\r\n\r\n if (typeof mergedStripNulls === \"boolean\") {\r\n headers[\"X-Strip-Nulls\"] = mergedStripNulls ? \"true\" : \"false\";\r\n }\r\n\r\n if (finalPublishEvent) {\r\n headers[\"X-Publish-Event\"] = finalPublishEvent;\r\n }\r\n\r\n if (finalApiKey) {\r\n headers[\"apikey\"] = finalApiKey;\r\n headers[\"x-api-key\"] = headers[\"x-api-key\"] ?? finalApiKey;\r\n }\r\n\r\n if (finalSupabaseUrl) {\r\n headers[\"x-supabase-url\"] = finalSupabaseUrl;\r\n }\r\n\r\n if (finalSupabaseKey) {\r\n headers[\"x-supabase-key\"] = finalSupabaseKey;\r\n }\r\n\r\n Object.entries(extraHeaders).forEach(([key, value]) => {\r\n const normalized = normalizeHeaderValue(value);\r\n if (normalized) {\r\n headers[key] = normalized;\r\n }\r\n });\r\n\r\n return headers;\r\n}\r\n\r\nasync function callAthena<T>(\r\n config: AthenaGatewayBaseOptions,\r\n endpoint: AthenaGatewayEndpointPath,\r\n method: AthenaGatewayMethod,\r\n payload: unknown,\r\n options?: AthenaGatewayCallOptions,\r\n): Promise<AthenaGatewayResponse<T>> {\r\n const baseUrl = (\r\n options?.baseUrl ??\r\n config.baseUrl ??\r\n DEFAULT_BASE_URL\r\n ).replace(/\\/$/, \"\");\r\n const url = `${baseUrl}${endpoint}`;\r\n const headers = buildHeaders(config, options);\r\n\r\n try {\r\n const response = await fetch(url, {\r\n method,\r\n headers,\r\n body: JSON.stringify(payload),\r\n });\r\n\r\n const rawText = await response.text();\r\n const parsed = parseResponseText(rawText ?? \"\");\r\n const parsedPayload = parsed as Record<string, unknown> | null;\r\n const parsedError =\r\n parsedPayload && typeof parsedPayload === \"object\"\r\n ? ((parsedPayload.error as string | undefined) ??\r\n (parsedPayload.message as string | undefined))\r\n : undefined;\r\n const hasError =\r\n typeof parsedError === \"string\" && parsedError.length > 0\r\n ? parsedError\r\n : undefined;\r\n\r\n // Unwrap envelope: API may return { data: [...], error: null } (e.g. when cached)\r\n // vs raw array when uncached. Use inner data when present to avoid double nesting.\r\n const payloadData =\r\n parsedPayload &&\r\n typeof parsedPayload === \"object\" &&\r\n \"data\" in parsedPayload\r\n ? (parsedPayload.data as T)\r\n : (parsed as T);\r\n\r\n return {\r\n ok: response.ok,\r\n status: response.status,\r\n data: payloadData ?? null,\r\n error: hasError,\r\n raw: parsed,\r\n };\r\n } catch (callError) {\r\n const message =\r\n callError instanceof Error ? callError.message : String(callError);\r\n return {\r\n ok: false,\r\n status: 0,\r\n data: null,\r\n error: message,\r\n raw: null,\r\n };\r\n }\r\n}\r\n\r\nexport interface AthenaGatewayClient {\r\n baseUrl: string;\r\n buildHeaders(options?: AthenaGatewayCallOptions): Record<string, string>;\r\n fetchGateway<T>(\r\n payload: AthenaFetchPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n insertGateway<T>(\r\n payload: AthenaInsertPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n updateGateway<T>(\r\n payload: AthenaUpdatePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n deleteGateway<T>(\r\n payload: AthenaDeletePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n}\r\n\r\nexport function createAthenaGatewayClient(\r\n config: AthenaGatewayBaseOptions = {},\r\n): AthenaGatewayClient {\r\n return {\r\n baseUrl: (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\"),\r\n buildHeaders(options) {\r\n return buildHeaders(config, options);\r\n },\r\n fetchGateway(payload, options) {\r\n return callAthena(config, \"/gateway/fetch\", \"POST\", payload, options);\r\n },\r\n insertGateway(payload, options) {\r\n return callAthena(config, \"/gateway/insert\", \"PUT\", payload, options);\r\n },\r\n updateGateway(payload, options) {\r\n return callAthena(config, \"/gateway/update\", \"POST\", payload, options);\r\n },\r\n deleteGateway(payload, options) {\r\n return callAthena(config, \"/gateway/delete\", \"DELETE\", payload, options);\r\n },\r\n };\r\n}\r\n","import { useCallback, useMemo, useState } from \"react\";\r\nimport type {\r\n AthenaDeletePayload,\r\n AthenaFetchPayload,\r\n AthenaGatewayCallLog,\r\n AthenaGatewayCallOptions,\r\n AthenaGatewayHookConfig,\r\n AthenaGatewayHookResult,\r\n AthenaGatewayResponse,\r\n AthenaGatewayResponseLog,\r\n AthenaInsertPayload,\r\n AthenaUpdatePayload,\r\n} from \"./types.js\";\r\nimport { createAthenaGatewayClient } from \"./client.js\";\r\n\r\nexport function useAthenaGateway(\r\n config?: AthenaGatewayHookConfig,\r\n): AthenaGatewayHookResult {\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [error, setError] = useState<string | null>(null);\r\n const [lastRequest, setLastRequest] = useState<AthenaGatewayCallLog | null>(\r\n null,\r\n );\r\n const [lastResponse, setLastResponse] =\r\n useState<AthenaGatewayResponseLog | null>(null);\r\n\r\n const client = useMemo(\r\n () =>\r\n createAthenaGatewayClient({\r\n client: config?.client,\r\n baseUrl: config?.baseUrl,\r\n apiKey: config?.apiKey,\r\n supabaseUrl: config?.supabaseUrl,\r\n supabaseKey: config?.supabaseKey,\r\n publishEvent: config?.publishEvent,\r\n stripNulls: config?.stripNulls,\r\n headers: config?.headers,\r\n userId: config?.userId,\r\n companyId: config?.companyId,\r\n organizationId: config?.organizationId,\r\n }),\r\n [\r\n config?.baseUrl,\r\n config?.client,\r\n config?.apiKey,\r\n config?.supabaseUrl,\r\n config?.supabaseKey,\r\n config?.publishEvent,\r\n config?.stripNulls,\r\n config?.headers,\r\n config?.userId,\r\n config?.companyId,\r\n config?.organizationId,\r\n ],\r\n );\r\n\r\n const callWithLifecycle = useCallback(\r\n async <T>(\r\n fn: () => Promise<AthenaGatewayResponse<T>>,\r\n metadata: {\r\n endpoint: string;\r\n method: string;\r\n payload: unknown;\r\n options?: AthenaGatewayCallOptions;\r\n },\r\n ): Promise<AthenaGatewayResponse<T>> => {\r\n const requestLog: AthenaGatewayCallLog = {\r\n endpoint: metadata.endpoint as any,\r\n method: metadata.method as any,\r\n payload: metadata.payload,\r\n headers: client.buildHeaders(metadata.options),\r\n timestamp: new Date().toISOString(),\r\n };\r\n\r\n setLastRequest(requestLog);\r\n setIsLoading(true);\r\n setError(null);\r\n\r\n let response: AthenaGatewayResponse<T> | undefined;\r\n try {\r\n response = await fn();\r\n setLastResponse({ ...response, timestamp: new Date().toISOString() });\r\n\r\n if (!response.ok) {\r\n const message =\r\n response.error ||\r\n `Athena gateway ${metadata.method} ${metadata.endpoint} failed`;\r\n setError(message);\r\n throw new Error(message);\r\n }\r\n\r\n return response;\r\n } catch (callError) {\r\n const message =\r\n callError instanceof Error ? callError.message : String(callError);\r\n setError(message);\r\n setLastResponse({\r\n timestamp: new Date().toISOString(),\r\n status: response?.status ?? 0,\r\n ok: false,\r\n data: null,\r\n raw: null,\r\n error: message,\r\n });\r\n throw callError;\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n },\r\n [client],\r\n );\r\n\r\n const normalizedConfigStripNulls = useMemo(\r\n () => config?.stripNulls ?? true,\r\n [config?.stripNulls],\r\n );\r\n\r\n const fetchGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaFetchPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n const normalizedPayload: AthenaFetchPayload = {\r\n ...payload,\r\n conditions: payload.conditions ?? [],\r\n strip_nulls:\r\n payload.strip_nulls ??\r\n options?.stripNulls ??\r\n normalizedConfigStripNulls,\r\n };\r\n return callWithLifecycle<T>(\r\n () => client.fetchGateway<T>(normalizedPayload, options),\r\n {\r\n endpoint: \"/gateway/fetch\",\r\n method: \"POST\",\r\n payload: normalizedPayload,\r\n options,\r\n },\r\n );\r\n },\r\n [callWithLifecycle, client, normalizedConfigStripNulls],\r\n );\r\n\r\n const insertGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaInsertPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) =>\r\n callWithLifecycle<T>(() => client.insertGateway<T>(payload, options), {\r\n endpoint: \"/gateway/insert\",\r\n method: \"PUT\",\r\n payload,\r\n options,\r\n }),\r\n [callWithLifecycle, client],\r\n );\r\n\r\n const updateGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaUpdatePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n const normalizedPayload: AthenaUpdatePayload = {\r\n ...payload,\r\n conditions: payload.conditions ?? [],\r\n strip_nulls:\r\n payload.strip_nulls ??\r\n options?.stripNulls ??\r\n normalizedConfigStripNulls,\r\n };\r\n return callWithLifecycle<T>(\r\n () => client.updateGateway<T>(normalizedPayload, options),\r\n {\r\n endpoint: \"/gateway/update\",\r\n method: \"POST\",\r\n payload: normalizedPayload,\r\n options,\r\n },\r\n );\r\n },\r\n [callWithLifecycle, client, normalizedConfigStripNulls],\r\n );\r\n\r\n const deleteGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaDeletePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n if (!payload.resource_id) {\r\n throw new Error(\r\n \"deleteGateway requires resource_id (the unique identifier of the record to delete)\",\r\n );\r\n }\r\n return callWithLifecycle<T>(\r\n () => client.deleteGateway<T>(payload, options),\r\n { endpoint: \"/gateway/delete\", method: \"DELETE\", payload, options },\r\n );\r\n },\r\n [callWithLifecycle, client],\r\n );\r\n\r\n return {\r\n fetchGateway,\r\n insertGateway,\r\n updateGateway,\r\n deleteGateway,\r\n isLoading,\r\n error,\r\n lastRequest,\r\n lastResponse,\r\n baseUrl: client.baseUrl,\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/gateway/client.ts","../src/gateway/use-athena-gateway.ts"],"names":[],"mappings":";;;;;AAcA,IAAM,gBAAA,GAAmB,uBAAA;AACzB,IAAM,cAAA,GAAiB,gBAAA;AAEvB,SAAS,kBAAkB,IAAA,EAAc;AACvC,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,MAAM,IAAI,CAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAEA,SAAS,qBAAqB,KAAA,EAAuB;AACnD,EAAA,OAAO,QAAQ,KAAA,GAAQ,MAAA;AACzB;AAEA,SAAS,YAAA,CACP,QACA,OAAA,EACwB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AAA,MACF;AACA,MAAA,OAAO,iBAAA;AAAA,QACL,MAAM,MAAA,CAAO,aAAA,CAAiB,OAAA,EAAS,OAAO,CAAA;AAAA,QAC9C,EAAE,QAAA,EAAU,iBAAA,EAAmB,MAAA,EAAQ,QAAA,EAAU,SAAS,OAAA;AAAQ,OACpE;AAAA,IACF,CAAA;AAAA,IACA,CAAC,mBAAmB,MAAM;AAAA,GAC5B;AAEA,EAAA,OAAO;AAAA,IACL,YAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAS,MAAA,CAAO;AAAA,GAClB;AACF","file":"react.js","sourcesContent":["import type {\r\n AthenaGatewayBaseOptions,\r\n AthenaGatewayCallOptions,\r\n AthenaGatewayEndpointPath,\r\n AthenaGatewayMethod,\r\n AthenaGatewayResponse,\r\n} from \"./types.js\";\r\nimport type {\r\n AthenaDeletePayload,\r\n AthenaFetchPayload,\r\n AthenaInsertPayload,\r\n AthenaUpdatePayload,\r\n} from \"./types.js\";\r\n\r\nconst DEFAULT_BASE_URL = \"https://athena-db.com\";\r\nconst DEFAULT_CLIENT = \"railway_direct\";\r\n\r\nfunction parseResponseText(text: string) {\r\n if (!text) return null;\r\n try {\r\n return JSON.parse(text);\r\n } catch {\r\n return text;\r\n }\r\n}\r\n\r\nfunction normalizeHeaderValue(value?: string | null) {\r\n return value ? value : undefined;\r\n}\r\n\r\nfunction buildHeaders(\r\n config: AthenaGatewayBaseOptions,\r\n options?: AthenaGatewayCallOptions,\r\n): Record<string, string> {\r\n const mergedStripNulls = options?.stripNulls ?? true;\r\n const extraHeaders = {\r\n ...(config.headers ?? {}),\r\n ...(options?.headers ?? {}),\r\n };\r\n const headerClient =\r\n extraHeaders[\"x-athena-client\"] ??\r\n extraHeaders[\"X-Athena-Client\"];\r\n const finalClient =\r\n options?.client ??\r\n config.client ??\r\n (typeof headerClient === \"string\" ? headerClient : undefined) ??\r\n DEFAULT_CLIENT;\r\n const finalApiKey = options?.apiKey ?? config.apiKey;\r\n const finalPublishEvent = options?.publishEvent ?? config.publishEvent;\r\n\r\n const headers: Record<string, string> = {\r\n \"Content-Type\": \"application/json\",\r\n };\r\n\r\n if (options?.userId ?? config.userId) {\r\n headers[\"X-User-Id\"] = options?.userId ?? config.userId ?? \"\";\r\n }\r\n\r\n if (options?.organizationId ?? config.organizationId) {\r\n headers[\"X-Organization-Id\"] =\r\n options?.organizationId ?? config.organizationId ?? \"\";\r\n }\r\n\r\n if (finalClient) {\r\n headers[\"X-Athena-Client\"] = finalClient;\r\n }\r\n\r\n const finalBackend = options?.backend ?? config.backend;\r\n if (finalBackend) {\r\n const type = typeof finalBackend === \"string\" ? finalBackend : finalBackend.type;\r\n if (type) headers[\"X-Backend-Type\"] = type;\r\n }\r\n\r\n if (typeof mergedStripNulls === \"boolean\") {\r\n headers[\"X-Strip-Nulls\"] = mergedStripNulls ? \"true\" : \"false\";\r\n }\r\n\r\n if (finalPublishEvent) {\r\n headers[\"X-Publish-Event\"] = finalPublishEvent;\r\n }\r\n\r\n if (finalApiKey) {\r\n headers[\"apikey\"] = finalApiKey;\r\n headers[\"x-api-key\"] = headers[\"x-api-key\"] ?? finalApiKey;\r\n }\r\n\r\n const athenaClientKeys = [\"x-athena-client\", \"X-Athena-Client\"];\r\n Object.entries(extraHeaders).forEach(([key, value]) => {\r\n if (athenaClientKeys.includes(key)) return;\r\n const normalized = normalizeHeaderValue(value);\r\n if (normalized) {\r\n headers[key] = normalized;\r\n }\r\n });\r\n\r\n return headers;\r\n}\r\n\r\nasync function callAthena<T>(\r\n config: AthenaGatewayBaseOptions,\r\n endpoint: AthenaGatewayEndpointPath,\r\n method: AthenaGatewayMethod,\r\n payload: unknown,\r\n options?: AthenaGatewayCallOptions,\r\n): Promise<AthenaGatewayResponse<T>> {\r\n const baseUrl = (\r\n options?.baseUrl ??\r\n config.baseUrl ??\r\n DEFAULT_BASE_URL\r\n ).replace(/\\/$/, \"\");\r\n const url = `${baseUrl}${endpoint}`;\r\n const headers = buildHeaders(config, options);\r\n\r\n try {\r\n const response = await fetch(url, {\r\n method,\r\n headers,\r\n body: JSON.stringify(payload),\r\n });\r\n\r\n const rawText = await response.text();\r\n const parsed = parseResponseText(rawText ?? \"\");\r\n const parsedPayload = parsed as Record<string, unknown> | null;\r\n const parsedError =\r\n parsedPayload && typeof parsedPayload === \"object\"\r\n ? ((parsedPayload.error as string | undefined) ??\r\n (parsedPayload.message as string | undefined))\r\n : undefined;\r\n const hasError =\r\n typeof parsedError === \"string\" && parsedError.length > 0\r\n ? parsedError\r\n : undefined;\r\n\r\n // Unwrap envelope: API may return { data: [...], error: null } (e.g. when cached)\r\n // vs raw array when uncached. Use inner data when present to avoid double nesting.\r\n const payloadData =\r\n parsedPayload &&\r\n typeof parsedPayload === \"object\" &&\r\n \"data\" in parsedPayload\r\n ? (parsedPayload.data as T)\r\n : (parsed as T);\r\n\r\n return {\r\n ok: response.ok,\r\n status: response.status,\r\n data: payloadData ?? null,\r\n error: hasError,\r\n raw: parsed,\r\n };\r\n } catch (callError) {\r\n const message =\r\n callError instanceof Error ? callError.message : String(callError);\r\n return {\r\n ok: false,\r\n status: 0,\r\n data: null,\r\n error: message,\r\n raw: null,\r\n };\r\n }\r\n}\r\n\r\nexport interface AthenaGatewayClient {\r\n baseUrl: string;\r\n buildHeaders(options?: AthenaGatewayCallOptions): Record<string, string>;\r\n fetchGateway<T>(\r\n payload: AthenaFetchPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n insertGateway<T>(\r\n payload: AthenaInsertPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n updateGateway<T>(\r\n payload: AthenaUpdatePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n deleteGateway<T>(\r\n payload: AthenaDeletePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ): Promise<AthenaGatewayResponse<T>>;\r\n}\r\n\r\nexport function createAthenaGatewayClient(\r\n config: AthenaGatewayBaseOptions = {},\r\n): AthenaGatewayClient {\r\n return {\r\n baseUrl: (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, \"\"),\r\n buildHeaders(options) {\r\n return buildHeaders(config, options);\r\n },\r\n fetchGateway(payload, options) {\r\n return callAthena(config, \"/gateway/fetch\", \"POST\", payload, options);\r\n },\r\n insertGateway(payload, options) {\r\n return callAthena(config, \"/gateway/insert\", \"PUT\", payload, options);\r\n },\r\n updateGateway(payload, options) {\r\n return callAthena(config, \"/gateway/update\", \"POST\", payload, options);\r\n },\r\n deleteGateway(payload, options) {\r\n return callAthena(config, \"/gateway/delete\", \"DELETE\", payload, options);\r\n },\r\n };\r\n}\r\n","import { useCallback, useMemo, useState } from \"react\";\r\nimport type {\r\n AthenaDeletePayload,\r\n AthenaFetchPayload,\r\n AthenaGatewayCallLog,\r\n AthenaGatewayCallOptions,\r\n AthenaGatewayEndpointPath,\r\n AthenaGatewayHookConfig,\r\n AthenaGatewayHookResult,\r\n AthenaGatewayMethod,\r\n AthenaGatewayResponse,\r\n AthenaGatewayResponseLog,\r\n AthenaInsertPayload,\r\n AthenaUpdatePayload,\r\n} from \"./types.js\";\r\nimport { createAthenaGatewayClient } from \"./client.js\";\r\n\r\nexport function useAthenaGateway(\r\n config?: AthenaGatewayHookConfig,\r\n): AthenaGatewayHookResult {\r\n const [isLoading, setIsLoading] = useState(false);\r\n const [error, setError] = useState<string | null>(null);\r\n const [lastRequest, setLastRequest] = useState<AthenaGatewayCallLog | null>(\r\n null,\r\n );\r\n const [lastResponse, setLastResponse] =\r\n useState<AthenaGatewayResponseLog | null>(null);\r\n\r\n const client = useMemo(\r\n () =>\r\n createAthenaGatewayClient({\r\n client: config?.client,\r\n baseUrl: config?.baseUrl,\r\n apiKey: config?.apiKey,\r\n backend: config?.backend,\r\n publishEvent: config?.publishEvent,\r\n headers: config?.headers,\r\n userId: config?.userId,\r\n organizationId: config?.organizationId,\r\n }),\r\n [\r\n config?.baseUrl,\r\n config?.client,\r\n config?.apiKey,\r\n config?.backend,\r\n config?.publishEvent,\r\n config?.headers,\r\n config?.userId,\r\n config?.organizationId,\r\n ],\r\n );\r\n\r\n const callWithLifecycle = useCallback(\r\n async <T>(\r\n fn: () => Promise<AthenaGatewayResponse<T>>,\r\n metadata: {\r\n endpoint: string;\r\n method: string;\r\n payload: unknown;\r\n options?: AthenaGatewayCallOptions;\r\n },\r\n ): Promise<AthenaGatewayResponse<T>> => {\r\n const requestLog: AthenaGatewayCallLog = {\r\n endpoint: metadata.endpoint as AthenaGatewayEndpointPath,\r\n method: metadata.method as AthenaGatewayMethod,\r\n payload: metadata.payload,\r\n headers: client.buildHeaders(metadata.options),\r\n timestamp: new Date().toISOString(),\r\n };\r\n\r\n setLastRequest(requestLog);\r\n setIsLoading(true);\r\n setError(null);\r\n\r\n let response: AthenaGatewayResponse<T> | undefined;\r\n try {\r\n response = await fn();\r\n setLastResponse({ ...response, timestamp: new Date().toISOString() });\r\n\r\n if (!response.ok) {\r\n const message =\r\n response.error ||\r\n `Athena gateway ${metadata.method} ${metadata.endpoint} failed`;\r\n setError(message);\r\n throw new Error(message);\r\n }\r\n\r\n return response;\r\n } catch (callError) {\r\n const message =\r\n callError instanceof Error ? callError.message : String(callError);\r\n setError(message);\r\n setLastResponse({\r\n timestamp: new Date().toISOString(),\r\n status: response?.status ?? 0,\r\n ok: false,\r\n data: null,\r\n raw: null,\r\n error: message,\r\n });\r\n throw callError;\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n },\r\n [client],\r\n );\r\n\r\n const defaultStripNulls = true;\r\n\r\n const fetchGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaFetchPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n const normalizedPayload: AthenaFetchPayload = {\r\n ...payload,\r\n conditions: payload.conditions ?? [],\r\n strip_nulls:\r\n payload.strip_nulls ??\r\n options?.stripNulls ??\r\n defaultStripNulls,\r\n };\r\n return callWithLifecycle<T>(\r\n () => client.fetchGateway<T>(normalizedPayload, options),\r\n {\r\n endpoint: \"/gateway/fetch\",\r\n method: \"POST\",\r\n payload: normalizedPayload,\r\n options,\r\n },\r\n );\r\n },\r\n [callWithLifecycle, client],\r\n );\r\n\r\n const insertGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaInsertPayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) =>\r\n callWithLifecycle<T>(() => client.insertGateway<T>(payload, options), {\r\n endpoint: \"/gateway/insert\",\r\n method: \"PUT\",\r\n payload,\r\n options,\r\n }),\r\n [callWithLifecycle, client],\r\n );\r\n\r\n const updateGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaUpdatePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n const normalizedPayload: AthenaUpdatePayload = {\r\n ...payload,\r\n conditions: payload.conditions ?? [],\r\n strip_nulls:\r\n payload.strip_nulls ??\r\n options?.stripNulls ??\r\n defaultStripNulls,\r\n };\r\n return callWithLifecycle<T>(\r\n () => client.updateGateway<T>(normalizedPayload, options),\r\n {\r\n endpoint: \"/gateway/update\",\r\n method: \"POST\",\r\n payload: normalizedPayload,\r\n options,\r\n },\r\n );\r\n },\r\n [callWithLifecycle, client],\r\n );\r\n\r\n const deleteGateway = useCallback(\r\n <T = unknown>(\r\n payload: AthenaDeletePayload,\r\n options?: AthenaGatewayCallOptions,\r\n ) => {\r\n if (!payload.resource_id) {\r\n throw new Error(\r\n \"deleteGateway requires resource_id (the unique identifier of the record to delete)\",\r\n );\r\n }\r\n return callWithLifecycle<T>(\r\n () => client.deleteGateway<T>(payload, options),\r\n { endpoint: \"/gateway/delete\", method: \"DELETE\", payload, options },\r\n );\r\n },\r\n [callWithLifecycle, client],\r\n );\r\n\r\n return {\r\n fetchGateway,\r\n insertGateway,\r\n updateGateway,\r\n deleteGateway,\r\n isLoading,\r\n error,\r\n lastRequest,\r\n lastResponse,\r\n baseUrl: client.baseUrl,\r\n };\r\n}\r\n"]}
|
|
@@ -13,6 +13,9 @@ interface AthenaGatewayCondition {
|
|
|
13
13
|
column?: string;
|
|
14
14
|
operator: AthenaConditionOperator;
|
|
15
15
|
value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
16
|
+
/** Back-compat shape expected by older gateway implementations */
|
|
17
|
+
eq_column?: string;
|
|
18
|
+
eq_value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
16
19
|
}
|
|
17
20
|
interface AthenaFetchPayload {
|
|
18
21
|
view_name?: string;
|
|
@@ -50,18 +53,40 @@ interface AthenaDeletePayload {
|
|
|
50
53
|
interface AthenaUpdatePayload extends AthenaFetchPayload {
|
|
51
54
|
update_body?: Record<string, unknown>;
|
|
52
55
|
}
|
|
56
|
+
/** Backend type for Athena client (aligns with athena-rs) */
|
|
57
|
+
type BackendType = 'athena' | 'postgrest' | 'supabase' | 'postgresql' | 'scylladb';
|
|
58
|
+
/** Backend config: type from SDK + backend-scoped options */
|
|
59
|
+
interface BackendConfig {
|
|
60
|
+
type: BackendType;
|
|
61
|
+
options?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
/** Pre-defined backends for lean usage: backend: Backend.Athena */
|
|
64
|
+
declare const Backend: {
|
|
65
|
+
readonly Athena: {
|
|
66
|
+
readonly type: "athena";
|
|
67
|
+
};
|
|
68
|
+
readonly Supabase: {
|
|
69
|
+
readonly type: "supabase";
|
|
70
|
+
};
|
|
71
|
+
readonly Postgrest: {
|
|
72
|
+
readonly type: "postgrest";
|
|
73
|
+
};
|
|
74
|
+
readonly PostgreSQL: {
|
|
75
|
+
readonly type: "postgresql";
|
|
76
|
+
};
|
|
77
|
+
readonly ScyllaDB: {
|
|
78
|
+
readonly type: "scylladb";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type BackendOption = BackendConfig | BackendType;
|
|
53
82
|
interface AthenaGatewayBaseOptions {
|
|
54
83
|
baseUrl?: string;
|
|
55
|
-
client?: string;
|
|
56
84
|
apiKey?: string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
supabaseKey?: string;
|
|
85
|
+
client?: string;
|
|
86
|
+
backend?: BackendOption;
|
|
60
87
|
publishEvent?: string;
|
|
61
88
|
headers?: Record<string, string>;
|
|
62
|
-
/** optional user context injected as gateway request headers */
|
|
63
89
|
userId?: string | null;
|
|
64
|
-
companyId?: string | null;
|
|
65
90
|
organizationId?: string | null;
|
|
66
91
|
}
|
|
67
92
|
interface AthenaGatewayHookConfig extends AthenaGatewayBaseOptions {
|
|
@@ -70,6 +95,7 @@ interface AthenaGatewayCallOptions extends AthenaGatewayBaseOptions {
|
|
|
70
95
|
count?: AthenaCountOption;
|
|
71
96
|
head?: boolean;
|
|
72
97
|
defaultToNull?: boolean;
|
|
98
|
+
stripNulls?: boolean;
|
|
73
99
|
onConflict?: string | string[];
|
|
74
100
|
updateBody?: Record<string, unknown>;
|
|
75
101
|
}
|
|
@@ -102,4 +128,4 @@ interface AthenaGatewayHookResult {
|
|
|
102
128
|
baseUrl: string;
|
|
103
129
|
}
|
|
104
130
|
|
|
105
|
-
export type
|
|
131
|
+
export { type AthenaConditionValue as A, type BackendConfig as B, type BackendType as a, type AthenaConditionArrayValue as b, type AthenaConditionOperator as c, type AthenaGatewayCallOptions as d, Backend as e, type AthenaGatewayHookConfig as f, type AthenaGatewayHookResult as g, type AthenaDeletePayload as h, type AthenaFetchPayload as i, type AthenaGatewayResponse as j, type AthenaInsertPayload as k, type AthenaUpdatePayload as l };
|
|
@@ -13,6 +13,9 @@ interface AthenaGatewayCondition {
|
|
|
13
13
|
column?: string;
|
|
14
14
|
operator: AthenaConditionOperator;
|
|
15
15
|
value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
16
|
+
/** Back-compat shape expected by older gateway implementations */
|
|
17
|
+
eq_column?: string;
|
|
18
|
+
eq_value?: AthenaConditionValue | AthenaConditionArrayValue | string;
|
|
16
19
|
}
|
|
17
20
|
interface AthenaFetchPayload {
|
|
18
21
|
view_name?: string;
|
|
@@ -50,18 +53,40 @@ interface AthenaDeletePayload {
|
|
|
50
53
|
interface AthenaUpdatePayload extends AthenaFetchPayload {
|
|
51
54
|
update_body?: Record<string, unknown>;
|
|
52
55
|
}
|
|
56
|
+
/** Backend type for Athena client (aligns with athena-rs) */
|
|
57
|
+
type BackendType = 'athena' | 'postgrest' | 'supabase' | 'postgresql' | 'scylladb';
|
|
58
|
+
/** Backend config: type from SDK + backend-scoped options */
|
|
59
|
+
interface BackendConfig {
|
|
60
|
+
type: BackendType;
|
|
61
|
+
options?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
/** Pre-defined backends for lean usage: backend: Backend.Athena */
|
|
64
|
+
declare const Backend: {
|
|
65
|
+
readonly Athena: {
|
|
66
|
+
readonly type: "athena";
|
|
67
|
+
};
|
|
68
|
+
readonly Supabase: {
|
|
69
|
+
readonly type: "supabase";
|
|
70
|
+
};
|
|
71
|
+
readonly Postgrest: {
|
|
72
|
+
readonly type: "postgrest";
|
|
73
|
+
};
|
|
74
|
+
readonly PostgreSQL: {
|
|
75
|
+
readonly type: "postgresql";
|
|
76
|
+
};
|
|
77
|
+
readonly ScyllaDB: {
|
|
78
|
+
readonly type: "scylladb";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type BackendOption = BackendConfig | BackendType;
|
|
53
82
|
interface AthenaGatewayBaseOptions {
|
|
54
83
|
baseUrl?: string;
|
|
55
|
-
client?: string;
|
|
56
84
|
apiKey?: string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
supabaseKey?: string;
|
|
85
|
+
client?: string;
|
|
86
|
+
backend?: BackendOption;
|
|
60
87
|
publishEvent?: string;
|
|
61
88
|
headers?: Record<string, string>;
|
|
62
|
-
/** optional user context injected as gateway request headers */
|
|
63
89
|
userId?: string | null;
|
|
64
|
-
companyId?: string | null;
|
|
65
90
|
organizationId?: string | null;
|
|
66
91
|
}
|
|
67
92
|
interface AthenaGatewayHookConfig extends AthenaGatewayBaseOptions {
|
|
@@ -70,6 +95,7 @@ interface AthenaGatewayCallOptions extends AthenaGatewayBaseOptions {
|
|
|
70
95
|
count?: AthenaCountOption;
|
|
71
96
|
head?: boolean;
|
|
72
97
|
defaultToNull?: boolean;
|
|
98
|
+
stripNulls?: boolean;
|
|
73
99
|
onConflict?: string | string[];
|
|
74
100
|
updateBody?: Record<string, unknown>;
|
|
75
101
|
}
|
|
@@ -102,4 +128,4 @@ interface AthenaGatewayHookResult {
|
|
|
102
128
|
baseUrl: string;
|
|
103
129
|
}
|
|
104
130
|
|
|
105
|
-
export type
|
|
131
|
+
export { type AthenaConditionValue as A, type BackendConfig as B, type BackendType as a, type AthenaConditionArrayValue as b, type AthenaConditionOperator as c, type AthenaGatewayCallOptions as d, Backend as e, type AthenaGatewayHookConfig as f, type AthenaGatewayHookResult as g, type AthenaDeletePayload as h, type AthenaFetchPayload as i, type AthenaGatewayResponse as j, type AthenaInsertPayload as k, type AthenaUpdatePayload as l };
|
package/package.json
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"version": "1.0.2",
|
|
4
|
-
"description": "Athena SDK",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
2
|
+
"author": "floris@xylex.group",
|
|
8
3
|
"bin": {
|
|
9
|
-
"athena-js": "bin/athena-js.js"
|
|
4
|
+
"athena-js": "./bin/athena-js.js"
|
|
5
|
+
},
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@xylex-group/athena": "^0.2.1",
|
|
8
|
+
"blessed": "^0.1.81",
|
|
9
|
+
"chalk": "^4.1.2",
|
|
10
|
+
"cron-parser": "^4.9.0",
|
|
11
|
+
"uuid": "^9.0.1"
|
|
12
|
+
},
|
|
13
|
+
"description": "Athena JS SDK",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/blessed": "^0.1.25",
|
|
16
|
+
"@types/node": "^20.10.5",
|
|
17
|
+
"@types/react": "^18.3.12",
|
|
18
|
+
"@types/uuid": "^9.0.7",
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
20
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
21
|
+
"eslint": "^8.57.1",
|
|
22
|
+
"tsup": "^8.5.1",
|
|
23
|
+
"tsx": "^4.7.0",
|
|
24
|
+
"typescript": "^5.3.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
10
28
|
},
|
|
11
29
|
"exports": {
|
|
12
30
|
".": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
31
|
"import": "./dist/index.mjs",
|
|
15
|
-
"require": "./dist/index.js"
|
|
32
|
+
"require": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
16
34
|
},
|
|
17
35
|
"./react": {
|
|
18
|
-
"types": "./dist/react.d.ts",
|
|
19
36
|
"import": "./dist/react.mjs",
|
|
20
|
-
"require": "./dist/react.js"
|
|
37
|
+
"require": "./dist/react.js",
|
|
38
|
+
"types": "./dist/react.d.ts"
|
|
21
39
|
}
|
|
22
40
|
},
|
|
23
41
|
"files": [
|
|
@@ -26,23 +44,6 @@
|
|
|
26
44
|
"README.md",
|
|
27
45
|
"LICENSE"
|
|
28
46
|
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsup",
|
|
31
|
-
"dev": "tsup --watch",
|
|
32
|
-
"test": "node --test test/*.test.ts",
|
|
33
|
-
"test:watch": "node --test --watch test/*.test.ts",
|
|
34
|
-
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
35
|
-
"lint:fix": "npm run lint -- --fix",
|
|
36
|
-
"prepublishOnly": "npm run build",
|
|
37
|
-
"publish:token": "node scripts/publish.js",
|
|
38
|
-
"example:express-api": "cd examples/express-api && bun run start",
|
|
39
|
-
"example:order-saga": "cd examples/order-saga && bun run start",
|
|
40
|
-
"example:recurring-invoice": "cd examples/recurring-invoice && bun run start",
|
|
41
|
-
"example:retry-patterns": "cd examples/retry-patterns && bun run start",
|
|
42
|
-
"example:email-resend": "cd examples/email-resend && bun run start",
|
|
43
|
-
"example:api-call": "cd examples/api-call && bun run start",
|
|
44
|
-
"example:postgres-connection": "cd examples/postgres-connection && bun run start"
|
|
45
|
-
},
|
|
46
47
|
"keywords": [
|
|
47
48
|
"database",
|
|
48
49
|
"driver",
|
|
@@ -54,20 +55,10 @@
|
|
|
54
55
|
"postgres",
|
|
55
56
|
"query-builder"
|
|
56
57
|
],
|
|
57
|
-
"author": "floris@xylex.group",
|
|
58
|
-
"publisher": "XYLEX Group",
|
|
59
58
|
"license": "MIT",
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"@xylex-group/athena": "^0.2.1",
|
|
66
|
-
"blessed": "^0.1.81",
|
|
67
|
-
"chalk": "^4.1.2",
|
|
68
|
-
"cron-parser": "^4.9.0",
|
|
69
|
-
"uuid": "^9.0.1"
|
|
70
|
-
},
|
|
59
|
+
"main": "./dist/index.js",
|
|
60
|
+
"module": "./dist/index.mjs",
|
|
61
|
+
"name": "@xylex-group/athena",
|
|
71
62
|
"peerDependencies": {
|
|
72
63
|
"react": ">=17.0.0"
|
|
73
64
|
},
|
|
@@ -76,19 +67,29 @@
|
|
|
76
67
|
"optional": true
|
|
77
68
|
}
|
|
78
69
|
},
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"@types/uuid": "^9.0.7",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
85
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
86
|
-
"eslint": "^8.57.1",
|
|
87
|
-
"tsup": "^8.5.1",
|
|
88
|
-
"tsx": "^4.7.0",
|
|
89
|
-
"typescript": "^5.3.3"
|
|
70
|
+
"publisher": "XYLEX Group",
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "git+https://github.com/xylex-group/athena-js.git"
|
|
90
74
|
},
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "tsup",
|
|
77
|
+
"dev": "tsup --watch",
|
|
78
|
+
"example:api-call": "cd examples/api-call && bun run start",
|
|
79
|
+
"example:email-resend": "cd examples/email-resend && bun run start",
|
|
80
|
+
"example:express-api": "cd examples/express-api && bun run start",
|
|
81
|
+
"example:order-saga": "cd examples/order-saga && bun run start",
|
|
82
|
+
"example:postgres-connection": "cd examples/postgres-connection && bun run start",
|
|
83
|
+
"example:recurring-invoice": "cd examples/recurring-invoice && bun run start",
|
|
84
|
+
"example:retry-patterns": "cd examples/retry-patterns && bun run start",
|
|
85
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
86
|
+
"lint:fix": "npm run lint -- --fix",
|
|
87
|
+
"prepublishOnly": "npm run build",
|
|
88
|
+
"publish:token": "node scripts/publish.js",
|
|
89
|
+
"test": "node --test test/*.test.ts",
|
|
90
|
+
"test:watch": "node --test --watch test/*.test.ts"
|
|
91
|
+
},
|
|
92
|
+
"type": "module",
|
|
93
|
+
"types": "./dist/index.d.ts",
|
|
94
|
+
"version": "1.1.0"
|
|
95
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { A as AthenaGatewayCallOptions, a as AthenaConditionValue, b as AthenaConditionArrayValue, c as AthenaConditionOperator } from './types-DzCf3v76.mjs';
|
|
2
|
-
export { d as AthenaDeletePayload, e as AthenaFetchPayload, f as AthenaGatewayBaseOptions, g as AthenaGatewayCallLog, h as AthenaGatewayCondition, i as AthenaGatewayEndpointPath, j as AthenaGatewayHookConfig, k as AthenaGatewayHookResult, l as AthenaGatewayMethod, m as AthenaGatewayResponse, n as AthenaGatewayResponseLog, o as AthenaInsertPayload, p as AthenaUpdatePayload } from './types-DzCf3v76.mjs';
|
|
3
|
-
|
|
4
|
-
interface SupabaseResult<T> {
|
|
5
|
-
data: T | null;
|
|
6
|
-
error: string | null;
|
|
7
|
-
status: number;
|
|
8
|
-
raw: unknown;
|
|
9
|
-
}
|
|
10
|
-
type MutationSingleResult<Result> = Result extends Array<infer Item> ? Item | null : Result | null;
|
|
11
|
-
interface MutationQuery<Result> extends PromiseLike<SupabaseResult<Result>> {
|
|
12
|
-
select(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<Result>>;
|
|
13
|
-
returning(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<Result>>;
|
|
14
|
-
single(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<MutationSingleResult<Result>>>;
|
|
15
|
-
maybeSingle(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<MutationSingleResult<Result>>>;
|
|
16
|
-
then<TResult1 = SupabaseResult<Result>, TResult2 = never>(onfulfilled?: ((value: SupabaseResult<Result>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
17
|
-
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<SupabaseResult<Result> | TResult>;
|
|
18
|
-
finally(onfinally?: (() => void) | undefined | null): Promise<SupabaseResult<Result>>;
|
|
19
|
-
}
|
|
20
|
-
interface TableQueryBuilder<Row> {
|
|
21
|
-
select<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T>>;
|
|
22
|
-
insert(values: Row | Row[], options?: AthenaGatewayCallOptions): MutationQuery<Row | Row[]>;
|
|
23
|
-
upsert(values: Row | Row[], options?: AthenaGatewayCallOptions & {
|
|
24
|
-
updateBody?: Partial<Row>;
|
|
25
|
-
onConflict?: string | string[];
|
|
26
|
-
}): MutationQuery<Row | Row[]>;
|
|
27
|
-
update(values: Partial<Row>, options?: AthenaGatewayCallOptions): MutationQuery<Row[]>;
|
|
28
|
-
delete(options?: AthenaGatewayCallOptions & {
|
|
29
|
-
resourceId?: string;
|
|
30
|
-
}): MutationQuery<Row | null>;
|
|
31
|
-
eq(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
32
|
-
match(filters: Record<string, AthenaConditionValue>): TableQueryBuilder<Row>;
|
|
33
|
-
range(from: number, to: number): TableQueryBuilder<Row>;
|
|
34
|
-
limit(count: number): TableQueryBuilder<Row>;
|
|
35
|
-
offset(count: number): TableQueryBuilder<Row>;
|
|
36
|
-
gt(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
37
|
-
gte(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
38
|
-
lt(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
39
|
-
lte(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
40
|
-
neq(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
41
|
-
like(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
42
|
-
ilike(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
43
|
-
is(column: string, value: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
44
|
-
in(column: string, values: AthenaConditionArrayValue): TableQueryBuilder<Row>;
|
|
45
|
-
contains(column: string, values: AthenaConditionArrayValue): TableQueryBuilder<Row>;
|
|
46
|
-
containedBy(column: string, values: AthenaConditionArrayValue): TableQueryBuilder<Row>;
|
|
47
|
-
not(columnOrExpression: string, operator?: AthenaConditionOperator, value?: AthenaConditionValue): TableQueryBuilder<Row>;
|
|
48
|
-
or(expression: string): TableQueryBuilder<Row>;
|
|
49
|
-
single<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
|
|
50
|
-
maybeSingle<T = Row>(columns?: string | string[], options?: AthenaGatewayCallOptions): Promise<SupabaseResult<T | null>>;
|
|
51
|
-
reset(): TableQueryBuilder<Row>;
|
|
52
|
-
}
|
|
53
|
-
interface SupabaseClient {
|
|
54
|
-
from<Row = unknown>(table: string): TableQueryBuilder<Row>;
|
|
55
|
-
}
|
|
56
|
-
declare function createClient(url: string, apiKey: string, options?: AthenaGatewayCallOptions): SupabaseClient;
|
|
57
|
-
|
|
58
|
-
export { AthenaGatewayCallOptions, type SupabaseClient, type SupabaseResult, type TableQueryBuilder, createClient };
|