Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jul 5, 2023
2 parents 2330ea6 + 59f99ce commit 6b8f417
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 8 deletions.
4 changes: 3 additions & 1 deletion DOCS/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- InherentPermissions to simplify permissions [#13](https://github.com/thetanz/OpenFeature-al/issues/13)
### Added
<!---for new features--->
-
- Code documentation for public APIs, public enums and interfaces
- `IProvider_FF_TSL` and `FeatureEvent_FF_TSL` become public to enable custom providers
- `FeatureMgt_FF_TSL.OnAfterGetUserContext` event
### Changed
<!---for changes in existing functionality--->
-
Expand Down
14 changes: 14 additions & 0 deletions MAIN/src/ConditionFunctions/IConditionFunction.Interface.al
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ interface "IConditionFunction_FF_TSL"
{
Access = Public;

/// <summary>
/// Lookup the argument of the condition function.
/// </summary>
/// <param name="Argument">Free form text argument of the condition function.</param>
procedure LookupConditionArgument(var Argument: Text[2048])
/// <summary>
/// Validate the argument of the condition function.
/// </summary>
/// <param name="Argument">Free form text argument of the condition function.</param>
/// <returns>Validated argument of the condition function.</returns>
procedure ValidateConditionArgument(Argument: Text): Text[2048]
/// <summary>
/// Check if the condition is active. Active is when condition is satisfied for current context.
/// </summary>
/// <param name="Argument">Free form text argument of the condition function.</param>
/// <returns>True if condition is active, false otherwise.</returns>
procedure IsActiveCondition(Argument: Text[2048]): Boolean
}
1 change: 0 additions & 1 deletion MAIN/src/Features/FeatureEvent.Enum.al
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
enum 70254347 "FeatureEvent_FF_TSL"
{
Access = Internal;
Extensible = false;

/// <summary>
Expand Down
15 changes: 12 additions & 3 deletions MAIN/src/Features/FeatureMgt.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ codeunit 70254347 "FeatureMgt_FF_TSL"

#region API

/// <summary>
/// Checks if a feature is enabled for the current user.
/// </summary>
/// <param name="FeatureID">The ID of the feature to check.</param>
/// <returns>True if the feature is enabled for the current user.</returns>
procedure IsEnabled(FeatureID: Code[50]) Enabled: Boolean
var
CallerModuleInfo: ModuleInfo;
Expand Down Expand Up @@ -285,7 +290,7 @@ codeunit 70254347 "FeatureMgt_FF_TSL"
end
end;
ContextAttributes.Add('profileID', TempUserSettings."Profile ID");
OnGetUserContext(ContextAttributes);
OnAfterGetUserContext(ContextAttributes);
GlobalContextAttributes := ContextAttributes;
GlobalContextAttributesContextID := ContextID;
end;
Expand Down Expand Up @@ -398,8 +403,12 @@ codeunit 70254347 "FeatureMgt_FF_TSL"

#region Events

[InternalEvent(false)]
local procedure OnGetUserContext(var ContextAttributes: JsonObject)
/// <summary>
/// This event is raised after the user context is set.
/// </summary>
/// <param name="ContextAttributes">Editable context attributes.</param>
[BusinessEvent(false)]
local procedure OnAfterGetUserContext(var ContextAttributes: JsonObject)
begin

end;
Expand Down
21 changes: 20 additions & 1 deletion MAIN/src/Providers/ConditionProvider.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ codeunit 70254351 "ConditionProvider_FF_TSL" implements IProvider_FF_TSL

#region Library

procedure AddFeature(FeatureID: Code[50]; Description: Text[2048]): Boolean
/// <summary>
/// Adds a new feature to the system.
/// </summary>
/// <param name="FeatureID">Feature identifier.</param>
/// <param name="Description">Feature description which may include a link to learn more about the feature. Example: "[My new feature](https://www.example.com)"</param>
/// <returns>True if the feature was added successfully.</returns>
procedure AddFeature(FeatureID: Code[50]; Description: Text): Boolean
begin
exit(FeatureMgt.AddFeature(FeatureID, Description, ConditionProviderCodeTxt))
end;

/// <summary>
/// Adds a new condition to the system.
/// </summary>
/// <param name="Code">Condition code.</param>
/// <param name="Function">Condition function.</param>
/// <param name="Argument">Condition argument.</param>
/// <returns>True if the condition was added successfully.</returns>
[InherentPermissions(PermissionObjectType::TableData, Database::Condition_FF_TSL, 'I')]
procedure AddCondition(Code: Code[50]; Function: Enum ConditionFunction_FF_TSL; Argument: Text) Result: Boolean
var
Expand All @@ -34,6 +47,12 @@ codeunit 70254351 "ConditionProvider_FF_TSL" implements IProvider_FF_TSL
end
end;

/// <summary>
/// Adds a new feature condition to the system.
/// </summary>
/// <param name="FeatureID">Feature identifier.</param>
/// <param name="ConditionCode">Condition code.</param>
/// <returns>True if the feature condition was added successfully.</returns>
[InherentPermissions(PermissionObjectType::TableData, Database::FeatureCondition_FF_TSL, 'IM')]
procedure AddFeatureCondition(FeatureID: Code[50]; ConditionCode: Code[50]) Result: Boolean
var
Expand Down
33 changes: 31 additions & 2 deletions MAIN/src/Providers/IProvider.Interface.al
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
interface "IProvider_FF_TSL"
{
Access = Internal;

/// <summary>
/// Cleans up any cached data for the specified provider.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
procedure ClearCache(ConnectionInfo: JsonObject)
/// <summary>
/// Handles a drill down event for the specified feature.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
/// <param name="FeatureID">Feature Identifier.</param>
procedure DrillDownState(ConnectionInfo: JsonObject; FeatureID: Code[50])
/// <summary>
/// Gets the enabled features for the specified provider.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
/// <returns>List of enabled feature identifiers.</returns>
procedure GetEnabled(ConnectionInfo: JsonObject): List of [Code[50]]
/// <summary>
/// Gets all features for the specified provider.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
/// <returns>List of all feature identifiers.</returns>
procedure GetAll(ConnectionInfo: JsonObject): Dictionary of [Code[50], Text]
/// <summary>
/// Passing a user context to the provider.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
/// <param name="ContextUserSecurityID">User context identifier.</param>
procedure SetContext(ConnectionInfo: JsonObject; ContextUserSecurityID: Guid)
/// <summary>
/// Captures a feature event.
/// </summary>
/// <param name="ConnectionInfo">Provider connection information.</param>
/// <param name="EventDateTime">Event date time.</param>
/// <param name="FeatureEvent">Feature event type.</param>
/// <param name="CustomDimensions">Custom dimensions.</param>
procedure CaptureEvent(ConnectionInfo: JsonObject; EventDateTime: DateTime; FeatureEvent: Enum "FeatureEvent_FF_TSL"; CustomDimensions: Dictionary of [Text, Text])
}
7 changes: 7 additions & 0 deletions MAIN/src/Providers/PostHogProvider.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ codeunit 70254353 "PostHogProvider_FF_TSL" implements IProvider_FF_TSL

#region Library

/// <summary>
/// Add a new PostHog provider to the system.
/// </summary>
/// <param name="Code">Provider code</param>
/// <param name="PersonalAPIKey">PostHug Personal API key</param>
/// <param name="ProjectID">PostHug Project ID</param>
/// <returns>True if the provider was added successfully, false otherwise</returns>
[NonDebuggable]
procedure AddProvider(Code: Code[20]; PersonalAPIKey: Text; ProjectID: Text): Boolean
var
Expand Down
6 changes: 6 additions & 0 deletions MAIN/src/Providers/ProviderType.Enum.al
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ enum 70254346 "ProviderType_FF_TSL" implements IProvider_FF_TSL
Extensible = true;
Caption = 'Provider Type';

/// <summary>
/// Condtion Provider Type
/// </summary>
value(0; Condition)
{
Caption = 'Condition';
Implementation = IProvider_FF_TSL = "ConditionProvider_FF_TSL";
}
/// <summary>
/// PostHog Provider Type
/// </summary>
value(1; PostHog)
{
Caption = 'PostHog';
Expand Down

0 comments on commit 6b8f417

Please sign in to comment.