@sudobility/shaperouter_client 0.0.1
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 +51 -0
- package/dist/hooks/index.d.ts +11 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +11 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAiExecute.d.ts +13 -0
- package/dist/hooks/useAiExecute.d.ts.map +1 -0
- package/dist/hooks/useAiExecute.js +66 -0
- package/dist/hooks/useAiExecute.js.map +1 -0
- package/dist/hooks/useAnalytics.d.ts +16 -0
- package/dist/hooks/useAnalytics.d.ts.map +1 -0
- package/dist/hooks/useAnalytics.js +42 -0
- package/dist/hooks/useAnalytics.js.map +1 -0
- package/dist/hooks/useEndpoints.d.ts +20 -0
- package/dist/hooks/useEndpoints.d.ts.map +1 -0
- package/dist/hooks/useEndpoints.js +133 -0
- package/dist/hooks/useEndpoints.js.map +1 -0
- package/dist/hooks/useEntities.d.ts +32 -0
- package/dist/hooks/useEntities.d.ts.map +1 -0
- package/dist/hooks/useEntities.js +330 -0
- package/dist/hooks/useEntities.js.map +1 -0
- package/dist/hooks/useKeys.d.ts +19 -0
- package/dist/hooks/useKeys.d.ts.map +1 -0
- package/dist/hooks/useKeys.js +129 -0
- package/dist/hooks/useKeys.js.map +1 -0
- package/dist/hooks/useProjects.d.ts +22 -0
- package/dist/hooks/useProjects.d.ts.map +1 -0
- package/dist/hooks/useProjects.js +166 -0
- package/dist/hooks/useProjects.js.map +1 -0
- package/dist/hooks/useProviders.d.ts +18 -0
- package/dist/hooks/useProviders.d.ts.map +1 -0
- package/dist/hooks/useProviders.js +60 -0
- package/dist/hooks/useProviders.js.map +1 -0
- package/dist/hooks/useSettings.d.ts +16 -0
- package/dist/hooks/useSettings.d.ts.map +1 -0
- package/dist/hooks/useSettings.js +72 -0
- package/dist/hooks/useSettings.js.map +1 -0
- package/dist/hooks/useStorageConfig.d.ts +19 -0
- package/dist/hooks/useStorageConfig.d.ts.map +1 -0
- package/dist/hooks/useStorageConfig.js +131 -0
- package/dist/hooks/useStorageConfig.js.map +1 -0
- package/dist/hooks/useUserApiKeys.d.ts +18 -0
- package/dist/hooks/useUserApiKeys.d.ts.map +1 -0
- package/dist/hooks/useUserApiKeys.js +107 -0
- package/dist/hooks/useUserApiKeys.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/network/ShapeRouterClient.d.ts +72 -0
- package/dist/network/ShapeRouterClient.d.ts.map +1 -0
- package/dist/network/ShapeRouterClient.js +461 -0
- package/dist/network/ShapeRouterClient.js.map +1 -0
- package/dist/network/index.d.ts +3 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +2 -0
- package/dist/network/index.js.map +1 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/shaperouter-helpers.d.ts +18 -0
- package/dist/utils/shaperouter-helpers.d.ts.map +1 -0
- package/dist/utils/shaperouter-helpers.js +53 -0
- package/dist/utils/shaperouter-helpers.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FirebaseIdToken } from '../types';
|
|
2
|
+
export declare class ShapeRouterApiError extends Error {
|
|
3
|
+
readonly statusCode: number | undefined;
|
|
4
|
+
readonly errorCode: string | undefined;
|
|
5
|
+
readonly details: string | undefined;
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
statusCode?: number;
|
|
8
|
+
errorCode?: string;
|
|
9
|
+
details?: string;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export declare function createAuthHeaders(token: FirebaseIdToken): Record<string, string>;
|
|
13
|
+
export declare function createHeaders(): Record<string, string>;
|
|
14
|
+
export declare function createApiKeyHeaders(apiKey: string): Record<string, string>;
|
|
15
|
+
export declare function buildUrl(baseUrl: string, path: string): string;
|
|
16
|
+
export declare function handleApiError(response: unknown, operation: string): ShapeRouterApiError;
|
|
17
|
+
export declare function buildQueryString(params: object): string;
|
|
18
|
+
//# sourceMappingURL=shaperouter-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaperouter-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/shaperouter-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAwBhD,qBAAa,mBAAoB,SAAQ,KAAK;IAE5C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAExC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAEvC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAGnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CAQJ;AAKD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAKD,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKtD;AAKD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM1E;AAKD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI9D;AAYD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,GAChB,mBAAmB,CAiBrB;AAKD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWvD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export class ShapeRouterApiError extends Error {
|
|
2
|
+
constructor(message, options) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'ShapeRouterApiError';
|
|
5
|
+
this.statusCode = options?.statusCode;
|
|
6
|
+
this.errorCode = options?.errorCode;
|
|
7
|
+
this.details = options?.details;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function createAuthHeaders(token) {
|
|
11
|
+
return {
|
|
12
|
+
'Content-Type': 'application/json',
|
|
13
|
+
Accept: 'application/json',
|
|
14
|
+
Authorization: `Bearer ${token}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createHeaders() {
|
|
18
|
+
return {
|
|
19
|
+
'Content-Type': 'application/json',
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function createApiKeyHeaders(apiKey) {
|
|
24
|
+
return {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
Accept: 'application/json',
|
|
27
|
+
Authorization: `Bearer ${apiKey}`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function buildUrl(baseUrl, path) {
|
|
31
|
+
const cleanBase = baseUrl.replace(/\/$/, '');
|
|
32
|
+
return `${cleanBase}${path}`;
|
|
33
|
+
}
|
|
34
|
+
export function handleApiError(response, operation) {
|
|
35
|
+
const resp = response;
|
|
36
|
+
const errorMessage = resp?.data?.error || resp?.data?.message || 'Unknown error';
|
|
37
|
+
return new ShapeRouterApiError(`Failed to ${operation}: ${errorMessage}`, {
|
|
38
|
+
statusCode: resp?.status,
|
|
39
|
+
errorCode: resp?.data?.code,
|
|
40
|
+
details: resp?.data?.details,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function buildQueryString(params) {
|
|
44
|
+
const queryParams = new URLSearchParams();
|
|
45
|
+
for (const [key, value] of Object.entries(params)) {
|
|
46
|
+
if (value !== undefined && value !== null) {
|
|
47
|
+
queryParams.append(key, String(value));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const queryString = queryParams.toString();
|
|
51
|
+
return queryString ? `?${queryString}` : '';
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=shaperouter-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaperouter-helpers.js","sourceRoot":"","sources":["../../src/utils/shaperouter-helpers.ts"],"names":[],"mappings":"AAwBA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAQ5C,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;IAClC,CAAC;CACF;AAKD,MAAM,UAAU,iBAAiB,CAC/B,KAAsB;IAEtB,OAAO;QACL,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,kBAAkB;QAC1B,aAAa,EAAE,UAAU,KAAK,EAAE;KACjC,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,kBAAkB;KAC3B,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,OAAO;QACL,cAAc,EAAE,kBAAkB;QAClC,MAAM,EAAE,kBAAkB;QAC1B,aAAa,EAAE,UAAU,MAAM,EAAE;KAClC,CAAC;AACJ,CAAC;AAKD,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAY;IAEpD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,GAAG,SAAS,GAAG,IAAI,EAAE,CAAC;AAC/B,CAAC;AAYD,MAAM,UAAU,cAAc,CAC5B,QAAiB,EACjB,SAAiB;IAEjB,MAAM,IAAI,GAAG,QAQZ,CAAC;IACF,MAAM,YAAY,GAChB,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,IAAI,EAAE,OAAO,IAAI,eAAe,CAAC;IAC9D,OAAO,IAAI,mBAAmB,CAAC,aAAa,SAAS,KAAK,YAAY,EAAE,EAAE;QACxE,UAAU,EAAE,IAAI,EAAE,MAAM;QACxB,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;QAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO;KAC7B,CAAC,CAAC;AACL,CAAC;AAKD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;IAE1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1C,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sudobility/shaperouter_client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React client library for ShapeRouter API with TanStack Query hooks",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "restricted"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bunx tsc -p tsconfig.build.json",
|
|
16
|
+
"build:watch": "bunx tsc --watch",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"prepublishOnly": "bun run clean && bun run build",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"lint": "bunx eslint src --ext .ts,.tsx",
|
|
22
|
+
"lint:fix": "bunx eslint src --ext .ts,.tsx --fix",
|
|
23
|
+
"format": "bunx prettier --write src/**/*.ts",
|
|
24
|
+
"format:check": "bunx prettier --check src/**/*.ts",
|
|
25
|
+
"typecheck": "bunx tsc --noEmit",
|
|
26
|
+
"verify": "bun run typecheck && bun run lint && bun run test && bun run build"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"shaperouter",
|
|
30
|
+
"llm",
|
|
31
|
+
"api-client",
|
|
32
|
+
"react",
|
|
33
|
+
"tanstack-query",
|
|
34
|
+
"typescript"
|
|
35
|
+
],
|
|
36
|
+
"author": "John Huang",
|
|
37
|
+
"license": "BUSL-1.1",
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@sudobility/shaperouter_types": "^0.0.1",
|
|
40
|
+
"@sudobility/types": "^1.9.67",
|
|
41
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
42
|
+
"react": ">=18.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@eslint/js": "^9.39.2",
|
|
46
|
+
"@sudobility/di": "^1.5.63",
|
|
47
|
+
"@sudobility/shaperouter_types": "^0.0.1",
|
|
48
|
+
"@sudobility/types": "^1.9.67",
|
|
49
|
+
"@tanstack/react-query": "^5.90.5",
|
|
50
|
+
"@testing-library/dom": "^10.4.1",
|
|
51
|
+
"@testing-library/react": "^16.3.1",
|
|
52
|
+
"@types/node": "^24.9.1",
|
|
53
|
+
"@types/react": "^19.2.2",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
55
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
56
|
+
"eslint": "^9.38.0",
|
|
57
|
+
"eslint-config-prettier": "^10.1.8",
|
|
58
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
59
|
+
"jsdom": "^27.3.0",
|
|
60
|
+
"prettier": "^3.6.2",
|
|
61
|
+
"react": "^19.2.1",
|
|
62
|
+
"react-dom": "^19.2.1",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"vitest": "^4.0.4"
|
|
65
|
+
},
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/johnqh/shaperouter_client.git"
|
|
69
|
+
}
|
|
70
|
+
}
|