@ctil/gql 1.0.5 → 1.0.7
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/dist/index.cjs +15 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
- package/.vscode/launch.json +0 -18
- package/ctil-gql-1.0.5.tgz +0 -0
- package/src/builders/auth.ts +0 -182
- package/src/builders/baseType.ts +0 -194
- package/src/builders/index.ts +0 -6
- package/src/builders/mutation.ts +0 -341
- package/src/builders/oss.ts +0 -140
- package/src/builders/query.ts +0 -180
- package/src/builders/sms.ts +0 -59
- package/src/cache/memoryCache.ts +0 -34
- package/src/core/api/auth.ts +0 -86
- package/src/core/api/gql.ts +0 -22
- package/src/core/api/mutation.ts +0 -100
- package/src/core/api/oss.ts +0 -216
- package/src/core/api/query.ts +0 -82
- package/src/core/api/sms.ts +0 -18
- package/src/core/client.ts +0 -47
- package/src/core/core.ts +0 -284
- package/src/core/executor.ts +0 -19
- package/src/core/type.ts +0 -76
- package/src/device/index.ts +0 -116
- package/src/index.ts +0 -60
- package/src/rateLimit/rateLimit.ts +0 -51
- package/src/rateLimit/rateLimitConfig.ts +0 -12
- package/src/test.ts +0 -109
- package/tsconfig.json +0 -17
- package/tsup.config.ts +0 -10
package/src/test.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { initGraphQLClient,auth,query,setToken,removeToken,useInterceptor,oss } from "./index.ts"; // 本地调试用相对路径
|
|
2
|
-
|
|
3
|
-
// import fs from 'fs';
|
|
4
|
-
// import { Blob } from 'buffer'; // Node 18+ 或 polyfill
|
|
5
|
-
|
|
6
|
-
// const buffer = fs.readFileSync('E:/Node-Package-Manage/cc-request/src/deepseek.png');
|
|
7
|
-
// const file = new Blob([buffer], { type: 'image/png' });
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const client = initGraphQLClient({
|
|
11
|
-
endpoint: "http://localhost:9526/graphql",
|
|
12
|
-
// Authorization:"eyJhbGciOiJIUzI1NiJ9.eyJ1c2VySWQiOjEwMDAwMDAwMDAsImxvZ2luQWNjb3VudCI6ImNhaWNhaSIsInR5cGUiOiJhY2Nlc3MiLCJkZXZpY2VJZCI6IjEwMDAwMDgiLCJqdGkiOiJjMTJjNjQ5ZS05OTIwLTRkNDgtOWRjZS0yYWJkZGMzYTc1OWIiLCJpYXQiOjE3NjE3MzIxMzEsImV4cCI6MTc2MTczMzkzMX0.CkJf3fYdto7zugkkej8sfLCw03Yrgc1zMAoPL2PaFUk"
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// ✅ 注册请求 / 响应 / 错误拦截器
|
|
17
|
-
useInterceptor({
|
|
18
|
-
onRequest: async ({ query, variables, headers }) => {
|
|
19
|
-
// console.log("[Request Interceptor]", { query, variables, headers });
|
|
20
|
-
// 可以在这里加上时间戳或日志
|
|
21
|
-
return { query, variables, headers };
|
|
22
|
-
},
|
|
23
|
-
onResponse: async (response) => {
|
|
24
|
-
// console.log("[Response Interceptor]", response);
|
|
25
|
-
// 可以在这里统一处理响应结构,比如包装 data
|
|
26
|
-
return response;
|
|
27
|
-
},
|
|
28
|
-
onError: async (error) => {
|
|
29
|
-
// console.error("[Error Interceptor]", error);
|
|
30
|
-
// 比如 token 过期时可以自动重试或刷新
|
|
31
|
-
if (error.status === 401) {
|
|
32
|
-
console.log("⚠️ Token expired, redirecting to login...");
|
|
33
|
-
}
|
|
34
|
-
// 返回错误或重新抛出
|
|
35
|
-
throw error;
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
async function test() {
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
// const loginRs=await auth.login({
|
|
43
|
-
// account:"caicai",
|
|
44
|
-
// password:"caicai"
|
|
45
|
-
// })
|
|
46
|
-
// console.log(loginRs.login.token);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// const fileWithName = Object.assign(file, { name: 'deepseek.png' });
|
|
50
|
-
// const rs= await oss.uploadFile({
|
|
51
|
-
// file: fileWithName as File,
|
|
52
|
-
// folder:"temp"
|
|
53
|
-
// })
|
|
54
|
-
// debugger;
|
|
55
|
-
// console.log(rs);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// const rs= await oss.uploadFromUrl({
|
|
61
|
-
// url: "http://fitting-report.oss-cn-shanghai.aliyuncs.com/images/20251101/yTsY9Xsj008caQixk7mbPg%3D%3D.png?Expires=1762565181&OSSAccessKeyId=LTAI5tHFpB7GqZCuwBzikFWf&Signature=7AUh645XYhf4FwpExC%2F9xjr4hIk%3D",
|
|
62
|
-
// folder:"test"
|
|
63
|
-
// })
|
|
64
|
-
// debugger;
|
|
65
|
-
// console.log(rs);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// const rs= await oss.getFilePreview("1000000043")
|
|
69
|
-
// console.log(rs);
|
|
70
|
-
|
|
71
|
-
// setToken(loginRs.login.token);
|
|
72
|
-
// debugger;
|
|
73
|
-
// console.log(loginRs);
|
|
74
|
-
// const rs=await query.byId({
|
|
75
|
-
// operationName:"user",
|
|
76
|
-
// pk:"1000000000",
|
|
77
|
-
// fields:["id","username","nickname","phone",{
|
|
78
|
-
// roles:{
|
|
79
|
-
// fields:["id","roleCode","roleName"]
|
|
80
|
-
// }
|
|
81
|
-
// }]
|
|
82
|
-
// })
|
|
83
|
-
// debugger;
|
|
84
|
-
// console.log(rs);
|
|
85
|
-
|
|
86
|
-
// removeToken()
|
|
87
|
-
|
|
88
|
-
// const res=await query.byId({
|
|
89
|
-
// operationName:"user",
|
|
90
|
-
// pk:"1000000000",
|
|
91
|
-
// fields:["id","username","nickname","phone",{
|
|
92
|
-
// roles:{
|
|
93
|
-
// fields:["id","roleCode","roleName"]
|
|
94
|
-
// }
|
|
95
|
-
// }]
|
|
96
|
-
// })
|
|
97
|
-
// debugger;
|
|
98
|
-
// console.log(res);
|
|
99
|
-
|
|
100
|
-
} catch (err:any) {
|
|
101
|
-
|
|
102
|
-
debugger;
|
|
103
|
-
console.error("GraphQL request failed:", err);
|
|
104
|
-
console.error("GraphQL request failed:", err.message);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
test();
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "nodenext", // ✅ 必须和 moduleResolution 配套
|
|
5
|
-
"moduleResolution": "nodenext", // ✅ 支持 Node ESM
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"allowImportingTsExtensions": true,
|
|
9
|
-
"noEmit":true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"outDir": "dist",
|
|
13
|
-
"strict": true,
|
|
14
|
-
"skipLibCheck": true
|
|
15
|
-
},
|
|
16
|
-
"include": ["src"]
|
|
17
|
-
}
|