@finos/sail-env 0.0.0-stage → 3.0.0-beta.1

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.
package/README.md CHANGED
@@ -1,3 +1,62 @@
1
- # Temporary Holding Version
1
+ # `@finos/sail-env`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Tiny shared helpers so Sail host shells (`sail-finance`, `sail-one`, `sail-v2-web`, …) read the
4
+ **same URL query params and Vite env keys** when they boot a Desktop Agent.
5
+
6
+ This package does not talk to FDC3, open apps, or configure the conformance toolbox. It only
7
+ parses strings and exports one constant.
8
+
9
+ ## Documentation
10
+
11
+ [fdc3-sail.finos.org/docs/packages/sail-env/overview](https://fdc3-sail.finos.org/docs/packages/sail-env/overview)
12
+
13
+ ## What it exports
14
+
15
+ | Export | Role |
16
+ |--------|------|
17
+ | `SAIL_MAX_FDC3_VERSION` | `"3.0"` — value hosts pass as advertised max wire version to `SailDesktopAgent` |
18
+ | `resolveDeepLinkAppId(search)` | `?appId=` → open that directory app after start |
19
+ | `resolveFdc3Directory(search)` | `?fdc3Directory=` → sole App Directory URL from the query |
20
+ | `resolveNoSplash(search)` | `?noSplash=1` / `true` → hide splash / welcome chrome |
21
+ | `resolveFdc3DirectoryUrl(raw)` | Non-empty check for `VITE_FDC3_DIRECTORY_URL` |
22
+ | `isAutoResolve(raw)` | `VITE_AUTO_RESOLVE === "1"` → programmatic intent pick |
23
+ | `resolveSoleFdc3Directory({ search, viteDirectoryUrl })` | Query `fdc3Directory` wins over Vite env |
24
+
25
+ Vite host typings:
26
+
27
+ ```ts
28
+ /// <reference types="@finos/sail-env/vite" />
29
+ ```
30
+
31
+ Declares `import.meta.env.VITE_FDC3_DIRECTORY_URL` and `VITE_AUTO_RESOLVE`.
32
+
33
+ ## Typical host usage
34
+
35
+ ```ts
36
+ import {
37
+ SAIL_MAX_FDC3_VERSION,
38
+ isAutoResolve,
39
+ resolveDeepLinkAppId,
40
+ resolveSoleFdc3Directory,
41
+ } from "@finos/sail-env"
42
+
43
+ const soleDirectoryUrl = resolveSoleFdc3Directory({
44
+ search: window.location.search,
45
+ viteDirectoryUrl: import.meta.env.VITE_FDC3_DIRECTORY_URL,
46
+ })
47
+ const autoResolve = isAutoResolve(import.meta.env.VITE_AUTO_RESOLVE)
48
+ const deepLinkAppId = resolveDeepLinkAppId(window.location.search)
49
+
50
+ // then: construct SailDesktopAgent with maxFdc3Version: SAIL_MAX_FDC3_VERSION,
51
+ // optional sole directory, auto-resolve intent UI, and deep-link open
52
+ ```
53
+
54
+ Example URL:
55
+
56
+ ```
57
+ /?appId=Conformance1&fdc3Directory=https://example.com/apps.json&noSplash=1
58
+ ```
59
+
60
+ ## License
61
+
62
+ Copyright 2025–2026 FINOS. Distributed under the Apache 2.0 License.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Shared Sail host helpers: URL query params, Vite env strings, and the
3
+ * advertised max FDC3 wire version constant. No FDC3 protocol logic.
4
+ */
5
+ /** Advertised maximum FDC3 API version Sail Desktop Agents support. */
6
+ export declare const SAIL_MAX_FDC3_VERSION: "3.0";
7
+ export type SailMaxFdc3Version = typeof SAIL_MAX_FDC3_VERSION;
8
+ /**
9
+ * Deep-link app id from a query string (`?appId=…`).
10
+ */
11
+ export declare function resolveDeepLinkAppId(search: string | URLSearchParams): string | undefined;
12
+ /**
13
+ * Optional sole App Directory URL (`?fdc3Directory=https://…`).
14
+ * When set, hosts should use this directory only.
15
+ */
16
+ export declare function resolveFdc3Directory(search: string | URLSearchParams): string | undefined;
17
+ /**
18
+ * Suppress splash / welcome chrome when `?noSplash=1` or `true`.
19
+ */
20
+ export declare function resolveNoSplash(search: string | URLSearchParams): boolean;
21
+ /**
22
+ * Read `VITE_FDC3_DIRECTORY_URL` (or any raw string from the host).
23
+ */
24
+ export declare function resolveFdc3DirectoryUrl(raw?: string | null): string | undefined;
25
+ /**
26
+ * True when `VITE_AUTO_RESOLVE` / equivalent is `"1"` (programmatic intent pick).
27
+ */
28
+ export declare function isAutoResolve(raw?: string | null): boolean;
29
+ /**
30
+ * Effective sole App Directory: query `fdc3Directory` wins over Vite env.
31
+ */
32
+ export declare function resolveSoleFdc3Directory(options?: {
33
+ search?: string | URLSearchParams;
34
+ viteDirectoryUrl?: string | null;
35
+ }): string | undefined;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,EAAG,KAAc,CAAA;AAEnD,MAAM,MAAM,kBAAkB,GAAG,OAAO,qBAAqB,CAAA;AAM7D;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAGzF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,MAAM,GAAG,SAAS,CAGzF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,OAAO,CAGzE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAE/E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,GAAG,MAAM,GAAG,SAAS,CAGrB"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Shared Sail host helpers: URL query params, Vite env strings, and the
3
+ * advertised max FDC3 wire version constant. No FDC3 protocol logic.
4
+ */
5
+ /** Advertised maximum FDC3 API version Sail Desktop Agents support. */
6
+ export const SAIL_MAX_FDC3_VERSION = "3.0";
7
+ function toSearchParams(search) {
8
+ return typeof search === "string" ? new URLSearchParams(search) : search;
9
+ }
10
+ /**
11
+ * Deep-link app id from a query string (`?appId=…`).
12
+ */
13
+ export function resolveDeepLinkAppId(search) {
14
+ const appId = toSearchParams(search).get("appId");
15
+ return appId && appId.length > 0 ? appId : undefined;
16
+ }
17
+ /**
18
+ * Optional sole App Directory URL (`?fdc3Directory=https://…`).
19
+ * When set, hosts should use this directory only.
20
+ */
21
+ export function resolveFdc3Directory(search) {
22
+ const url = toSearchParams(search).get("fdc3Directory");
23
+ return url && url.length > 0 ? url : undefined;
24
+ }
25
+ /**
26
+ * Suppress splash / welcome chrome when `?noSplash=1` or `true`.
27
+ */
28
+ export function resolveNoSplash(search) {
29
+ const raw = toSearchParams(search).get("noSplash");
30
+ return raw === "1" || raw === "true";
31
+ }
32
+ /**
33
+ * Read `VITE_FDC3_DIRECTORY_URL` (or any raw string from the host).
34
+ */
35
+ export function resolveFdc3DirectoryUrl(raw) {
36
+ return raw && raw.length > 0 ? raw : undefined;
37
+ }
38
+ /**
39
+ * True when `VITE_AUTO_RESOLVE` / equivalent is `"1"` (programmatic intent pick).
40
+ */
41
+ export function isAutoResolve(raw) {
42
+ return raw === "1";
43
+ }
44
+ /**
45
+ * Effective sole App Directory: query `fdc3Directory` wins over Vite env.
46
+ */
47
+ export function resolveSoleFdc3Directory(options) {
48
+ const fromQuery = options?.search ? resolveFdc3Directory(options.search) : undefined;
49
+ return fromQuery ?? resolveFdc3DirectoryUrl(options?.viteDirectoryUrl);
50
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from "vite-plus/test";
2
+ import { isAutoResolve, resolveDeepLinkAppId, resolveFdc3Directory, resolveNoSplash, resolveSoleFdc3Directory, } from "./index.js";
3
+ describe("sail-env query helpers", () => {
4
+ it("resolves appId", () => {
5
+ expect(resolveDeepLinkAppId("?appId=Conformance1")).toBe("Conformance1");
6
+ expect(resolveDeepLinkAppId("?")).toBeUndefined();
7
+ });
8
+ it("resolves fdc3Directory", () => {
9
+ expect(resolveFdc3Directory("?fdc3Directory=https://example.com/apps.json")).toBe("https://example.com/apps.json");
10
+ expect(resolveFdc3Directory("?conformanceDirectory=https://x")).toBeUndefined();
11
+ });
12
+ it("resolves noSplash", () => {
13
+ expect(resolveNoSplash("?noSplash=1")).toBe(true);
14
+ expect(resolveNoSplash("?noSplash=true")).toBe(true);
15
+ expect(resolveNoSplash("?noSplash=0")).toBe(false);
16
+ });
17
+ it("prefers query directory over Vite env", () => {
18
+ expect(resolveSoleFdc3Directory({
19
+ search: "?fdc3Directory=https://query.example/a.json",
20
+ viteDirectoryUrl: "https://env.example/b.json",
21
+ })).toBe("https://query.example/a.json");
22
+ expect(resolveSoleFdc3Directory({
23
+ search: "?",
24
+ viteDirectoryUrl: "https://env.example/b.json",
25
+ })).toBe("https://env.example/b.json");
26
+ });
27
+ it("isAutoResolve", () => {
28
+ expect(isAutoResolve("1")).toBe(true);
29
+ expect(isAutoResolve("0")).toBe(false);
30
+ });
31
+ });
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@finos/sail-env",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "3.0.0-beta.1",
4
+ "description": "Shared Sail host URL query and Vite env helpers (appId, fdc3Directory, auto-resolve, SAIL_MAX_FDC3_VERSION).",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/finos/FDC3-Sail",
7
+ "repository": "github:finos/FDC3-Sail",
8
+ "bugs": "https://github.com/finos/FDC3-Sail/issues",
9
+ "type": "module",
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./vite": "./vite.d.ts"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "vite.d.ts"
24
+ ],
25
+ "scripts": {
26
+ "clean": "rimraf dist",
27
+ "build": "tsc",
28
+ "typecheck": "tsc --noEmit",
29
+ "test": "vp test run",
30
+ "lint": "vp lint ."
31
+ },
32
+ "devDependencies": {
33
+ "rimraf": "^6.0.1",
34
+ "typescript": "^5.8.2"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "tag": "beta"
39
+ }
40
+ }
package/vite.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared Vite `ImportMetaEnv` keys for Sail Desktop Agent hosts.
3
+ * Host packages: `/// <reference types="@finos/sail-env/vite" />`
4
+ */
5
+ interface ImportMetaEnv {
6
+ /** Sole App Directory URL when set (CI / deep-link). */
7
+ readonly VITE_FDC3_DIRECTORY_URL?: string
8
+ /** `"1"` → programmatic intent resolution (no UI). */
9
+ readonly VITE_AUTO_RESOLVE?: string
10
+ }
11
+
12
+ interface ImportMeta {
13
+ readonly env: ImportMetaEnv
14
+ }