@aidc-toolkit/core 1.0.34-beta → 1.0.36-beta

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.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Alpha base URL. Reads from local application storage, path "config", key "resources.local", if present, otherwise
3
+ * defaults to the Vite server URL.
4
+ */
5
+ export declare const ALPHA_BASE_URL: Promise<string>;
6
+ /**
7
+ * AIDC Toolkit base URL.
8
+ */
9
+ export declare const AIDC_TOOLKIT_BASE_URL = "https://aidc-toolkit.com";
10
+ /**
11
+ * Determine the base URL for the phase based on the package version.
12
+ *
13
+ * @param version
14
+ * Package version.
15
+ *
16
+ * @param alphaBaseURL
17
+ * Alpha base URL.
18
+ *
19
+ * @param nonAlphaRelativeURL
20
+ * Non-alpha URL, relative to non-alpha base URL and optionally the pre-release identifier and version.
21
+ *
22
+ * @returns
23
+ * Fully-formed base URL for the phase.
24
+ */
25
+ export declare function baseURL(version: string, alphaBaseURL: string, nonAlphaRelativeURL?: string): string;
26
+ //# sourceMappingURL=base-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url.d.ts","sourceRoot":"","sources":["../src/base-url.ts"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,eAAO,MAAM,cAAc,iBAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBnG"}
@@ -0,0 +1,62 @@
1
+ import { LocalAppDataStorage } from "./local-app-data-storage.js";
2
+ import { parseVersion } from "./parse-version.js";
3
+ /**
4
+ * Default alpha URL (Vite development URL) if no local resources file is found.
5
+ */
6
+ const DEFAULT_ALPHA_BASE_URL = "http://localhost:5173";
7
+ /**
8
+ * Configuration path, expected to be present in development but not necessarily in production.
9
+ */
10
+ const CONFIGURATION_PATH = "config";
11
+ /**
12
+ * Key to local resources, expected to be present in development but not necessarily in production.
13
+ */
14
+ const LOCAL_RESOURCES_KEY = "resources.local";
15
+ /**
16
+ * Alpha base URL. Reads from local application storage, path "config", key "resources.local", if present, otherwise
17
+ * defaults to the Vite server URL.
18
+ */
19
+ export const ALPHA_BASE_URL = LocalAppDataStorage.then(async (LocalAppDataStorage) => new LocalAppDataStorage(CONFIGURATION_PATH).read(LOCAL_RESOURCES_KEY)).then(resources =>
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Fallback works regardless of type.
21
+ resources?.alphaBaseURL ?? DEFAULT_ALPHA_BASE_URL);
22
+ /**
23
+ * AIDC Toolkit base URL.
24
+ */
25
+ export const AIDC_TOOLKIT_BASE_URL = "https://aidc-toolkit.com";
26
+ /**
27
+ * Determine the base URL for the phase based on the package version.
28
+ *
29
+ * @param version
30
+ * Package version.
31
+ *
32
+ * @param alphaBaseURL
33
+ * Alpha base URL.
34
+ *
35
+ * @param nonAlphaRelativeURL
36
+ * Non-alpha URL, relative to non-alpha base URL and optionally the pre-release identifier and version.
37
+ *
38
+ * @returns
39
+ * Fully-formed base URL for the phase.
40
+ */
41
+ export function baseURL(version, alphaBaseURL, nonAlphaRelativeURL) {
42
+ const parsedVersion = parseVersion(version);
43
+ const preReleaseIdentifier = parsedVersion.preReleaseIdentifier;
44
+ let url;
45
+ if (preReleaseIdentifier === "alpha") {
46
+ // Alpha base URL is absolute.
47
+ url = alphaBaseURL;
48
+ }
49
+ else {
50
+ const relativeURL = nonAlphaRelativeURL !== undefined && nonAlphaRelativeURL !== "" ? `/${nonAlphaRelativeURL}` : "";
51
+ if (preReleaseIdentifier !== undefined) {
52
+ // Non-alpha base URL is relative to AIDC Toolkit base URL plus pre-release identifier and version.
53
+ url = `${AIDC_TOOLKIT_BASE_URL}/${preReleaseIdentifier}/v${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${relativeURL}`;
54
+ }
55
+ else {
56
+ // Production base URL is relative to AIDC Toolkit base URL.
57
+ url = `${AIDC_TOOLKIT_BASE_URL}${relativeURL}`;
58
+ }
59
+ }
60
+ return url;
61
+ }
62
+ //# sourceMappingURL=base-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-url.js","sourceRoot":"","sources":["../src/base-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAEvD;;GAEG;AACH,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAS9C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAC,mBAAmB,EAAC,EAAE,CAC/E,IAAI,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CACxE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;AACf,6GAA6G;AAC5G,SAA0C,EAAE,YAAY,IAAI,sBAAsB,CACtF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe,EAAE,YAAoB,EAAE,mBAA4B;IACvF,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,oBAAoB,GAAG,aAAa,CAAC,oBAAoB,CAAC;IAEhE,IAAI,GAAW,CAAC;IAEhB,IAAI,oBAAoB,KAAK,OAAO,EAAE,CAAC;QACnC,8BAA8B;QAC9B,GAAG,GAAG,YAAY,CAAC;IACvB,CAAC;SAAM,CAAC;QACJ,MAAM,WAAW,GAAG,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAErH,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACrC,mGAAmG;YACnG,GAAG,GAAG,GAAG,qBAAqB,IAAI,oBAAoB,KAAK,aAAa,CAAC,YAAY,IAAI,aAAa,CAAC,YAAY,GAAG,WAAW,EAAE,CAAC;QACxI,CAAC;aAAM,CAAC;YACJ,4DAA4D;YAC5D,GAAG,GAAG,GAAG,qBAAqB,GAAG,WAAW,EAAE,CAAC;QACnD,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export type * from "./type.js";
18
18
  export * from "./type-helper.js";
19
19
  export * from "./logger.js";
20
20
  export * from "./parse-version.js";
21
- export * from "./phase-url.js";
21
+ export * from "./base-url.js";
22
22
  export * from "./app-data.js";
23
23
  export * from "./app-data-storage.js";
24
24
  export * from "./local-app-data-storage.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mBAAmB,WAAW,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAE3B,mBAAmB,gBAAgB,CAAC;AAEpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mBAAmB,WAAW,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAE3B,mBAAmB,gBAAgB,CAAC;AAEpC,cAAc,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@
17
17
  export * from "./type-helper.js";
18
18
  export * from "./logger.js";
19
19
  export * from "./parse-version.js";
20
- export * from "./phase-url.js";
20
+ export * from "./base-url.js";
21
21
  export * from "./app-data.js";
22
22
  export * from "./app-data-storage.js";
23
23
  export * from "./local-app-data-storage.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAI3B,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,kBAAkB,CAAC;AAEjC,cAAc,aAAa,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAI3B,cAAc,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aidc-toolkit/core",
3
- "version": "1.0.34-beta",
3
+ "version": "1.0.36-beta",
4
4
  "description": "Core functionality for AIDC Toolkit",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "build:doc": "npm run build:non-prod"
29
29
  },
30
30
  "devDependencies": {
31
- "@aidc-toolkit/dev": "1.0.34-beta"
31
+ "@aidc-toolkit/dev": "1.0.35-beta"
32
32
  },
33
33
  "dependencies": {
34
34
  "base64-js": "^1.5.1",
@@ -0,0 +1,79 @@
1
+ import { LocalAppDataStorage } from "./local-app-data-storage.js";
2
+ import { parseVersion } from "./parse-version.js";
3
+
4
+ /**
5
+ * Default alpha URL (Vite development URL) if no local resources file is found.
6
+ */
7
+ const DEFAULT_ALPHA_BASE_URL = "http://localhost:5173";
8
+
9
+ /**
10
+ * Configuration path, expected to be present in development but not necessarily in production.
11
+ */
12
+ const CONFIGURATION_PATH = "config";
13
+
14
+ /**
15
+ * Key to local resources, expected to be present in development but not necessarily in production.
16
+ */
17
+ const LOCAL_RESOURCES_KEY = "resources.local";
18
+
19
+ /**
20
+ * Local resources.
21
+ */
22
+ interface LocalResources {
23
+ alphaBaseURL: string;
24
+ }
25
+
26
+ /**
27
+ * Alpha base URL. Reads from local application storage, path "config", key "resources.local", if present, otherwise
28
+ * defaults to the Vite server URL.
29
+ */
30
+ export const ALPHA_BASE_URL = LocalAppDataStorage.then(async LocalAppDataStorage =>
31
+ new LocalAppDataStorage(CONFIGURATION_PATH).read(LOCAL_RESOURCES_KEY)
32
+ ).then(resources =>
33
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Fallback works regardless of type.
34
+ (resources as (LocalResources | undefined))?.alphaBaseURL ?? DEFAULT_ALPHA_BASE_URL
35
+ );
36
+
37
+ /**
38
+ * AIDC Toolkit base URL.
39
+ */
40
+ export const AIDC_TOOLKIT_BASE_URL = "https://aidc-toolkit.com";
41
+
42
+ /**
43
+ * Determine the base URL for the phase based on the package version.
44
+ *
45
+ * @param version
46
+ * Package version.
47
+ *
48
+ * @param alphaBaseURL
49
+ * Alpha base URL.
50
+ *
51
+ * @param nonAlphaRelativeURL
52
+ * Non-alpha URL, relative to non-alpha base URL and optionally the pre-release identifier and version.
53
+ *
54
+ * @returns
55
+ * Fully-formed base URL for the phase.
56
+ */
57
+ export function baseURL(version: string, alphaBaseURL: string, nonAlphaRelativeURL?: string): string {
58
+ const parsedVersion = parseVersion(version);
59
+ const preReleaseIdentifier = parsedVersion.preReleaseIdentifier;
60
+
61
+ let url: string;
62
+
63
+ if (preReleaseIdentifier === "alpha") {
64
+ // Alpha base URL is absolute.
65
+ url = alphaBaseURL;
66
+ } else {
67
+ const relativeURL = nonAlphaRelativeURL !== undefined && nonAlphaRelativeURL !== "" ? `/${nonAlphaRelativeURL}` : "";
68
+
69
+ if (preReleaseIdentifier !== undefined) {
70
+ // Non-alpha base URL is relative to AIDC Toolkit base URL plus pre-release identifier and version.
71
+ url = `${AIDC_TOOLKIT_BASE_URL}/${preReleaseIdentifier}/v${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${relativeURL}`;
72
+ } else {
73
+ // Production base URL is relative to AIDC Toolkit base URL.
74
+ url = `${AIDC_TOOLKIT_BASE_URL}${relativeURL}`;
75
+ }
76
+ }
77
+
78
+ return url;
79
+ }
package/src/index.ts CHANGED
@@ -21,7 +21,7 @@ export * from "./type-helper.js";
21
21
  export * from "./logger.js";
22
22
 
23
23
  export * from "./parse-version.js";
24
- export * from "./phase-url.js";
24
+ export * from "./base-url.js";
25
25
 
26
26
  export * from "./app-data.js";
27
27
  export * from "./app-data-storage.js";
@@ -1,17 +0,0 @@
1
- /**
2
- * Get the URL for the phase as determined by the package version.
3
- *
4
- * @param version
5
- * Package version.
6
- *
7
- * @param alphaURL
8
- * Alpha URL.
9
- *
10
- * @param nonAlphaRelativeURL
11
- * Non-alpha URL, relative to non-alpha base URL plus optionally the pre-release identifier and version.
12
- *
13
- * @returns
14
- * Fully-formed URL for the phase.
15
- */
16
- export declare function phaseURL(version: string, alphaURL: string, nonAlphaRelativeURL?: string): string;
17
- //# sourceMappingURL=phase-url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phase-url.d.ts","sourceRoot":"","sources":["../src/phase-url.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAsBhG"}
package/dist/phase-url.js DELETED
@@ -1,39 +0,0 @@
1
- import { parseVersion } from "./parse-version.js";
2
- const NON_ALPHA_BASE_URL = "https://aidc-toolkit.com";
3
- /**
4
- * Get the URL for the phase as determined by the package version.
5
- *
6
- * @param version
7
- * Package version.
8
- *
9
- * @param alphaURL
10
- * Alpha URL.
11
- *
12
- * @param nonAlphaRelativeURL
13
- * Non-alpha URL, relative to non-alpha base URL plus optionally the pre-release identifier and version.
14
- *
15
- * @returns
16
- * Fully-formed URL for the phase.
17
- */
18
- export function phaseURL(version, alphaURL, nonAlphaRelativeURL) {
19
- const parsedVersion = parseVersion(version);
20
- const preReleaseIdentifier = parsedVersion.preReleaseIdentifier;
21
- let url;
22
- if (preReleaseIdentifier === "alpha") {
23
- // Alpha URL is absolute.
24
- url = alphaURL;
25
- }
26
- else {
27
- const relativeURL = nonAlphaRelativeURL !== undefined && nonAlphaRelativeURL !== "" ? `/${nonAlphaRelativeURL}` : "";
28
- if (preReleaseIdentifier !== undefined) {
29
- // Non-alpha URL is relative to non-alpha base URL plus pre-release identifier and version.
30
- url = `${NON_ALPHA_BASE_URL}/${preReleaseIdentifier}/v${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${relativeURL}`;
31
- }
32
- else {
33
- // Production URL is relative to non-alpha base URL.
34
- url = `${NON_ALPHA_BASE_URL}${relativeURL}`;
35
- }
36
- }
37
- return url;
38
- }
39
- //# sourceMappingURL=phase-url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"phase-url.js","sourceRoot":"","sources":["../src/phase-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,QAAgB,EAAE,mBAA4B;IACpF,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,oBAAoB,GAAG,aAAa,CAAC,oBAAoB,CAAC;IAEhE,IAAI,GAAW,CAAC;IAEhB,IAAI,oBAAoB,KAAK,OAAO,EAAE,CAAC;QACnC,yBAAyB;QACzB,GAAG,GAAG,QAAQ,CAAC;IACnB,CAAC;SAAM,CAAC;QACJ,MAAM,WAAW,GAAG,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAErH,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;YACrC,2FAA2F;YAC3F,GAAG,GAAG,GAAG,kBAAkB,IAAI,oBAAoB,KAAK,aAAa,CAAC,YAAY,IAAI,aAAa,CAAC,YAAY,GAAG,WAAW,EAAE,CAAC;QACrI,CAAC;aAAM,CAAC;YACJ,oDAAoD;YACpD,GAAG,GAAG,GAAG,kBAAkB,GAAG,WAAW,EAAE,CAAC;QAChD,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC"}
package/src/phase-url.ts DELETED
@@ -1,42 +0,0 @@
1
- import { parseVersion } from "./parse-version.js";
2
-
3
- const NON_ALPHA_BASE_URL = "https://aidc-toolkit.com";
4
-
5
- /**
6
- * Get the URL for the phase as determined by the package version.
7
- *
8
- * @param version
9
- * Package version.
10
- *
11
- * @param alphaURL
12
- * Alpha URL.
13
- *
14
- * @param nonAlphaRelativeURL
15
- * Non-alpha URL, relative to non-alpha base URL plus optionally the pre-release identifier and version.
16
- *
17
- * @returns
18
- * Fully-formed URL for the phase.
19
- */
20
- export function phaseURL(version: string, alphaURL: string, nonAlphaRelativeURL?: string): string {
21
- const parsedVersion = parseVersion(version);
22
- const preReleaseIdentifier = parsedVersion.preReleaseIdentifier;
23
-
24
- let url: string;
25
-
26
- if (preReleaseIdentifier === "alpha") {
27
- // Alpha URL is absolute.
28
- url = alphaURL;
29
- } else {
30
- const relativeURL = nonAlphaRelativeURL !== undefined && nonAlphaRelativeURL !== "" ? `/${nonAlphaRelativeURL}` : "";
31
-
32
- if (preReleaseIdentifier !== undefined) {
33
- // Non-alpha URL is relative to non-alpha base URL plus pre-release identifier and version.
34
- url = `${NON_ALPHA_BASE_URL}/${preReleaseIdentifier}/v${parsedVersion.majorVersion}.${parsedVersion.minorVersion}${relativeURL}`;
35
- } else {
36
- // Production URL is relative to non-alpha base URL.
37
- url = `${NON_ALPHA_BASE_URL}${relativeURL}`;
38
- }
39
- }
40
-
41
- return url;
42
- }