mirror of
https://github.com/xtr-dev/payload-feature-flags.git
synced 2025-12-10 02:43:25 +00:00
Bump version to 0.0.7
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@xtr-dev/payload-feature-flags",
|
"name": "@xtr-dev/payload-feature-flags",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"description": "Feature flags plugin for Payload CMS - manage feature toggles, A/B tests, and gradual rollouts",
|
"description": "Feature flags plugin for Payload CMS - manage feature toggles, A/B tests, and gradual rollouts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -34,14 +34,8 @@ function getCollectionSlug(payload: Payload): string {
|
|||||||
/**
|
/**
|
||||||
* Get a specific feature flag by name (for use in React Server Components)
|
* Get a specific feature flag by name (for use in React Server Components)
|
||||||
*/
|
*/
|
||||||
export const getFeatureFlag = cache(async (flagName: string, payload?: Payload): Promise<FeatureFlag | null> => {
|
export const getFeatureFlag = cache(async (flagName: string, payload: Payload): Promise<FeatureFlag | null> => {
|
||||||
try {
|
try {
|
||||||
// If no payload provided, return null as these hooks should be used within Payload context
|
|
||||||
if (!payload) {
|
|
||||||
console.error('Payload instance not available. These hooks should be called within Payload server context or pass payload as parameter.')
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const collectionSlug = getCollectionSlug(payload)
|
const collectionSlug = getCollectionSlug(payload)
|
||||||
|
|
||||||
const result = await payload.find({
|
const result = await payload.find({
|
||||||
@@ -76,7 +70,7 @@ export const getFeatureFlag = cache(async (flagName: string, payload?: Payload):
|
|||||||
/**
|
/**
|
||||||
* Check if a feature flag is enabled (for use in React Server Components)
|
* Check if a feature flag is enabled (for use in React Server Components)
|
||||||
*/
|
*/
|
||||||
export const isFeatureEnabled = cache(async (flagName: string, payload?: Payload): Promise<boolean> => {
|
export const isFeatureEnabled = cache(async (flagName: string, payload: Payload): Promise<boolean> => {
|
||||||
const flag = await getFeatureFlag(flagName, payload)
|
const flag = await getFeatureFlag(flagName, payload)
|
||||||
return flag?.enabled ?? false
|
return flag?.enabled ?? false
|
||||||
})
|
})
|
||||||
@@ -84,14 +78,8 @@ export const isFeatureEnabled = cache(async (flagName: string, payload?: Payload
|
|||||||
/**
|
/**
|
||||||
* Get all active feature flags (for use in React Server Components)
|
* Get all active feature flags (for use in React Server Components)
|
||||||
*/
|
*/
|
||||||
export const getAllFeatureFlags = cache(async (payload?: Payload): Promise<Record<string, FeatureFlag>> => {
|
export const getAllFeatureFlags = cache(async (payload: Payload): Promise<Record<string, FeatureFlag>> => {
|
||||||
try {
|
try {
|
||||||
// If no payload provided, return empty object as these hooks should be used within Payload context
|
|
||||||
if (!payload) {
|
|
||||||
console.error('Payload instance not available. These hooks should be called within Payload server context or pass payload as parameter.')
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
|
|
||||||
const collectionSlug = getCollectionSlug(payload)
|
const collectionSlug = getCollectionSlug(payload)
|
||||||
|
|
||||||
const result = await payload.find({
|
const result = await payload.find({
|
||||||
@@ -129,7 +117,7 @@ export const getAllFeatureFlags = cache(async (payload?: Payload): Promise<Recor
|
|||||||
export const isUserInRollout = cache(async (
|
export const isUserInRollout = cache(async (
|
||||||
flagName: string,
|
flagName: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
payload?: Payload
|
payload: Payload
|
||||||
): Promise<boolean> => {
|
): Promise<boolean> => {
|
||||||
const flag = await getFeatureFlag(flagName, payload)
|
const flag = await getFeatureFlag(flagName, payload)
|
||||||
|
|
||||||
@@ -155,7 +143,7 @@ export const isUserInRollout = cache(async (
|
|||||||
export const getUserVariant = cache(async (
|
export const getUserVariant = cache(async (
|
||||||
flagName: string,
|
flagName: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
payload?: Payload
|
payload: Payload
|
||||||
): Promise<string | null> => {
|
): Promise<string | null> => {
|
||||||
const flag = await getFeatureFlag(flagName, payload)
|
const flag = await getFeatureFlag(flagName, payload)
|
||||||
|
|
||||||
@@ -184,14 +172,8 @@ export const getUserVariant = cache(async (
|
|||||||
/**
|
/**
|
||||||
* Get feature flags by tags (for use in React Server Components)
|
* Get feature flags by tags (for use in React Server Components)
|
||||||
*/
|
*/
|
||||||
export const getFeatureFlagsByTag = cache(async (tag: string, payload?: Payload): Promise<FeatureFlag[]> => {
|
export const getFeatureFlagsByTag = cache(async (tag: string, payload: Payload): Promise<FeatureFlag[]> => {
|
||||||
try {
|
try {
|
||||||
// If no payload provided, return empty array as these hooks should be used within Payload context
|
|
||||||
if (!payload) {
|
|
||||||
console.error('Payload instance not available. These hooks should be called within Payload server context or pass payload as parameter.')
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
const collectionSlug = getCollectionSlug(payload)
|
const collectionSlug = getCollectionSlug(payload)
|
||||||
|
|
||||||
const result = await payload.find({
|
const result = await payload.find({
|
||||||
|
|||||||
Reference in New Issue
Block a user