@equinor/fusion-framework-module-msal 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/esm/__tests__/versioning/resolve-version.test.js +70 -140
  3. package/dist/esm/__tests__/versioning/resolve-version.test.js.map +1 -1
  4. package/dist/esm/static.js +1 -1
  5. package/dist/esm/v2/client/log/console.js +1 -1
  6. package/dist/esm/v2/provider.js +15 -15
  7. package/dist/esm/v2/provider.js.map +1 -1
  8. package/dist/esm/version.js +1 -1
  9. package/dist/esm/versioning/VersionError.js +0 -24
  10. package/dist/esm/versioning/VersionError.js.map +1 -1
  11. package/dist/esm/versioning/resolve-version.js +21 -15
  12. package/dist/esm/versioning/resolve-version.js.map +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/types/static.d.ts +1 -1
  15. package/dist/types/v2/provider.d.ts +2 -4
  16. package/dist/types/version.d.ts +1 -1
  17. package/dist/types/versioning/VersionError.d.ts +1 -26
  18. package/package.json +2 -2
  19. package/src/__tests__/versioning/resolve-version.test.ts +89 -170
  20. package/src/v2/client/log/console.ts +1 -1
  21. package/src/v2/provider.ts +18 -17
  22. package/src/version.ts +1 -1
  23. package/src/versioning/VersionError.ts +1 -40
  24. package/src/versioning/resolve-version.ts +35 -29
  25. package/dist/esm/versioning/create-version-message.js +0 -54
  26. package/dist/esm/versioning/create-version-message.js.map +0 -1
  27. package/dist/esm/versioning/static.js +0 -10
  28. package/dist/esm/versioning/static.js.map +0 -1
  29. package/dist/types/versioning/create-version-message.d.ts +0 -34
  30. package/dist/types/versioning/static.d.ts +0 -8
  31. package/src/versioning/create-version-message.ts +0 -63
  32. package/src/versioning/static.ts +0 -8
@@ -52,63 +52,69 @@ export function resolveVersion(version?: string | SemVer): ResolvedVersion {
52
52
  const versionString = version || MsalModuleVersion.Latest;
53
53
 
54
54
  // Parse versions using coerce for backward compatibility
55
- const wantedVersion = semver.coerce(versionString);
56
55
  const latestVersion = semver.coerce(MsalModuleVersion.Latest);
57
56
 
58
- // Validate that the requested version is a valid semver
59
- if (!wantedVersion) {
60
- throw VersionError.create(
61
- VersionError.Type.InvalidVersion,
57
+ // This should never happen! Indicates version.ts was not generated correctly
58
+ // This is a critical build-time issue that needs immediate attention
59
+ if (!latestVersion) {
60
+ throw new VersionError(
61
+ `Failed to parse latest version "${MsalModuleVersion.Latest}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`,
62
62
  versionString,
63
63
  MsalModuleVersion.Latest,
64
64
  );
65
65
  }
66
66
 
67
- // This should never happen! Indicates version.ts was not generated correctly
68
- // This is a critical build-time issue that needs immediate attention
69
- if (!latestVersion) {
70
- throw VersionError.create(
71
- VersionError.Type.InvalidLatestVersion,
67
+ let wantedVersion: SemVer | null = semver.coerce(versionString);
68
+ // Validate that the requested version is a valid semver
69
+ if (!wantedVersion) {
70
+ const missingVersionWarning = new VersionError(
71
+ `Failed to parse requested version "${versionString}"`,
72
72
  versionString,
73
73
  MsalModuleVersion.Latest,
74
74
  );
75
+ warnings.push(missingVersionWarning.message);
76
+ wantedVersion = latestVersion;
75
77
  }
76
78
 
77
- // Major version incompatibility check - this is a hard error
78
- // Users cannot request a major version that doesn't exist yet
79
- if (wantedVersion.major > latestVersion.major) {
80
- throw VersionError.create(
81
- VersionError.Type.MajorIncompatibility,
82
- String(wantedVersion),
83
- String(latestVersion),
79
+ if (wantedVersion.major < latestVersion.major) {
80
+ const majorBehindVersionWarning = new VersionError(
81
+ `Requested major version ${wantedVersion.major} is behind the latest major version ${latestVersion.major}`,
82
+ wantedVersion,
83
+ latestVersion,
84
84
  );
85
+ warnings.push(majorBehindVersionWarning.message);
85
86
  }
86
87
 
87
88
  // Minor version mismatch - add warning but don't throw
88
89
  // This helps developers stay aware of version differences without breaking functionality
89
90
  if (wantedVersion.major === latestVersion.major && wantedVersion.minor !== latestVersion.minor) {
90
- const minorMismatchWarning = VersionError.create(
91
- VersionError.Type.MinorMismatch,
92
- String(wantedVersion),
93
- String(latestVersion),
91
+ const minorMismatchWarning = new VersionError(
92
+ `Requested minor version ${wantedVersion.minor} is different from the latest minor version ${latestVersion.minor}`,
93
+ wantedVersion,
94
+ latestVersion,
94
95
  );
95
96
  warnings.push(minorMismatchWarning.message);
96
97
  }
97
98
 
98
99
  // Find the corresponding enum version for the requested major version
99
100
  // This is used for module configuration and feature detection
100
- const enumVersion = Object.values(MsalModuleVersion).find(
101
+ let enumVersion = Object.values(MsalModuleVersion).find(
101
102
  (x) => semver.coerce(x)?.major === wantedVersion.major,
102
103
  );
103
104
 
104
- // If no matching enum version is found, this indicates a major version
105
- // that doesn't have a corresponding enum value defined
105
+ // If no matching enum version is found, fall back to the latest available
106
+ // This allows forward compatibility with future versions
106
107
  if (!enumVersion) {
107
- throw VersionError.create(
108
- VersionError.Type.MajorIncompatibility,
109
- String(wantedVersion),
110
- String(latestVersion),
111
- );
108
+ enumVersion = MsalModuleVersion.Latest;
109
+ // Only warn if this is a future version (higher than latest)
110
+ if (wantedVersion.major > latestVersion.major) {
111
+ const fallbackWarning = new VersionError(
112
+ `Requested major version ${wantedVersion.major} is greater than the latest major version ${latestVersion.major}. Falling back to latest version.`,
113
+ wantedVersion,
114
+ latestVersion,
115
+ );
116
+ warnings.push(fallbackWarning.message);
117
+ }
112
118
  }
113
119
 
114
120
  // Return comprehensive version resolution result
@@ -1,54 +0,0 @@
1
- import { VersionMessageType } from './static';
2
- /**
3
- * Creates a human-readable version message based on the version message type.
4
- *
5
- * This function generates descriptive error messages for different version compatibility
6
- * scenarios, helping developers understand version-related issues.
7
- *
8
- * @param type - The type of version message to create
9
- * @param requestedVersion - The version that was requested by the user
10
- * @param latestVersion - The latest available version in the system
11
- * @returns A formatted, human-readable version message string
12
- *
13
- * @example
14
- * ```typescript
15
- * const message = createVersionMessage(
16
- * VersionMessageType.MajorIncompatibility,
17
- * '3.0.0',
18
- * '2.1.0'
19
- * );
20
- * // Returns: "Requested major version 3.0.0 is greater than the latest major version 2.1.0"
21
- * ```
22
- *
23
- * @example
24
- * ```typescript
25
- * const message = createVersionMessage(
26
- * VersionMessageType.MinorMismatch,
27
- * '2.1.0',
28
- * '2.2.0'
29
- * );
30
- * // Returns: "Minor version mismatch, requested 2.1.0, latest 2.2.0"
31
- * ```
32
- */
33
- export const createVersionMessage = (type, requestedVersion, latestVersion) => {
34
- // Convert versions to strings for consistent formatting
35
- const requestedVersionString = String(requestedVersion);
36
- const latestVersionString = String(latestVersion);
37
- switch (type) {
38
- case VersionMessageType.MajorIncompatibility:
39
- return `Requested major version ${requestedVersionString} is greater than the latest major version ${latestVersionString}`;
40
- case VersionMessageType.InvalidVersion:
41
- return `Invalid version ${requestedVersionString}`;
42
- case VersionMessageType.InvalidLatestVersion:
43
- return `Failed to parse latest version "${latestVersionString}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`;
44
- case VersionMessageType.MinorMismatch:
45
- return `Minor version mismatch, requested ${requestedVersionString}, latest ${latestVersionString}`;
46
- case VersionMessageType.PatchDifference:
47
- return `Patch version difference, requested ${requestedVersionString}, latest ${latestVersionString}`;
48
- case VersionMessageType.IncompatibleVersion:
49
- return `Incompatible version, requested ${requestedVersionString}, latest ${latestVersionString}`;
50
- default:
51
- return createVersionMessage(VersionMessageType.IncompatibleVersion, requestedVersion, latestVersion);
52
- }
53
- };
54
- //# sourceMappingURL=create-version-message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-version-message.js","sourceRoot":"","sources":["../../../src/versioning/create-version-message.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,IAAwB,EACxB,gBAAiC,EACjC,aAA8B,EACtB,EAAE;IACV,wDAAwD;IACxD,MAAM,sBAAsB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACxD,MAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IAClD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,kBAAkB,CAAC,oBAAoB;YAC1C,OAAO,2BAA2B,sBAAsB,6CAA6C,mBAAmB,EAAE,CAAC;QAC7H,KAAK,kBAAkB,CAAC,cAAc;YACpC,OAAO,mBAAmB,sBAAsB,EAAE,CAAC;QACrD,KAAK,kBAAkB,CAAC,oBAAoB;YAC1C,OAAO,mCAAmC,mBAAmB,mHAAmH,CAAC;QACnL,KAAK,kBAAkB,CAAC,aAAa;YACnC,OAAO,qCAAqC,sBAAsB,YAAY,mBAAmB,EAAE,CAAC;QACtG,KAAK,kBAAkB,CAAC,eAAe;YACrC,OAAO,uCAAuC,sBAAsB,YAAY,mBAAmB,EAAE,CAAC;QACxG,KAAK,kBAAkB,CAAC,mBAAmB;YACzC,OAAO,mCAAmC,sBAAsB,YAAY,mBAAmB,EAAE,CAAC;QACpG;YACE,OAAO,oBAAoB,CACzB,kBAAkB,CAAC,mBAAmB,EACtC,gBAAgB,EAChB,aAAa,CACd,CAAC;IACN,CAAC;AACH,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- export var VersionMessageType;
2
- (function (VersionMessageType) {
3
- VersionMessageType["MajorIncompatibility"] = "major-incompatibility";
4
- VersionMessageType["MinorMismatch"] = "minor-mismatch";
5
- VersionMessageType["PatchDifference"] = "patch-difference";
6
- VersionMessageType["InvalidVersion"] = "invalid-version";
7
- VersionMessageType["InvalidLatestVersion"] = "invalid-latest-version";
8
- VersionMessageType["IncompatibleVersion"] = "incompatible-version";
9
- })(VersionMessageType || (VersionMessageType = {}));
10
- //# sourceMappingURL=static.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static.js","sourceRoot":"","sources":["../../../src/versioning/static.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,kBAOX;AAPD,WAAY,kBAAkB;IAC5B,oEAA8C,CAAA;IAC9C,sDAAgC,CAAA;IAChC,0DAAoC,CAAA;IACpC,wDAAkC,CAAA;IAClC,qEAA+C,CAAA;IAC/C,kEAA4C,CAAA;AAC9C,CAAC,EAPW,kBAAkB,KAAlB,kBAAkB,QAO7B"}
@@ -1,34 +0,0 @@
1
- import type { SemVer } from 'semver';
2
- import { VersionMessageType } from './static';
3
- /**
4
- * Creates a human-readable version message based on the version message type.
5
- *
6
- * This function generates descriptive error messages for different version compatibility
7
- * scenarios, helping developers understand version-related issues.
8
- *
9
- * @param type - The type of version message to create
10
- * @param requestedVersion - The version that was requested by the user
11
- * @param latestVersion - The latest available version in the system
12
- * @returns A formatted, human-readable version message string
13
- *
14
- * @example
15
- * ```typescript
16
- * const message = createVersionMessage(
17
- * VersionMessageType.MajorIncompatibility,
18
- * '3.0.0',
19
- * '2.1.0'
20
- * );
21
- * // Returns: "Requested major version 3.0.0 is greater than the latest major version 2.1.0"
22
- * ```
23
- *
24
- * @example
25
- * ```typescript
26
- * const message = createVersionMessage(
27
- * VersionMessageType.MinorMismatch,
28
- * '2.1.0',
29
- * '2.2.0'
30
- * );
31
- * // Returns: "Minor version mismatch, requested 2.1.0, latest 2.2.0"
32
- * ```
33
- */
34
- export declare const createVersionMessage: (type: VersionMessageType, requestedVersion: string | SemVer, latestVersion: string | SemVer) => string;
@@ -1,8 +0,0 @@
1
- export declare enum VersionMessageType {
2
- MajorIncompatibility = "major-incompatibility",
3
- MinorMismatch = "minor-mismatch",
4
- PatchDifference = "patch-difference",
5
- InvalidVersion = "invalid-version",
6
- InvalidLatestVersion = "invalid-latest-version",
7
- IncompatibleVersion = "incompatible-version"
8
- }
@@ -1,63 +0,0 @@
1
- import type { SemVer } from 'semver';
2
- import { VersionMessageType } from './static';
3
-
4
- /**
5
- * Creates a human-readable version message based on the version message type.
6
- *
7
- * This function generates descriptive error messages for different version compatibility
8
- * scenarios, helping developers understand version-related issues.
9
- *
10
- * @param type - The type of version message to create
11
- * @param requestedVersion - The version that was requested by the user
12
- * @param latestVersion - The latest available version in the system
13
- * @returns A formatted, human-readable version message string
14
- *
15
- * @example
16
- * ```typescript
17
- * const message = createVersionMessage(
18
- * VersionMessageType.MajorIncompatibility,
19
- * '3.0.0',
20
- * '2.1.0'
21
- * );
22
- * // Returns: "Requested major version 3.0.0 is greater than the latest major version 2.1.0"
23
- * ```
24
- *
25
- * @example
26
- * ```typescript
27
- * const message = createVersionMessage(
28
- * VersionMessageType.MinorMismatch,
29
- * '2.1.0',
30
- * '2.2.0'
31
- * );
32
- * // Returns: "Minor version mismatch, requested 2.1.0, latest 2.2.0"
33
- * ```
34
- */
35
- export const createVersionMessage = (
36
- type: VersionMessageType,
37
- requestedVersion: string | SemVer,
38
- latestVersion: string | SemVer,
39
- ): string => {
40
- // Convert versions to strings for consistent formatting
41
- const requestedVersionString = String(requestedVersion);
42
- const latestVersionString = String(latestVersion);
43
- switch (type) {
44
- case VersionMessageType.MajorIncompatibility:
45
- return `Requested major version ${requestedVersionString} is greater than the latest major version ${latestVersionString}`;
46
- case VersionMessageType.InvalidVersion:
47
- return `Invalid version ${requestedVersionString}`;
48
- case VersionMessageType.InvalidLatestVersion:
49
- return `Failed to parse latest version "${latestVersionString}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`;
50
- case VersionMessageType.MinorMismatch:
51
- return `Minor version mismatch, requested ${requestedVersionString}, latest ${latestVersionString}`;
52
- case VersionMessageType.PatchDifference:
53
- return `Patch version difference, requested ${requestedVersionString}, latest ${latestVersionString}`;
54
- case VersionMessageType.IncompatibleVersion:
55
- return `Incompatible version, requested ${requestedVersionString}, latest ${latestVersionString}`;
56
- default:
57
- return createVersionMessage(
58
- VersionMessageType.IncompatibleVersion,
59
- requestedVersion,
60
- latestVersion,
61
- );
62
- }
63
- };
@@ -1,8 +0,0 @@
1
- export enum VersionMessageType {
2
- MajorIncompatibility = 'major-incompatibility',
3
- MinorMismatch = 'minor-mismatch',
4
- PatchDifference = 'patch-difference',
5
- InvalidVersion = 'invalid-version',
6
- InvalidLatestVersion = 'invalid-latest-version',
7
- IncompatibleVersion = 'incompatible-version',
8
- }