@visualautomate/plugin-sdk 0.7.0 → 0.8.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.
package/dist/index.d.ts CHANGED
@@ -15,5 +15,5 @@ export * from "./simulate";
15
15
  export * from "./validate";
16
16
  export * from "./runtime";
17
17
  export { BLOCKED_GLOBAL_NAMES, MAX_CODE_LENGTH, PLATFORM_NODE_MAJOR, PROVIDED_GLOBALS, PUSH_CHECK, RETIRED_TIERS, SANDBOX_OVERRIDES, SANDBOX_TIERS, SIGNED_URL_SECONDS, STATE_LIMITS, } from "./platform-rules";
18
- export { checkManifest, type ManifestCheck, type StepKind } from "./manifest-check";
18
+ export { ACCOUNTS_ARE_OURS, accountUseIn, checkManifest, type ManifestCheck, type StepKind } from "./manifest-check";
19
19
  export { CONTEXT_API, BLOCKED_GLOBALS, type ContextApiEntry } from "./context-api";
package/dist/index.mjs CHANGED
@@ -1619,6 +1619,23 @@ var MAX_PAGES = 50;
1619
1619
  var MAX_MEMORY_MB = 128;
1620
1620
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1621
1621
  var isRelativePath = (path) => typeof path === "string" && path.trim() !== "" && !/^[a-z][a-z0-9+.-]*:/i.test(path) && !path.startsWith("//");
1622
+ var ACCOUNTS_ARE_OURS = `Only VisualAutomate's own apps act as a connected account: call the API at its own address instead (action.baseUrl, or fetch in code), with a key the user enters in a property of type "secret"`;
1623
+ function accountUseIn(manifest) {
1624
+ if (!isObject(manifest)) return [];
1625
+ const m = manifest;
1626
+ const uses = [];
1627
+ if (isObject(m.properties)) {
1628
+ for (const [key, value] of Object.entries(m.properties)) {
1629
+ if (!isObject(value)) continue;
1630
+ if (value.type === "connection") uses.push(`properties.${key} is a connection: an account to act as`);
1631
+ if (value.optionsFrom !== void 0) uses.push(`properties.${key}.optionsFrom reads its options as an account`);
1632
+ }
1633
+ }
1634
+ if (isObject(m.action) && m.action.connection !== void 0) uses.push("action.connection makes the call as an account");
1635
+ if (m.trigger !== void 0) uses.push("trigger watches an account");
1636
+ if (isObject(m.auth) && typeof m.auth.provider === "string" && m.auth.provider) uses.push(`auth.provider names "${m.auth.provider}"`);
1637
+ return uses;
1638
+ }
1622
1639
  function checkManifest(raw, hasCode) {
1623
1640
  const errors = [];
1624
1641
  const warnings = [];
@@ -1660,6 +1677,8 @@ function checkManifest(raw, hasCode) {
1660
1677
  else {
1661
1678
  if (typeof m.auth.type !== "string" || !AUTH_TYPES.has(m.auth.type)) {
1662
1679
  errors.push(`auth.type must be one of ${[...AUTH_TYPES].join(", ")}.`);
1680
+ } else if (m.auth.type !== "none" && !m.auth.provider) {
1681
+ errors.push(`auth.type "${m.auth.type}" needs a provider to sign in to, and only VisualAutomate's own apps name one: use { "type": "none" } and take the user's key in a property of type "secret".`);
1663
1682
  }
1664
1683
  for (const key of HOST_KEYS) {
1665
1684
  if (key in m.auth) errors.push(`auth.${key} is refused: a manifest may not name a host. The provider's base URL belongs to the platform.`);
@@ -1693,6 +1712,7 @@ function checkManifest(raw, hasCode) {
1693
1712
  if (kind === "code" && !hasCode) {
1694
1713
  errors.push("There is no index.js and no action or trigger block, so this step has nothing to run.");
1695
1714
  }
1715
+ for (const use of accountUseIn(m)) errors.push(`${use}. ${ACCOUNTS_ARE_OURS}`);
1696
1716
  return { ok: errors.length === 0, kind, errors, warnings };
1697
1717
  }
1698
1718
  function checkConnectionName(where, name, typeOf, errors) {
@@ -1906,6 +1926,7 @@ var BLOCKED_GLOBALS = [
1906
1926
  { name: "__dirname", instead: "There is no meaningful filesystem." }
1907
1927
  ];
1908
1928
  export {
1929
+ ACCOUNTS_ARE_OURS,
1909
1930
  ALLOWED_PACKAGES,
1910
1931
  ALLOWED_PACKAGE_NAMES,
1911
1932
  BLOCKED_GLOBALS,
@@ -1921,6 +1942,7 @@ export {
1921
1942
  SANDBOX_TIERS,
1922
1943
  SIGNED_URL_SECONDS,
1923
1944
  STATE_LIMITS,
1945
+ accountUseIn,
1924
1946
  checkManifest,
1925
1947
  createLocalState,
1926
1948
  createLocalStorage,