Skip to content

Commit

Permalink
v2.0 Re-write
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyVyska committed Feb 16, 2023
1 parent 7f7d7a4 commit 2ff2231
Show file tree
Hide file tree
Showing 36 changed files with 1,504 additions and 634 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"CRS.FileNamePatternPageCustomizations": "<ObjectNameShort>.<ObjectTypeShortPascalCase>.al",
"CRS.RenameWithGit": false,
"CRS.ObjectNamePrefix": "SPBPL ",
"al.ruleSetPath": "./ruleset.json",
"al.ruleSetPath": "src\\.rulesets\\SPBLicensing.ruleset.json",

}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@

# Change Log

## [2.0.202307.109] - 2023-02-16

Massive refactoring. **Note: Breaking changes**

### Added
- New Platform built in, [Lemon Squeezy](https://www.lemonsqueezy.com/)

### Changed
- **Breaking Change:** All events refactored into a new Event Wrapper codeunit
- **Breaking Change:** Checking if a license is active moved to new codeunit for the purpose. This is in prep for more complex checking, such as metered usage scenarios
- **Breaking Change:** Interface for alternative platforms now has more procedure signatures to be more platform agnostic in logic flows.
- Restructure of Files/Folders to add developer clarity
- Refactor of entire Extension to comply better with SOLID principles
- Additional documentation added to codeunits/procedures

### Notice

Due to the sheer volume of breaking changes, the commit history on this repo is NOT completely detailing all changes. This repo is a PTE *clone* of the AppSource app (renamed and renumbered, so they can co-exist) which is on our Public Azure DevOps site.

## [1.0.202224.23] - 2022-06-06

Lots of fixes, tweaks, and v20 changeover. New Submodule option for licensing.
Expand Down
210 changes: 135 additions & 75 deletions Translations/Spare Brained Licensing Public.g.xlf

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publisher": "Spare Brained Ideas AB",
"brief": "This library helps other Extensions verify a current subscription license.",
"description": "This library helps other Extensions verify a current subscription license.",
"version": "1.1.0.0",
"version": "1.2.0.0",
"privacyStatement": "https://sparebrained.com/appsource/privacystatement",
"EULA": "https://sparebrained.com/appsource/eula",
"help": "https://sparebrained.com/support",
Expand All @@ -18,7 +18,7 @@
"idRanges": [
{
"from": 71033,
"to": 71043
"to": 71049
}
],
"resourceExposurePolicy": {
Expand All @@ -27,7 +27,7 @@
"includeSourceInSymbolFile": true
},
"target": "Cloud",
"runtime": "8.0",
"runtime": "10.0",
"features": [
"TranslationFile", "NoImplicitWith"
],
Expand Down
21 changes: 0 additions & 21 deletions ruleset.json

This file was deleted.

48 changes: 48 additions & 0 deletions src/.obsoleting/SPBPLLicenseManagement.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
codeunit 71036 "SPBPL License Management"
{
Permissions = tabledata "SPBPL Extension License" = RIM;
ObsoleteState = Pending;
ObsoleteReason = 'Refactored to new Method Codeunits and separate Event wrapper.';

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnAfterLicenseDeactivated(var SPBExtensionLicense: Record "SPBPL Extension License")
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnAfterLicenseDeactivatedByPlatform(var SPBExtensionLicense: Record "SPBPL Extension License"; ResponseBody: Text)
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnAfterActivationFailure(var SPBExtensionLicense: Record "SPBPL Extension License"; var AppInfo: ModuleInfo)
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnBeforeVersionCheckUpgradeAvailable(var SPBExtensionLicense: Record "SPBPL Extension License"; var LatestVersion: Version; var IsHandled: Boolean)
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnAfterActivationSuccess(var SPBExtensionLicense: Record "SPBPL Extension License"; var AppInfo: ModuleInfo)
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
local procedure OnAfterVersionCheckFailure(var SPBExtensionLicense: Record "SPBPL Extension License"; var ApiHttpRespMessage: HttpResponseMessage)
begin
end;

[Obsolete('Use new Events in SPBPL Events codeunit.')]
[IntegrationEvent(false, false)]
internal procedure OnAfterThrowPossibleMisuse(var SPBExtensionLicense: Record "SPBPL Extension License")
begin
end;
}
23 changes: 23 additions & 0 deletions src/.permissions/SPBPLLicensing.PermissionSet.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
permissionset 71033 "SPBPL Licensing"
{
Assignable = true;
Caption = 'Spare Brained Licensing Admin';
Permissions = table "SPBPL Extension License" = X,
tabledata "SPBPL Extension License" = RMI,
codeunit "SPBPL Activate Meth" = X,
codeunit "SPBPL Check Active" = X,
codeunit "SPBPL Check Active Meth" = X,
codeunit "SPBPL Deactivate Meth" = X,
codeunit "SPBPL Environment Watcher" = X,
codeunit "SPBPL Events" = X,
codeunit "SPBPL Extension Registration" = X,
codeunit "SPBPL Gumroad Communicator" = X,
codeunit "SPBPL IsoStore Manager" = X,
codeunit "SPBPL LemonSqueezy Comm." = X,
codeunit "SPBPL License Utilities" = X,
codeunit "SPBPL Licensing Install" = X,
codeunit "SPBPL Upgrade" = X,
codeunit "SPBPL Version Check" = X,
page "SPBPL Extension Licenses" = X,
page "SPBPL License Activation" = X;
}
23 changes: 23 additions & 0 deletions src/.permissions/SPBPLLicensingRO.PermissionSet.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
permissionset 71034 "SPBPL Licensing RO"
{
Assignable = true;
Caption = 'SPBPL Licensing RO';
Permissions = table "SPBPL Extension License" = X,
tabledata "SPBPL Extension License" = RMI,
codeunit "SPBPL Activate Meth" = X,
codeunit "SPBPL Check Active" = X,
codeunit "SPBPL Check Active Meth" = X,
codeunit "SPBPL Deactivate Meth" = X,
codeunit "SPBPL Environment Watcher" = X,
codeunit "SPBPL Events" = X,
codeunit "SPBPL Extension Registration" = X,
codeunit "SPBPL Gumroad Communicator" = X,
codeunit "SPBPL IsoStore Manager" = X,
codeunit "SPBPL LemonSqueezy Comm." = X,
codeunit "SPBPL License Utilities" = X,
codeunit "SPBPL Licensing Install" = X,
codeunit "SPBPL Upgrade" = X,
codeunit "SPBPL Version Check" = X,
page "SPBPL Extension Licenses" = X,
page "SPBPL License Activation" = X;
}
36 changes: 36 additions & 0 deletions src/.rulesets/SPBLicensing.ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Licensing ruleset",
"description": "The ruleset to use for SBI Licensing",
"rules": [
{
"id": "AA0240",
"action": "None",
"justification": "There are intentionally included email addresses for support with this extension."
},
{
"id": "AA0072",
"action": "None",
"justification": "I need to use more generic variable names for easing cloning to a PTE."
},
{
"id": "PTE0001",
"action": "None",
"justification": "<object> has an ID of [#######]. It must be between 50000 and 99999. Need to clarify licensing issues with VAR ID range"
},
{
"id": "PTE0002",
"action": "None",
"justification": "<field in tableextension> has an ID of [#######]. It must be between 50000 and 99999. Need to clarify licensing issues with VAR ID range"
},
{
"id": "AS0084",
"action": "None",
"justification": "Not Applicable - The ID range '[50000..99999]' is not valid. It must be within the range allocated to the partner for AppSource, within the range '[1000000..75999999]' allocated to AppSource applications, and outside the range '[50000..99999]' allocated to per-tenant customizations."
},
{
"id": "AS0092",
"action": "None",
"justification": "For the public version, I'm not releasing my app insights key. You're welcome to include your own, of course, as telemetry was added in v1.2.0.0."
}
]
}
61 changes: 61 additions & 0 deletions src/Callables/SPBPLCheckActive.Codeunit.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/// <summary>
/// This Codeunit is for checking basic active/inactive functions to be used by 3rd parties wanting to validate
/// if a license is active. Two main options exist at this time - with or without Submodule functionality.
/// </summary>
codeunit 71042 "SPBPL Check Active"
{
/// <summary>
/// This function takes an App ID and checks if it is active or not, along with if the user should be shown errors if Inactive.
/// </summary>
/// <param name="SubscriptionId">This should be the App ID</param>
/// <param name="InactiveShowError">If the extension is Inactive, should the user be shown an error?</param>
/// <returns></returns>
procedure CheckBasic(SubscriptionId: Guid; InactiveShowError: Boolean) IsActive: Boolean
var
SPBExtensionLicense: Record "SPBPL Extension License";
NoSubFoundErr: Label 'No License was found in the Licenses list for SubscriptionId: %1', Comment = '%1 is the ID of the App.';
begin
SPBExtensionLicense.SetRange("Extension App Id");
//If using this function signature, the Submodule functionality should NOT be considered.
SPBExtensionLicense.SetRange("Submodule Name", '');
if not SPBExtensionLicense.FindFirst() then
if GuiAllowed() then
Error(NoSubFoundErr, SubscriptionId);

IsActive := DoCheckBasic(SPBExtensionLicense, InactiveShowError);
end;

/// <summary>
/// This function takes an App ID and Submodule Name and checks if it is active or not, along with if the user should be shown errors if Inactive.
/// </summary>
/// <param name="SubscriptionId">This should be the App ID</param>
/// <param name="SubmoduleName">This should be the submodule to check for</param>
/// <param name="InactiveShowError">If the extension is Inactive, should the user be shown an error?</param>
/// <returns></returns>
procedure CheckBasicSubmodule(SubscriptionId: Guid; SubmoduleName: Text[100]; InactiveShowError: Boolean) IsActive: Boolean
var
SPBExtensionLicense: Record "SPBPL Extension License";
NoSubscriptionFoundErr: Label 'No License was found in the Licenses list for SubscriptionId: %1 with Submodule name: %2', Comment = '%1 is the ID of the App. %2 is the Submodule.';
begin
SPBExtensionLicense.SetRange("Extension App Id");
SPBExtensionLicense.SetRange("Submodule Name", SubmoduleName);
if not SPBExtensionLicense.FindFirst() then
if GuiAllowed() then
Error(NoSubscriptionFoundErr, SubscriptionId, SubmoduleName);

IsActive := DoCheckBasic(SPBExtensionLicense, InactiveShowError);
end;

local procedure DoCheckBasic(var SPBExtensionLicense: Record "SPBPL Extension License"; InactiveShowError: Boolean): Boolean
var
SPBPLCheckActiveMeth: Codeunit "SPBPL Check Active Meth";
IsActive: Boolean;
SubscriptionInactiveErr: Label 'The License for %1 is not Active. Contact your system administrator to re-activate it.', Comment = '%1 is the name of the Extension.';
begin
IsActive := SPBPLCheckActiveMeth.CheckIfActive(SPBExtensionLicense);
if not IsActive and InactiveShowError then
if GuiAllowed() then
Error(SubscriptionInactiveErr, SPBExtensionLicense."Extension Name");
exit(IsActive);
end;
}
Loading

0 comments on commit 2ff2231

Please sign in to comment.