@useflagly/sdk-javascript 0.2.0 → 0.2.2
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 +6 -2
- package/dist/index.d.ts +11 -11
- package/dist/index.js +3 -3
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ npm install @useflagly/sdk-javascript
|
|
|
11
11
|
## Uso
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import {
|
|
14
|
+
import { UseFlaglyClient } from '@useflagly/sdk-javascript';
|
|
15
15
|
|
|
16
|
-
const sdk = new
|
|
16
|
+
const sdk = new UseFlaglyClient({ token: 'seu-api-token' });
|
|
17
17
|
// A URL padrão é https://api.useflagly.com.br — pode ser sobrescrita com { baseUrl: '...' }
|
|
18
18
|
|
|
19
19
|
// Validar flag
|
|
@@ -52,3 +52,7 @@ await sdk.getResult('00000000000');
|
|
|
52
52
|
| `getScenarioCache(slug, identifier?)` | Lê o cache de um scenario |
|
|
53
53
|
| `initializeFlags(payload, environment?)` | Inicializa flags (producer) |
|
|
54
54
|
| `getResult(identifier)` | Busca resultado por identifier |
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -13,20 +13,20 @@ export type SDKOptions = {
|
|
|
13
13
|
token?: string;
|
|
14
14
|
timeoutMs?: number;
|
|
15
15
|
};
|
|
16
|
-
export declare class
|
|
16
|
+
export declare class UseFlaglyClient {
|
|
17
17
|
private baseUrl;
|
|
18
18
|
private token?;
|
|
19
19
|
constructor(opts?: SDKOptions);
|
|
20
20
|
private headers;
|
|
21
21
|
private request;
|
|
22
|
-
validateFlag(slug: string, body: ValidateBody, environment?: string): Promise<
|
|
23
|
-
getFlagCache(slug: string, identifier?: string): Promise<
|
|
24
|
-
validateFlow(slug: string, body: ValidateBody, environment?: string): Promise<
|
|
25
|
-
getFlowCache(slug: string, identifier?: string): Promise<
|
|
26
|
-
validateFlowPart(slug: string, body: ValidateBody, environment?: string): Promise<
|
|
27
|
-
getFlowPartCache(slug: string, identifier?: string): Promise<
|
|
28
|
-
validateScenario(slug: string, body: ValidateBody, environment?: string): Promise<
|
|
29
|
-
getScenarioCache(slug: string, identifier?: string): Promise<
|
|
30
|
-
initializeFlags(payload: ReceiveMessage, environment?: string): Promise<
|
|
31
|
-
getResult(cpf: string): Promise<
|
|
22
|
+
validateFlag<T = unknown>(slug: string, body: ValidateBody, environment?: string): Promise<string | T | null>;
|
|
23
|
+
getFlagCache<T = unknown>(slug: string, identifier?: string): Promise<string | T | null>;
|
|
24
|
+
validateFlow<T = unknown>(slug: string, body: ValidateBody, environment?: string): Promise<string | T | null>;
|
|
25
|
+
getFlowCache<T = unknown>(slug: string, identifier?: string): Promise<string | T | null>;
|
|
26
|
+
validateFlowPart<T = unknown>(slug: string, body: ValidateBody, environment?: string): Promise<string | T | null>;
|
|
27
|
+
getFlowPartCache<T = unknown>(slug: string, identifier?: string): Promise<string | T | null>;
|
|
28
|
+
validateScenario<T = unknown>(slug: string, body: ValidateBody, environment?: string): Promise<string | T | null>;
|
|
29
|
+
getScenarioCache<T = unknown>(slug: string, identifier?: string): Promise<string | T | null>;
|
|
30
|
+
initializeFlags<T = unknown>(payload: ReceiveMessage, environment?: string): Promise<string | T | null>;
|
|
31
|
+
getResult<T = unknown>(cpf: string): Promise<string | T | null>;
|
|
32
32
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.UseFlaglyClient = void 0;
|
|
7
7
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
8
|
const DEFAULT_BASE_URL = 'https://api.useflagly.com.br';
|
|
9
|
-
class
|
|
9
|
+
class UseFlaglyClient {
|
|
10
10
|
constructor(opts = {}) {
|
|
11
11
|
var _a;
|
|
12
12
|
this.baseUrl = ((_a = opts.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
@@ -79,4 +79,4 @@ class SystemSDK {
|
|
|
79
79
|
return this.request(`/validate/result/${encodeURIComponent(cpf)}`, 'GET');
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
exports.
|
|
82
|
+
exports.UseFlaglyClient = UseFlaglyClient;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useflagly/sdk-javascript",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "JavaScript SDK para
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "JavaScript SDK para UseFlagly API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
8
10
|
"publishConfig": {
|
|
9
11
|
"registry": "https://registry.npmjs.org",
|
|
10
12
|
"access": "public"
|
|
@@ -21,7 +23,8 @@
|
|
|
21
23
|
"author": "",
|
|
22
24
|
"license": "MIT",
|
|
23
25
|
"dependencies": {
|
|
24
|
-
"cross-fetch": "^3.1.8"
|
|
26
|
+
"cross-fetch": "^3.1.8",
|
|
27
|
+
"express-basic-auth": "^1.2.1"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
30
|
"typescript": "^5.9.3"
|