Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@indigov/flags-api

Package Overview
Dependencies
Maintainers
14
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@indigov/flags-api - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

5

dist/index.d.ts

@@ -12,2 +12,5 @@ declare type Env = 'prod' | 'staging' | 'local';

declare type GetFlagsResponse = Record<Flag, boolean>;
interface RequestOptions {
cohort?: string;
}
interface ConstructorOps {

@@ -24,3 +27,3 @@ env?: Env;

constructor(token: string, office: string, source: Source, { env, traceId }?: ConstructorOps);
getFlag: (flag: Flag) => Promise<GetFlagResponse>;
getFlag: (flag: Flag, options?: RequestOptions | undefined) => Promise<GetFlagResponse>;
getFlags: (flags: Flag[]) => Promise<GetFlagsResponse>;

@@ -27,0 +30,0 @@ getFlagValue: (flag: string) => Promise<GetFlagValueResponse>;

@@ -12,7 +12,7 @@ import fetch from 'cross-fetch';

this.source = source;
this.getFlag = async (flag) => (await this.request(`flag/${flag}`)).value;
this.getFlag = async (flag, options) => (await this.request(`flag/${flag}`, options)).value;
this.getFlags = async (flags) => this.request(`flags?${flags.map((flag) => `&flags=${flag}`).join('')}`).then((_) => _.value);
this.getFlagValue = async (flag) => this.request(`flag/${flag}/raw`).then((_) => _.value);
this.getAllFlags = async () => this.request('flags/all').then((_) => _.value);
this.request = (path) => fetch(`${this.endpoint}/${path}`, {
this.request = (path, { cohort } = {}) => fetch(`${this.endpoint}/${path}`, {
method: 'GET',

@@ -22,2 +22,3 @@ headers: {

'x-office': this.office,
...(cohort && { 'x-cohort': cohort }),
'x-origin': this.source,

@@ -24,0 +25,0 @@ ...(this.traceId && { 'x-trace-id': this.traceId })

2

package.json
{
"name": "@indigov/flags-api",
"version": "0.0.15",
"version": "0.0.16",
"description": "Strongly typed React/Node client for the Flags service",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -22,2 +22,7 @@ import fetch from 'cross-fetch'

interface RequestOptions {
// Cohort to fetch flags for in addition to office
cohort?: string
}
interface ConstructorOps {

@@ -47,4 +52,5 @@ // Determines endpoint for Flags service. Defaults to prod

* Retrieves a boolean value for {@param flag} for an office or cohort if it follows our standard schema (see Flags repo)
* {@param options} enables support for fetching cohort values as well.
*/
public getFlag = async (flag: Flag): Promise<GetFlagResponse> => (await this.request<GetFlagResponse>(`flag/${flag}`)).value
public getFlag = async (flag: Flag, options?: RequestOptions): Promise<GetFlagResponse> => (await this.request<GetFlagResponse>(`flag/${flag}`, options)).value

@@ -68,3 +74,3 @@ /**

private request = <T>(path: string): Promise<{ value: T }> =>
private request = <T>(path: string, { cohort }: RequestOptions = {}): Promise<{ value: T }> =>
fetch(`${this.endpoint}/${path}`, {

@@ -75,2 +81,3 @@ method: 'GET',

'x-office': this.office,
...(cohort && { 'x-cohort': cohort }),
'x-origin': this.source,

@@ -77,0 +84,0 @@ ...(this.traceId && { 'x-trace-id': this.traceId })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc