@geekmidas/manifest 10.0.0-alpha.198 → 10.0.0-alpha.199

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/dist/index.cjs CHANGED
@@ -928,9 +928,41 @@ function mapsRolesFor(kind) {
928
928
  if (kind === "mobile-app") return ["androidKey", "iosKey"];
929
929
  return ["apiKey"];
930
930
  }
931
- /** The keys a caller of `kind` is handed of the `Maps` construct `id`. */
932
- function mapsKeysFor(id, kind) {
933
- return mapsRolesFor(kind).map((role) => providedKeyFor(id, "maps", role));
931
+ /** Between a role's name and the caller a stored key is its: `_`. */
932
+ const CALLER_SEPARATOR = "_";
933
+ /**
934
+ * Where the stage's secrets keep the key `caller` holds of the `Maps`
935
+ * construct `maps` in `role` — `MAPS_BROWSER_KEY_WEB` for the site `Web`.
936
+ */
937
+ function mapsKeyOf(maps, role, caller) {
938
+ return `${providedKeyFor(maps, "maps", role)}${CALLER_SEPARATOR}${environmentCase(caller)}`;
939
+ }
940
+ /** The role `key` names of the `Maps` construct `maps`, as its callers read it. */
941
+ function mapsRoleOf(maps, key) {
942
+ return MAPS_ROLES.find((role) => providedKeyFor(maps, "maps", role) === key);
943
+ }
944
+ /**
945
+ * The caller `key` keeps a key of the `Maps` construct `maps` for — `Web` of
946
+ * `MAPS_BROWSER_KEY_WEB` — read against each role's name exactly: the rest
947
+ * after it and one `_`, never a split on underscores. `undefined` for a key
948
+ * that is no caller's, in its environment case (`WEB`, `ADMIN_APP`).
949
+ */
950
+ function mapsCallerOf(maps, key) {
951
+ for (const role of MAPS_ROLES) {
952
+ const prefix = `${providedKeyFor(maps, "maps", role)}${CALLER_SEPARATOR}`;
953
+ if (key.startsWith(prefix) && key.length > prefix.length) return {
954
+ role,
955
+ caller: key.slice(prefix.length)
956
+ };
957
+ }
958
+ }
959
+ /**
960
+ * Whether `key` is where a caller's own key of one of the manifest's `Maps`
961
+ * constructs is kept — a value only that caller is handed, under the role's
962
+ * name, and never a stage key every process reads.
963
+ */
964
+ function isMapsCallerKey(manifest, key) {
965
+ return Object.values(manifest).some((declaration) => declaration.kind === "maps" && mapsCallerOf(declaration.id, key) !== void 0);
934
966
  }
935
967
  //#endregion
936
968
  //#region src/derive.ts
@@ -1026,22 +1058,6 @@ function dependentsOf(manifest, id) {
1026
1058
  return callers.sort();
1027
1059
  }
1028
1060
  /**
1029
- * The keys of the `Maps` construct `id` its callers hold, by role — the
1030
- * graph read backwards, as an API's trusted origins are: a server process
1031
- * that depends on it is why there is a server key, a site why there is a
1032
- * browser key, a mobile app why there are an Android and an iOS key. Each
1033
- * role lists its callers, sorted; a role nobody holds is absent.
1034
- */
1035
- function mapsCallers(manifest, id) {
1036
- const callers = {};
1037
- for (const caller of dependentsOf(manifest, id)) {
1038
- const kind = manifest[caller]?.kind;
1039
- if (!kind) continue;
1040
- for (const role of mapsRolesFor(kind)) callers[role] = [...callers[role] ?? [], caller];
1041
- }
1042
- return callers;
1043
- }
1044
- /**
1045
1061
  * How each site variant names a value it ships to the browser.
1046
1062
  *
1047
1063
  * The prefix *is* the framework's contract — `VITE_`, `NEXT_PUBLIC_` and
@@ -1802,13 +1818,15 @@ exports.inboxDomain = inboxDomain;
1802
1818
  exports.inboxRecipient = inboxRecipient;
1803
1819
  exports.isDerived = isDerived;
1804
1820
  exports.isHostedDeclaration = isHostedDeclaration;
1821
+ exports.isMapsCallerKey = isMapsCallerKey;
1805
1822
  exports.isPublicDeclaration = isPublicDeclaration;
1806
1823
  exports.isWebOrigin = isWebOrigin;
1807
1824
  exports.isWildcardSite = isWildcardSite;
1808
1825
  exports.kebabCase = kebabCase;
1809
1826
  exports.kmsUrl = kmsUrl;
1810
- exports.mapsCallers = mapsCallers;
1811
- exports.mapsKeysFor = mapsKeysFor;
1827
+ exports.mapsCallerOf = mapsCallerOf;
1828
+ exports.mapsKeyOf = mapsKeyOf;
1829
+ exports.mapsRoleOf = mapsRoleOf;
1812
1830
  exports.mapsRolesFor = mapsRolesFor;
1813
1831
  exports.migrationFolder = migrationFolder;
1814
1832
  exports.migrationTargets = migrationTargets;