-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
668 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
import Utils from 'common/utils/utils' | ||
|
||
export const identityFeatureStateService = service | ||
.enhanceEndpoints({ addTagTypes: ['IdentityFeatureState'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
getIdentityFeatureStates: builder.query< | ||
Res['identityFeatureStates'], | ||
Req['getIdentityFeatureStates'] | ||
>({ | ||
providesTags: (res, _, req) => [ | ||
{ id: req.user, type: 'IdentityFeatureState' }, | ||
], | ||
query: (query: Req['getIdentityFeatureStates']) => ({ | ||
url: `environments/${ | ||
query.environment | ||
}/${Utils.getIdentitiesEndpoint()}/${ | ||
query.user | ||
}/${Utils.getFeatureStatesEndpoint()}/all/`, | ||
}), | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function getIdentityFeatureStates( | ||
store: any, | ||
data: Req['getIdentityFeatureStates'], | ||
options?: Parameters< | ||
typeof identityFeatureStateService.endpoints.getIdentityFeatureStates.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
identityFeatureStateService.endpoints.getIdentityFeatureStates.initiate( | ||
data, | ||
options, | ||
), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useGetIdentityFeatureStatesQuery, | ||
// END OF EXPORTS | ||
} = identityFeatureStateService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetIdentityFeatureStatesQuery({ id: 2 }, {}) //get hook | ||
const [createIdentityFeatureStates, { isLoading, data, isSuccess }] = useCreateIdentityFeatureStatesMutation() //create hook | ||
identityFeatureStateService.endpoints.getIdentityFeatureStates.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { PagedResponse, ProjectFlag, Res } from 'common/types/responses' | ||
import { Req } from 'common/types/requests' | ||
import { service } from 'common/service' | ||
import data from 'common/data/base/_data' | ||
import { BaseQueryFn } from '@reduxjs/toolkit/query' | ||
|
||
function recursivePageGet( | ||
url: string, | ||
parentRes: null | PagedResponse<ProjectFlag>, | ||
baseQuery: (arg: unknown) => any, // matches rtk types, | ||
) { | ||
return baseQuery({ | ||
method: 'GET', | ||
url, | ||
}).then((res: Res['projectFlags']) => { | ||
let response | ||
if (parentRes) { | ||
response = { | ||
...parentRes, | ||
results: parentRes.results.concat(res.results), | ||
} | ||
} else { | ||
response = res | ||
} | ||
if (res.next) { | ||
return recursivePageGet(res.next, response, baseQuery) | ||
} | ||
return Promise.resolve(response) | ||
}) | ||
} | ||
export const projectFlagService = service | ||
.enhanceEndpoints({ addTagTypes: ['ProjectFlag'] }) | ||
.injectEndpoints({ | ||
endpoints: (builder) => ({ | ||
getProjectFlags: builder.query< | ||
Res['projectFlags'], | ||
Req['getProjectFlags'] | ||
>({ | ||
providesTags: (res, _, req) => [ | ||
{ id: req?.project, type: 'ProjectFlag' }, | ||
], | ||
queryFn: async (args, _, _2, baseQuery) => { | ||
return await recursivePageGet( | ||
`projects/${args.project}/features/?page_size=999`, | ||
null, | ||
baseQuery, | ||
) | ||
}, | ||
}), | ||
// END OF ENDPOINTS | ||
}), | ||
}) | ||
|
||
export async function getProjectFlags( | ||
store: any, | ||
data: Req['getProjectFlags'], | ||
options?: Parameters< | ||
typeof projectFlagService.endpoints.getProjectFlags.initiate | ||
>[1], | ||
) { | ||
return store.dispatch( | ||
projectFlagService.endpoints.getProjectFlags.initiate(data, options), | ||
) | ||
} | ||
// END OF FUNCTION_EXPORTS | ||
|
||
export const { | ||
useGetProjectFlagsQuery, | ||
// END OF EXPORTS | ||
} = projectFlagService | ||
|
||
/* Usage examples: | ||
const { data, isLoading } = useGetProjectFlagsQuery({ id: 2 }, {}) //get hook | ||
const [createProjectFlags, { isLoading, data, isSuccess }] = useCreateProjectFlagsMutation() //create hook | ||
projectFlagService.endpoints.getProjectFlags.select({id: 2})(store.getState()) //access data from any function | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
aafce13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-staging – ./frontend
staging.flagsmith.com
flagsmith-frontend-staging-git-main-flagsmith.vercel.app
flagsmith-staging-frontend.vercel.app
flagsmith-frontend-staging-flagsmith.vercel.app
aafce13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./docs
docs-flagsmith.vercel.app
docs-git-main-flagsmith.vercel.app
docs.bullet-train.io
docs.flagsmith.com
aafce13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flagsmith-frontend-preview – ./frontend
flagsmith-frontend-preview-git-main-flagsmith.vercel.app
flagsmith-frontend-preview-flagsmith.vercel.app
flagsmith-frontend-production-native.vercel.app