Skip to content

Commit

Permalink
v4
Browse files Browse the repository at this point in the history
  • Loading branch information
rolodato committed Oct 8, 2024
1 parent 2b5df9f commit 0df9af2
Show file tree
Hide file tree
Showing 44 changed files with 1,424 additions and 4,475 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@

node_modules/
build/
coverage/

.tool-versions
6 changes: 3 additions & 3 deletions flagsmith-engine/environments/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FeatureStateModel } from '../features/models';
import { IdentityModel } from '../identities/models';
import { ProjectModel } from '../projects/models';
import { FeatureStateModel } from '../features/models.js';
import { IdentityModel } from '../identities/models.js';
import { ProjectModel } from '../projects/models.js';

export class EnvironmentAPIKeyModel {
id: number;
Expand Down
8 changes: 4 additions & 4 deletions flagsmith-engine/environments/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildFeatureStateModel } from '../features/util';
import { buildIdentityModel } from '../identities/util';
import { buildProjectModel } from '../projects/util';
import { EnvironmentAPIKeyModel, EnvironmentModel } from './models';
import { buildFeatureStateModel } from '../features/util.js';
import { buildIdentityModel } from '../identities/util.js';
import { buildProjectModel } from '../projects/util.js';
import { EnvironmentAPIKeyModel, EnvironmentModel } from './models.js';

export function buildEnvironmentModel(environmentJSON: any) {
const project = buildProjectModel(environmentJSON.project);
Expand Down
2 changes: 1 addition & 1 deletion flagsmith-engine/features/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuidv4 } from 'uuid';
import { getHashedPercentateForObjIds } from '../utils/hashing';
import { getHashedPercentateForObjIds } from '../utils/hashing/index.js';

export class FeatureModel {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion flagsmith-engine/features/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FeatureStateModel,
MultivariateFeatureOptionModel,
MultivariateFeatureStateValueModel
} from './models';
} from './models.js';

export function buildFeatureModel(featuresModelJSON: any): FeatureModel {
return new FeatureModel(featuresModelJSON.id, featuresModelJSON.name, featuresModelJSON.type);
Expand Down
5 changes: 2 additions & 3 deletions flagsmith-engine/identities/models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FeatureStateModel } from '../features/models';
import { IdentityFeaturesList } from '../utils/collections';
import { TraitModel } from './traits/models';
import { IdentityFeaturesList } from '../utils/collections.js';
import { TraitModel } from './traits/models.js';

const { v4: uuidv4 } = require('uuid');

Expand Down
8 changes: 4 additions & 4 deletions flagsmith-engine/identities/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildFeatureStateModel } from '../features/util';
import { IdentityFeaturesList } from '../utils/collections';
import { IdentityModel } from './models';
import { TraitModel } from './traits/models';
import { buildFeatureStateModel } from '../features/util.js';
import { IdentityFeaturesList } from '../utils/collections.js';
import { IdentityModel } from './models.js';
import { TraitModel } from './traits/models.js';

export function buildTraitModel(traitJSON: any): TraitModel {
return new TraitModel(traitJSON.trait_key, traitJSON.trait_value);
Expand Down
26 changes: 13 additions & 13 deletions flagsmith-engine/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { EnvironmentModel } from './environments/models';
import { FeatureStateModel } from './features/models';
import { IdentityModel } from './identities/models';
import { TraitModel } from './identities/traits/models';
import { getIdentitySegments } from './segments/evaluators';
import { SegmentModel } from './segments/models';
import { FeatureStateNotFound } from './utils/errors';
import { EnvironmentModel } from './environments/models.js';
import { FeatureStateModel } from './features/models.js';
import { IdentityModel } from './identities/models.js';
import { TraitModel } from './identities/traits/models.js';
import { getIdentitySegments } from './segments/evaluators.js';
import { SegmentModel } from './segments/models.js';
import { FeatureStateNotFound } from './utils/errors.js';

export { EnvironmentModel } from './environments/models';
export { FeatureStateModel } from './features/models';
export { IdentityModel } from './identities/models';
export { TraitModel } from './identities/traits/models';
export { SegmentModel } from './segments/models';
export { OrganisationModel } from './organisations/models';
export { EnvironmentModel } from './environments/models.js';
export { FeatureStateModel } from './features/models.js';
export { IdentityModel } from './identities/models.js';
export { TraitModel } from './identities/traits/models.js';
export { SegmentModel } from './segments/models.js';
export { OrganisationModel } from './organisations/models.js';

function getIdentityFeatureStatesDict(
environment: EnvironmentModel,
Expand Down
2 changes: 1 addition & 1 deletion flagsmith-engine/organisations/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OrganisationModel } from './models';
import { OrganisationModel } from './models.js';

export function buildOrganizationModel(organizationJSON: any): OrganisationModel {
return new OrganisationModel(
Expand Down
4 changes: 2 additions & 2 deletions flagsmith-engine/projects/models.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OrganisationModel } from '../organisations/models';
import { SegmentModel } from '../segments/models';
import { OrganisationModel } from '../organisations/models.js';
import { SegmentModel } from '../segments/models.js';

export class ProjectModel {
id: number;
Expand Down
8 changes: 4 additions & 4 deletions flagsmith-engine/projects/util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildOrganizationModel } from '../organisations/util';
import { SegmentModel } from '../segments/models';
import { buildSegmentModel } from '../segments/util';
import { ProjectModel } from './models';
import { buildOrganizationModel } from '../organisations/util.js';
import { SegmentModel } from '../segments/models.js';
import { buildSegmentModel } from '../segments/util.js';
import { ProjectModel } from './models.js';

export function buildProjectModel(projectJSON: any): ProjectModel {
const segments: SegmentModel[] = projectJSON['segments']
Expand Down
12 changes: 6 additions & 6 deletions flagsmith-engine/segments/evaluators.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EnvironmentModel } from '../environments/models';
import { IdentityModel } from '../identities/models';
import { TraitModel } from '../identities/traits/models';
import { getHashedPercentateForObjIds } from '../utils/hashing';
import { PERCENTAGE_SPLIT, IS_SET, IS_NOT_SET } from './constants';
import { SegmentConditionModel, SegmentModel, SegmentRuleModel } from './models';
import { EnvironmentModel } from '../environments/models.js';
import { IdentityModel } from '../identities/models.js';
import { TraitModel } from '../identities/traits/models.js';
import { getHashedPercentateForObjIds } from '../utils/hashing/index.js';
import { PERCENTAGE_SPLIT, IS_SET, IS_NOT_SET } from './constants.js';
import { SegmentConditionModel, SegmentModel, SegmentRuleModel } from './models.js';

export function getIdentitySegments(
environment: EnvironmentModel,
Expand Down
8 changes: 4 additions & 4 deletions flagsmith-engine/segments/models.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import semver from 'semver';

import { FeatureStateModel } from '../features/models';
import { getCastingFunction as getCastingFunction } from '../utils';
import { FeatureStateModel } from '../features/models.js';
import { getCastingFunction as getCastingFunction } from '../utils/index.js';
import {
ALL_RULE,
ANY_RULE,
Expand All @@ -11,8 +11,8 @@ import {
MODULO,
IN,
CONDITION_OPERATORS
} from './constants';
import { isSemver } from './util';
} from './constants.js';
import { isSemver } from './util.js';

export const all = (iterable: Array<any>) => iterable.filter(e => !!e).length === iterable.length;
export const any = (iterable: Array<any>) => iterable.filter(e => !!e).length > 0;
Expand Down
6 changes: 3 additions & 3 deletions flagsmith-engine/segments/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { buildFeatureStateModel } from '../features/util';
import { SegmentConditionModel, SegmentModel, SegmentRuleModel } from './models';
import { buildFeatureStateModel } from '../features/util.js';
import { SegmentConditionModel, SegmentModel, SegmentRuleModel } from './models.js';

export function buildSegmentConditionModel(segmentConditionJSON: any): SegmentConditionModel {
return new SegmentConditionModel(
Expand Down Expand Up @@ -34,4 +34,4 @@ export function isSemver(value: any) {

export function removeSemverSuffix(value: string) {
return value.replace(':semver', '');
}
}
2 changes: 1 addition & 1 deletion flagsmith-engine/utils/collections.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { FeatureStateModel } from '../features/models';
import { FeatureStateModel } from '../features/models.js';

export class IdentityFeaturesList extends Array<FeatureStateModel> {}
2 changes: 1 addition & 1 deletion flagsmith-engine/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { removeSemverSuffix } from "../segments/util";
import { removeSemverSuffix } from "../segments/util.js";

export function getCastingFunction(traitType: 'boolean' | 'string' | 'number' | 'semver' | any): CallableFunction {
switch (traitType) {
Expand Down
8 changes: 4 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Flagsmith from "./sdk";
import Flagsmith from "./sdk/index.js";

export {
AnalyticsProcessor,
Expand All @@ -9,11 +9,11 @@ export {
DefaultFlag,
Flags,
default
} from './sdk';
} from './sdk/index.js';

export {
FlagsmithConfig
} from './sdk/types'
} from './sdk/types.js'

export {
EnvironmentModel,
Expand All @@ -22,6 +22,6 @@ export {
TraitModel,
SegmentModel,
OrganisationModel
} from './flagsmith-engine';
} from './flagsmith-engine/index.js';

module.exports = Flagsmith;
5 changes: 0 additions & 5 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 0df9af2

Please sign in to comment.