lago-javascript-client 0.19.4-alpha
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/LICENSE +21 -0
- package/README.md +115 -0
- package/esm/mod.js +33 -0
- package/esm/package.json +3 -0
- package/esm/swagger/client.js +1090 -0
- package/package.json +49 -0
- package/script/mod.js +52 -0
- package/script/package.json +3 -0
- package/script/swagger/client.js +1095 -0
- package/types/mod.d.ts +5 -0
- package/types/swagger/client.d.ts +1802 -0
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"module": "./esm/mod.js",
|
|
3
|
+
"main": "./script/mod.js",
|
|
4
|
+
"types": "./types/mod.d.ts",
|
|
5
|
+
"name": "lago-javascript-client",
|
|
6
|
+
"version": "v0.19.4-alpha",
|
|
7
|
+
"description": "Lago JavaScript API Client",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/getlago/lago-javascript-client.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"Lago",
|
|
14
|
+
"Node",
|
|
15
|
+
"API",
|
|
16
|
+
"Client"
|
|
17
|
+
],
|
|
18
|
+
"contributors": [
|
|
19
|
+
"Lovro Colic",
|
|
20
|
+
"Jérémy Denquin",
|
|
21
|
+
"Arjun Yelamanchili"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/getlago/lago-javascript-client/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/getlago/lago-javascript-client#readme",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"default": "./esm/mod.js",
|
|
32
|
+
"types": "./types/mod.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"default": "./script/mod.js",
|
|
36
|
+
"types": "./types/mod.d.ts"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "node test_runner.js"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^18.11.9",
|
|
45
|
+
"chalk": "^4.1.2",
|
|
46
|
+
"@deno/shim-deno": "~0.11.0",
|
|
47
|
+
"urlpattern-polyfill": "^6.0.2"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/script/mod.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getLagoError = exports.Client = void 0;
|
|
18
|
+
// deno-lint-ignore-file no-explicit-any
|
|
19
|
+
const client_js_1 = require("./swagger/client.js");
|
|
20
|
+
const Client = (apiKey, apiConfig) => {
|
|
21
|
+
const api = new client_js_1.Api({
|
|
22
|
+
securityWorker: (apiKey) => apiKey ? { headers: { Authorization: `Bearer ${apiKey}` } } : {},
|
|
23
|
+
// Cloudflare Workers doesn't support some options like credentials so need to override default
|
|
24
|
+
baseApiParams: {
|
|
25
|
+
redirect: "follow",
|
|
26
|
+
},
|
|
27
|
+
...apiConfig,
|
|
28
|
+
});
|
|
29
|
+
api.setSecurityData(apiKey);
|
|
30
|
+
return api;
|
|
31
|
+
};
|
|
32
|
+
exports.Client = Client;
|
|
33
|
+
// https://github.com/remix-run/remix/blob/ef26f7671a9619966a6cfa3c39e196d44fbf32cf/packages/remix-server-runtime/responses.ts#L60
|
|
34
|
+
function isResponse(value) {
|
|
35
|
+
return (value != null &&
|
|
36
|
+
typeof value.status === "number" &&
|
|
37
|
+
typeof value.statusText === "string" &&
|
|
38
|
+
typeof value.headers === "object" &&
|
|
39
|
+
typeof value.body !== "undefined");
|
|
40
|
+
}
|
|
41
|
+
async function getLagoError(error) {
|
|
42
|
+
if (isResponse(error)) {
|
|
43
|
+
if (!error.bodyUsed) {
|
|
44
|
+
const errorJson = await error.json();
|
|
45
|
+
return errorJson;
|
|
46
|
+
}
|
|
47
|
+
return error.error;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(error);
|
|
50
|
+
}
|
|
51
|
+
exports.getLagoError = getLagoError;
|
|
52
|
+
__exportStar(require("./swagger/client.js"), exports);
|