@sanoma-ai/workflows 0.10.0 → 0.10.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.
Files changed (89) hide show
  1. package/README.md +33 -7
  2. package/SECRET-SUPPORT.md +33 -0
  3. package/dist/apps.d.ts +6 -0
  4. package/dist/apps.js +18 -1
  5. package/dist/apps.js.map +1 -1
  6. package/dist/authentication.d.ts +30 -0
  7. package/dist/authentication.js +71 -1
  8. package/dist/authentication.js.map +1 -1
  9. package/dist/call.js +7 -5
  10. package/dist/call.js.map +1 -1
  11. package/dist/client.d.ts +54 -6
  12. package/dist/client.js +177 -5
  13. package/dist/client.js.map +1 -1
  14. package/dist/config.d.ts +7 -4
  15. package/dist/config.js +44 -12
  16. package/dist/config.js.map +1 -1
  17. package/dist/connection.d.ts +223 -2
  18. package/dist/connection.js +334 -4
  19. package/dist/connection.js.map +1 -1
  20. package/dist/db.js +15 -2
  21. package/dist/db.js.map +1 -1
  22. package/dist/describe.d.ts +8 -0
  23. package/dist/describe.js +51 -1
  24. package/dist/describe.js.map +1 -1
  25. package/dist/direct.js +4 -0
  26. package/dist/direct.js.map +1 -1
  27. package/dist/fake.d.ts +13 -1
  28. package/dist/fake.js +70 -0
  29. package/dist/fake.js.map +1 -1
  30. package/dist/index.d.ts +4 -4
  31. package/dist/index.js +2 -2
  32. package/dist/index.js.map +1 -1
  33. package/dist/lint.js +1 -1
  34. package/dist/lint.js.map +1 -1
  35. package/dist/load.d.ts +11 -0
  36. package/dist/load.js +42 -8
  37. package/dist/load.js.map +1 -1
  38. package/dist/op.d.ts +14 -6
  39. package/dist/op.js +20 -2
  40. package/dist/op.js.map +1 -1
  41. package/dist/outline.d.ts +5 -0
  42. package/dist/outline.js +33 -1
  43. package/dist/outline.js.map +1 -1
  44. package/dist/paths.d.ts +2 -4
  45. package/dist/paths.js +2 -8
  46. package/dist/paths.js.map +1 -1
  47. package/dist/run.d.ts +3 -1
  48. package/dist/run.js.map +1 -1
  49. package/dist/sandbox.d.ts +4 -1
  50. package/dist/sandbox.js +51 -5
  51. package/dist/sandbox.js.map +1 -1
  52. package/dist/scenario.d.ts +5 -0
  53. package/dist/scenario.js +3 -2
  54. package/dist/scenario.js.map +1 -1
  55. package/dist/secret.d.ts +2 -0
  56. package/dist/secret.js +32 -0
  57. package/dist/secret.js.map +1 -1
  58. package/dist/shared.d.ts +4 -0
  59. package/dist/shared.js +7 -0
  60. package/dist/shared.js.map +1 -1
  61. package/dist/sites.js +18 -3
  62. package/dist/sites.js.map +1 -1
  63. package/dist/steps.d.ts +3 -0
  64. package/dist/steps.js.map +1 -1
  65. package/oxlint.json +1 -0
  66. package/package.json +2 -1
  67. package/src/apps.ts +17 -1
  68. package/src/authentication.ts +119 -2
  69. package/src/call.ts +4 -5
  70. package/src/client.ts +240 -6
  71. package/src/config.ts +45 -11
  72. package/src/connection.ts +472 -6
  73. package/src/db.ts +15 -2
  74. package/src/describe.ts +52 -1
  75. package/src/direct.ts +4 -0
  76. package/src/fake.ts +71 -0
  77. package/src/index.ts +12 -1
  78. package/src/lint.ts +1 -1
  79. package/src/load.ts +36 -7
  80. package/src/op.ts +33 -8
  81. package/src/outline.ts +35 -2
  82. package/src/paths.ts +2 -9
  83. package/src/run.ts +3 -1
  84. package/src/sandbox.ts +55 -5
  85. package/src/scenario.ts +24 -6
  86. package/src/secret.ts +29 -0
  87. package/src/shared.ts +9 -0
  88. package/src/sites.ts +19 -3
  89. package/src/steps.ts +3 -2
package/src/sites.ts CHANGED
@@ -7,6 +7,7 @@ import type { ConfigDescription, SiteCall, SiteEntry, SitePage } from "./descrip
7
7
  import { stringValue, unwrap } from "./outline.ts";
8
8
  import { exportsOf, loadModules } from "./load.ts";
9
9
  import { APPS_DIR, appFolders, filesUnder, isDirectory, relPath, SITE_ENTRIES } from "./paths.ts";
10
+ import { isObject } from "./resource.ts";
10
11
  import type { ResourceProblem } from "./resources.ts";
11
12
  import { START } from "./schema.ts";
12
13
  import {
@@ -428,6 +429,9 @@ const SiteDefinitionSchema = z.strictObject({
428
429
  locales: z.array(z.string()).optional(),
429
430
  });
430
431
 
432
+ /** What `site.ts` says of who may see a site: read together or not at all. */
433
+ const ACCESS = ["public", "login", "locales"];
434
+
431
435
  /**
432
436
  * What the site in `dir` (relative to `root`) says of itself in its `site.ts`, loaded
433
437
  * (`loadModules`, `defineSite` served from `sanoma/site`), and what is wrong there: its default
@@ -452,13 +456,25 @@ function siteDefinitionOf(
452
456
  const value = loaded.exports.find(([name]) => name === "default")?.[1];
453
457
  if (value === undefined) return { problems: [] };
454
458
  const problem = (message: string) => ({ file, export: "default", message });
455
- const parsed = SiteDefinitionSchema.safeParse(value);
459
+ const problems: (ResourceProblem & { file: string })[] = [];
460
+ let parsed = SiteDefinitionSchema.safeParse(value);
456
461
  if (!parsed.success) {
457
462
  const why = z.prettifyError(parsed.error).replaceAll(/\s*\n\s*/g, " ");
458
- return { problems: [problem(`its default export is \`defineSite({ … })\` from "sanoma/site": ${why}`)] };
463
+ problems.push(problem(`its default export is \`defineSite({ … })\` from "sanoma/site": ${why}`));
464
+ // The fields it names wrongly (and the keys it does not know) left out, the rest still read:
465
+ // a bad icon keeps a site's `public`, `login` and `locales`. Those three say who may see it,
466
+ // so a wrong one leaves out all three: never a site read as public without its login.
467
+ const wrong = new Set(
468
+ parsed.error.issues.flatMap((i) => (i.code === "unrecognized_keys" ? i.keys : i.path.slice(0, 1))),
469
+ );
470
+ if (ACCESS.some((key) => wrong.has(key))) for (const key of ACCESS) wrong.add(key);
471
+ if (!isObject(value) || !wrong.size) return { problems };
472
+ parsed = SiteDefinitionSchema.safeParse(
473
+ Object.fromEntries(Object.entries(value).filter(([key]) => !wrong.has(key))),
474
+ );
475
+ if (!parsed.success) return { problems };
459
476
  }
460
477
  const { title, icon, public: isPublic, login, locales } = parsed.data;
461
- const problems: (ResourceProblem & { file: string })[] = [];
462
478
  const loginProblem = (): string | undefined => {
463
479
  if (!isPublic) return "a login is for a public site: add `public: true`, or remove `login`";
464
480
  if (!connectors.vendors.has(login!)) return `login names "${login}", which is not a connector in sanoma.config.ts`;
package/src/steps.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { LedgerRecord } from "./ledger.ts";
2
2
  import type { Op } from "./op.ts";
3
+ import type { ConnectionRef } from "./connection.ts";
3
4
 
4
5
  /*
5
6
  * Steps a connector (or a company) ships for its Gherkin tests, as plain data: expressions and
@@ -19,8 +20,8 @@ type AnyOp<I = any, O = any> = Op<string, string, string, I, O>;
19
20
  * seed's name (else the type's) as the export.
20
21
  */
21
22
  export type Seed =
22
- | { op: AnyOp; input: Record<string, unknown>; as?: string }
23
- | { op: AnyOp; fault: "failNext" | "rateLimit" | "loseReply" };
23
+ | { op: AnyOp; input: Record<string, unknown>; as?: string; connection?: ConnectionRef }
24
+ | { op: AnyOp; fault: "failNext" | "rateLimit" | "loseReply"; connection?: ConnectionRef };
24
25
 
25
26
  /** A call through an operation: what it was given, and what it returned. */
26
27
  export interface Call<I, O> {