@sfutureapps/gateway-sdk 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.
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +28 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,qBAAa,sBAAsB;IACd,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAElC,IAAI,CAAC,OAAO,EAAE,MAAM;CA0BrB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class FastAdminGatewayClient {
|
|
2
|
+
constructor(baseUrl) {
|
|
3
|
+
this.baseUrl = baseUrl;
|
|
4
|
+
}
|
|
5
|
+
call(service) {
|
|
6
|
+
return new Proxy({}, {
|
|
7
|
+
get: (_target, fn) => {
|
|
8
|
+
if (typeof fn !== 'string')
|
|
9
|
+
return undefined;
|
|
10
|
+
return async (payload) => {
|
|
11
|
+
const form = new FormData();
|
|
12
|
+
form.append('class', service);
|
|
13
|
+
form.append('function', fn);
|
|
14
|
+
form.append('payload', JSON.stringify(payload ?? {}));
|
|
15
|
+
const response = await fetch(`${this.baseUrl}/api/gateway`, {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: form
|
|
18
|
+
});
|
|
19
|
+
const json = (await response.json());
|
|
20
|
+
if (json.code !== 1)
|
|
21
|
+
throw new Error(json.msg);
|
|
22
|
+
return json.data;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,sBAAsB;IACjC,YAAmB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEtC,IAAI,CAAC,OAAe;QAClB,OAAO,IAAI,KAAK,CACd,EAAE,EACF;YACE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAmB,EAAE,EAAE;gBACpC,IAAI,OAAO,EAAE,KAAK,QAAQ;oBAAE,OAAO,SAAS,CAAC;gBAE7C,OAAO,KAAK,EAAE,OAAiB,EAAoB,EAAE;oBACnD,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAC9B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;oBAC5B,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;oBAEtD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,cAAc,EAAE;wBAC1D,MAAM,EAAE,MAAM;wBACd,IAAI,EAAE,IAAI;qBACX,CAAC,CAAC;oBAEH,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA6B,CAAC;oBACjE,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;wBAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAC/C,OAAO,IAAI,CAAC,IAAI,CAAC;gBACnB,CAAC,CAAC;YACJ,CAAC;SACF,CACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sfutureapps/gateway-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"default": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./generated/api": {
|
|
13
|
+
"default": "./generated/api.js",
|
|
14
|
+
"types": "./generated/api.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"generated"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"sync:types": "node scripts/sync-types.mjs",
|
|
24
|
+
"sync": "cross-env GATEWAY_TYPES_URL=https://api.yourdomain.com/types/api.d.ts npm run sync:types",
|
|
25
|
+
"clean": "rimraf dist",
|
|
26
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
27
|
+
"prepack": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"cross-env": "^7.0.3",
|
|
31
|
+
"rimraf": "^6.0.1",
|
|
32
|
+
"typescript": "^5.6.3"
|
|
33
|
+
}
|
|
34
|
+
}
|