@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.
- package/README.md +33 -7
- package/SECRET-SUPPORT.md +33 -0
- package/dist/apps.d.ts +6 -0
- package/dist/apps.js +18 -1
- package/dist/apps.js.map +1 -1
- package/dist/authentication.d.ts +30 -0
- package/dist/authentication.js +71 -1
- package/dist/authentication.js.map +1 -1
- package/dist/call.js +7 -5
- package/dist/call.js.map +1 -1
- package/dist/client.d.ts +54 -6
- package/dist/client.js +177 -5
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +7 -4
- package/dist/config.js +44 -12
- package/dist/config.js.map +1 -1
- package/dist/connection.d.ts +223 -2
- package/dist/connection.js +334 -4
- package/dist/connection.js.map +1 -1
- package/dist/db.js +15 -2
- package/dist/db.js.map +1 -1
- package/dist/describe.d.ts +8 -0
- package/dist/describe.js +51 -1
- package/dist/describe.js.map +1 -1
- package/dist/direct.js +4 -0
- package/dist/direct.js.map +1 -1
- package/dist/fake.d.ts +13 -1
- package/dist/fake.js +70 -0
- package/dist/fake.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lint.js +1 -1
- package/dist/lint.js.map +1 -1
- package/dist/load.d.ts +11 -0
- package/dist/load.js +42 -8
- package/dist/load.js.map +1 -1
- package/dist/op.d.ts +14 -6
- package/dist/op.js +20 -2
- package/dist/op.js.map +1 -1
- package/dist/outline.d.ts +5 -0
- package/dist/outline.js +33 -1
- package/dist/outline.js.map +1 -1
- package/dist/paths.d.ts +2 -4
- package/dist/paths.js +2 -8
- package/dist/paths.js.map +1 -1
- package/dist/run.d.ts +3 -1
- package/dist/run.js.map +1 -1
- package/dist/sandbox.d.ts +4 -1
- package/dist/sandbox.js +51 -5
- package/dist/sandbox.js.map +1 -1
- package/dist/scenario.d.ts +5 -0
- package/dist/scenario.js +3 -2
- package/dist/scenario.js.map +1 -1
- package/dist/secret.d.ts +2 -0
- package/dist/secret.js +32 -0
- package/dist/secret.js.map +1 -1
- package/dist/shared.d.ts +4 -0
- package/dist/shared.js +7 -0
- package/dist/shared.js.map +1 -1
- package/dist/sites.js +18 -3
- package/dist/sites.js.map +1 -1
- package/dist/steps.d.ts +3 -0
- package/dist/steps.js.map +1 -1
- package/oxlint.json +1 -0
- package/package.json +2 -1
- package/src/apps.ts +17 -1
- package/src/authentication.ts +119 -2
- package/src/call.ts +4 -5
- package/src/client.ts +240 -6
- package/src/config.ts +45 -11
- package/src/connection.ts +472 -6
- package/src/db.ts +15 -2
- package/src/describe.ts +52 -1
- package/src/direct.ts +4 -0
- package/src/fake.ts +71 -0
- package/src/index.ts +12 -1
- package/src/lint.ts +1 -1
- package/src/load.ts +36 -7
- package/src/op.ts +33 -8
- package/src/outline.ts +35 -2
- package/src/paths.ts +2 -9
- package/src/run.ts +3 -1
- package/src/sandbox.ts +55 -5
- package/src/scenario.ts +24 -6
- package/src/secret.ts +29 -0
- package/src/shared.ts +9 -0
- package/src/sites.ts +19 -3
- 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
|
|
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
|
-
|
|
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> {
|