From 59f99ce1ed9a058121c405dc677fd0bc85b4352f Mon Sep 17 00:00:00 2001 From: Vlad Leonov Date: Wed, 5 Jul 2023 12:36:45 +1200 Subject: [PATCH] +code docs, +provider extensability --- DOCS/Changelog.md | 4 ++- .../IConditionFunction.Interface.al | 14 ++++++++ MAIN/src/Features/FeatureEvent.Enum.al | 1 - MAIN/src/Features/FeatureMgt.Codeunit.al | 15 +++++++-- .../Providers/ConditionProvider.Codeunit.al | 21 +++++++++++- MAIN/src/Providers/IProvider.Interface.al | 33 +++++++++++++++++-- .../src/Providers/PostHogProvider.Codeunit.al | 7 ++++ MAIN/src/Providers/ProviderType.Enum.al | 6 ++++ 8 files changed, 93 insertions(+), 8 deletions(-) diff --git a/DOCS/Changelog.md b/DOCS/Changelog.md index d27467f..98a6422 100644 --- a/DOCS/Changelog.md +++ b/DOCS/Changelog.md @@ -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 -- +- 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 - diff --git a/MAIN/src/ConditionFunctions/IConditionFunction.Interface.al b/MAIN/src/ConditionFunctions/IConditionFunction.Interface.al index 0b6b5e5..d9da3c5 100644 --- a/MAIN/src/ConditionFunctions/IConditionFunction.Interface.al +++ b/MAIN/src/ConditionFunctions/IConditionFunction.Interface.al @@ -2,7 +2,21 @@ interface "IConditionFunction_FF_TSL" { Access = Public; + /// + /// Lookup the argument of the condition function. + /// + /// Free form text argument of the condition function. procedure LookupConditionArgument(var Argument: Text[2048]) + /// + /// Validate the argument of the condition function. + /// + /// Free form text argument of the condition function. + /// Validated argument of the condition function. procedure ValidateConditionArgument(Argument: Text): Text[2048] + /// + /// Check if the condition is active. Active is when condition is satisfied for current context. + /// + /// Free form text argument of the condition function. + /// True if condition is active, false otherwise. procedure IsActiveCondition(Argument: Text[2048]): Boolean } \ No newline at end of file diff --git a/MAIN/src/Features/FeatureEvent.Enum.al b/MAIN/src/Features/FeatureEvent.Enum.al index 41ed827..6567cfa 100644 --- a/MAIN/src/Features/FeatureEvent.Enum.al +++ b/MAIN/src/Features/FeatureEvent.Enum.al @@ -1,6 +1,5 @@ enum 58539 "FeatureEvent_FF_TSL" { - Access = Internal; Extensible = false; /// diff --git a/MAIN/src/Features/FeatureMgt.Codeunit.al b/MAIN/src/Features/FeatureMgt.Codeunit.al index 379311a..63a3ee9 100644 --- a/MAIN/src/Features/FeatureMgt.Codeunit.al +++ b/MAIN/src/Features/FeatureMgt.Codeunit.al @@ -133,6 +133,11 @@ codeunit 58537 "FeatureMgt_FF_TSL" #region API + /// + /// Checks if a feature is enabled for the current user. + /// + /// The ID of the feature to check. + /// True if the feature is enabled for the current user. procedure IsEnabled(FeatureID: Code[50]) Enabled: Boolean var CallerModuleInfo: ModuleInfo; @@ -285,7 +290,7 @@ codeunit 58537 "FeatureMgt_FF_TSL" end end; ContextAttributes.Add('profileID', TempUserSettings."Profile ID"); - OnGetUserContext(ContextAttributes); + OnAfterGetUserContext(ContextAttributes); GlobalContextAttributes := ContextAttributes; GlobalContextAttributesContextID := ContextID; end; @@ -398,8 +403,12 @@ codeunit 58537 "FeatureMgt_FF_TSL" #region Events - [InternalEvent(false)] - local procedure OnGetUserContext(var ContextAttributes: JsonObject) + /// + /// This event is raised after the user context is set. + /// + /// Editable context attributes. + [BusinessEvent(false)] + local procedure OnAfterGetUserContext(var ContextAttributes: JsonObject) begin end; diff --git a/MAIN/src/Providers/ConditionProvider.Codeunit.al b/MAIN/src/Providers/ConditionProvider.Codeunit.al index c0282ff..4e49899 100644 --- a/MAIN/src/Providers/ConditionProvider.Codeunit.al +++ b/MAIN/src/Providers/ConditionProvider.Codeunit.al @@ -16,11 +16,24 @@ codeunit 58651 "ConditionProvider_FF_TSL" implements IProvider_FF_TSL #region Library - procedure AddFeature(FeatureID: Code[50]; Description: Text[2048]): Boolean + /// + /// Adds a new feature to the system. + /// + /// Feature identifier. + /// Feature description which may include a link to learn more about the feature. Example: "[My new feature](https://www.example.com)" + /// True if the feature was added successfully. + procedure AddFeature(FeatureID: Code[50]; Description: Text): Boolean begin exit(FeatureMgt.AddFeature(FeatureID, Description, ConditionProviderCodeTxt)) end; + /// + /// Adds a new condition to the system. + /// + /// Condition code. + /// Condition function. + /// Condition argument. + /// True if the condition was added successfully. [InherentPermissions(PermissionObjectType::TableData, Database::Condition_FF_TSL, 'I')] procedure AddCondition(Code: Code[50]; Function: Enum ConditionFunction_FF_TSL; Argument: Text) Result: Boolean var @@ -34,6 +47,12 @@ codeunit 58651 "ConditionProvider_FF_TSL" implements IProvider_FF_TSL end end; + /// + /// Adds a new feature condition to the system. + /// + /// Feature identifier. + /// Condition code. + /// True if the feature condition was added successfully. [InherentPermissions(PermissionObjectType::TableData, Database::FeatureCondition_FF_TSL, 'IM')] procedure AddFeatureCondition(FeatureID: Code[50]; ConditionCode: Code[50]) Result: Boolean var diff --git a/MAIN/src/Providers/IProvider.Interface.al b/MAIN/src/Providers/IProvider.Interface.al index 47ed024..c628b4b 100644 --- a/MAIN/src/Providers/IProvider.Interface.al +++ b/MAIN/src/Providers/IProvider.Interface.al @@ -1,11 +1,40 @@ interface "IProvider_FF_TSL" { - Access = Internal; - + /// + /// Cleans up any cached data for the specified provider. + /// + /// Provider connection information. procedure ClearCache(ConnectionInfo: JsonObject) + /// + /// Handles a drill down event for the specified feature. + /// + /// Provider connection information. + /// Feature Identifier. procedure DrillDownState(ConnectionInfo: JsonObject; FeatureID: Code[50]) + /// + /// Gets the enabled features for the specified provider. + /// + /// Provider connection information. + /// List of enabled feature identifiers. procedure GetEnabled(ConnectionInfo: JsonObject): List of [Code[50]] + /// + /// Gets all features for the specified provider. + /// + /// Provider connection information. + /// List of all feature identifiers. procedure GetAll(ConnectionInfo: JsonObject): Dictionary of [Code[50], Text] + /// + /// Passing a user context to the provider. + /// + /// Provider connection information. + /// User context identifier. procedure SetContext(ConnectionInfo: JsonObject; ContextUserSecurityID: Guid) + /// + /// Captures a feature event. + /// + /// Provider connection information. + /// Event date time. + /// Feature event type. + /// Custom dimensions. procedure CaptureEvent(ConnectionInfo: JsonObject; EventDateTime: DateTime; FeatureEvent: Enum "FeatureEvent_FF_TSL"; CustomDimensions: Dictionary of [Text, Text]) } \ No newline at end of file diff --git a/MAIN/src/Providers/PostHogProvider.Codeunit.al b/MAIN/src/Providers/PostHogProvider.Codeunit.al index 408d452..11dffed 100644 --- a/MAIN/src/Providers/PostHogProvider.Codeunit.al +++ b/MAIN/src/Providers/PostHogProvider.Codeunit.al @@ -16,6 +16,13 @@ codeunit 58653 "PostHogProvider_FF_TSL" implements IProvider_FF_TSL #region Library + /// + /// Add a new PostHog provider to the system. + /// + /// Provider code + /// PostHug Personal API key + /// PostHug Project ID + /// True if the provider was added successfully, false otherwise [NonDebuggable] procedure AddProvider(Code: Code[20]; PersonalAPIKey: Text; ProjectID: Text): Boolean var diff --git a/MAIN/src/Providers/ProviderType.Enum.al b/MAIN/src/Providers/ProviderType.Enum.al index 7d46f2b..717cf93 100644 --- a/MAIN/src/Providers/ProviderType.Enum.al +++ b/MAIN/src/Providers/ProviderType.Enum.al @@ -4,11 +4,17 @@ enum 58536 "ProviderType_FF_TSL" implements IProvider_FF_TSL Extensible = true; Caption = 'Provider Type'; + /// + /// Condtion Provider Type + /// value(0; Condition) { Caption = 'Condition'; Implementation = IProvider_FF_TSL = "ConditionProvider_FF_TSL"; } + /// + /// PostHog Provider Type + /// value(1; PostHog) { Caption = 'PostHog';