Skip to content

Commit

Permalink
fix(node/browser): export models outside package (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps authored Sep 21, 2024
1 parent 76fd9ba commit c3f0806
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 83 deletions.
4 changes: 2 additions & 2 deletions flipt-client-browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flipt-client-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flipt-io/flipt-client-browser",
"version": "0.2.0",
"version": "0.2.1",
"description": "Flipt Client Evaluation Browser SDK",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
Expand Down
17 changes: 11 additions & 6 deletions flipt-client-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import wasm from '../dist/flipt_engine_wasm_bg.wasm';
import { deserialize, serialize } from './utils';
import {
BatchEvaluationResponse,
BatchResult,
BooleanEvaluationResponse,
BooleanResult,
ClientOptions,
ErrorEvaluationResponse,
EvaluationRequest,
EvaluationResponse,
Flag,
IFetcher,
ListFlagsResult,
VariantEvaluationResponse,
VariantResult
} from './models.js';
VariantEvaluationResponse
} from './models';

import {
VariantResult,
BooleanResult,
BatchResult,
ListFlagsResult
} from './internal/models';

export class FliptEvaluationClient {
private engine: Engine;
Expand Down Expand Up @@ -292,3 +295,5 @@ export class FliptEvaluationClient {
return flags.result.map(deserialize<Flag>);
}
}

export * from './models';
39 changes: 39 additions & 0 deletions flipt-client-browser/src/internal/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
BatchEvaluationResponse,
BooleanEvaluationResponse,
Flag,
VariantEvaluationResponse
} from '../models';

/**
* Represents a specialized result object for variant evaluation, extending
* the generic Result interface with a specific type VariantEvaluationResponse.
*/
export interface VariantResult extends Result<VariantEvaluationResponse> {}

/**
* Represents a specialized result object for boolean evaluation, extending
* the generic Result interface with a specific type BooleanEvaluationResponse.
*/
export interface BooleanResult extends Result<BooleanEvaluationResponse> {}

/**
* Represents a specialized result object for batch evaluation, extending
* the generic Result interface with a specific type BatchEvaluationResponse.
*/
export interface BatchResult extends Result<BatchEvaluationResponse> {}

/**
* Represents a specialized result object for listing flags, extending
* the generic Result interface with a specific type ListFlagsResponse.
*/
export interface ListFlagsResult extends Result<Flag[]> {}

export interface Result<T> {
/** Status of the result - `success` or `failure`. */
status: string;
/** Actual result of type T if the operation was successful. */
result?: T;
/** Error message describing the reason for failure, if applicable.*/
errorMessage: string;
}
33 changes: 0 additions & 33 deletions flipt-client-browser/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,36 +191,3 @@ export interface BatchEvaluationResponse {
/** Duration of the request in milliseconds. */
requestDurationMillis: number;
}

/**
* Represents a specialized result object for variant evaluation, extending
* the generic Result interface with a specific type VariantEvaluationResponse.
*/
export interface VariantResult extends Result<VariantEvaluationResponse> {}

/**
* Represents a specialized result object for boolean evaluation, extending
* the generic Result interface with a specific type BooleanEvaluationResponse.
*/
export interface BooleanResult extends Result<BooleanEvaluationResponse> {}

/**
* Represents a specialized result object for batch evaluation, extending
* the generic Result interface with a specific type BatchEvaluationResponse.
*/
export interface BatchResult extends Result<BatchEvaluationResponse> {}

/**
* Represents a specialized result object for listing flags, extending
* the generic Result interface with a specific type ListFlagsResponse.
*/
export interface ListFlagsResult extends Result<Flag[]> {}

export interface Result<T> {
/** Status of the result - `success` or `failure`. */
status: string;
/** Actual result of type T if the operation was successful. */
result?: T;
/** Error message describing the reason for failure, if applicable.*/
errorMessage: string;
}
4 changes: 2 additions & 2 deletions flipt-client-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flipt-client-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flipt-io/flipt-client",
"version": "0.10.0",
"version": "0.10.1",
"description": "Flipt Client Evaluation SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
15 changes: 10 additions & 5 deletions flipt-client-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ import { serialize, deserialize } from './utils';

import {
AuthenticationStrategy,
BooleanResult,
BatchResult,
ClientOptions,
EvaluationRequest,
IFetcher,
VariantResult,
VariantEvaluationResponse,
BooleanEvaluationResponse,
BatchEvaluationResponse,
ErrorEvaluationResponse,
EvaluationResponse,
Flag,
ListFlagsResult
Flag
} from './models';

import {
VariantResult,
BooleanResult,
BatchResult,
ListFlagsResult
} from './internal/models';

export class FliptEvaluationClient {
private engine: Engine;
private fetcher: IFetcher;
Expand Down Expand Up @@ -316,3 +319,5 @@ export class FliptEvaluationClient {
this.stopAutoRefresh();
}
}

export * from './models';
38 changes: 38 additions & 0 deletions flipt-client-node/src/internal/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
Flag,
VariantEvaluationResponse,
BooleanEvaluationResponse,
BatchEvaluationResponse
} from '../models';
/**
* Represents a specialized result object for variant evaluation, extending
* the generic Result interface with a specific type VariantEvaluationResponse.
*/
export interface VariantResult extends Result<VariantEvaluationResponse> {}

/**
* Represents a specialized result object for boolean evaluation, extending
* the generic Result interface with a specific type BooleanEvaluationResponse.
*/
export interface BooleanResult extends Result<BooleanEvaluationResponse> {}

/**
* Represents a specialized result object for batch evaluation, extending
* the generic Result interface with a specific type BatchEvaluationResponse.
*/
export interface BatchResult extends Result<BatchEvaluationResponse> {}

/**
* Represents a specialized result object for listing flags, extending
* the generic Result interface with a specific type ListFlagsResponse.
*/
export interface ListFlagsResult extends Result<Flag[]> {}

export interface Result<T> {
/** Status of the result - `success` or `failure`. */
status: string;
/** Actual result of type T if the operation was successful. */
result?: T;
/** Error message describing the reason for failure, if applicable.*/
errorMessage: string;
}
33 changes: 0 additions & 33 deletions flipt-client-node/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,36 +191,3 @@ export interface BatchEvaluationResponse {
/** Duration of the request in milliseconds. */
requestDurationMillis: number;
}

/**
* Represents a specialized result object for variant evaluation, extending
* the generic Result interface with a specific type VariantEvaluationResponse.
*/
export interface VariantResult extends Result<VariantEvaluationResponse> {}

/**
* Represents a specialized result object for boolean evaluation, extending
* the generic Result interface with a specific type BooleanEvaluationResponse.
*/
export interface BooleanResult extends Result<BooleanEvaluationResponse> {}

/**
* Represents a specialized result object for batch evaluation, extending
* the generic Result interface with a specific type BatchEvaluationResponse.
*/
export interface BatchResult extends Result<BatchEvaluationResponse> {}

/**
* Represents a specialized result object for listing flags, extending
* the generic Result interface with a specific type ListFlagsResponse.
*/
export interface ListFlagsResult extends Result<Flag[]> {}

export interface Result<T> {
/** Status of the result - `success` or `failure`. */
status: string;
/** Actual result of type T if the operation was successful. */
result?: T;
/** Error message describing the reason for failure, if applicable.*/
errorMessage: string;
}

0 comments on commit c3f0806

Please sign in to comment.