@sanoma-ai/workflows 0.1.0 → 0.4.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/README.md +186 -76
- package/dist/apply-steps.d.ts +6 -0
- package/dist/apply-steps.js +93 -0
- package/dist/apply-steps.js.map +1 -0
- package/dist/apply.d.ts +197 -0
- package/dist/apply.js +470 -0
- package/dist/apply.js.map +1 -0
- package/dist/approvals.d.ts +11 -6
- package/dist/approvals.js +38 -10
- package/dist/approvals.js.map +1 -1
- package/dist/call-workflow.d.ts +16 -0
- package/dist/call-workflow.js +35 -0
- package/dist/call-workflow.js.map +1 -0
- package/dist/call.d.ts +35 -2
- package/dist/call.js +123 -43
- package/dist/call.js.map +1 -1
- package/dist/cedar.d.ts +87 -0
- package/dist/cedar.js +365 -0
- package/dist/cedar.js.map +1 -0
- package/dist/client.d.ts +123 -9
- package/dist/client.js +355 -34
- package/dist/client.js.map +1 -1
- package/dist/collection.d.ts +107 -0
- package/dist/collection.js +306 -0
- package/dist/collection.js.map +1 -0
- package/dist/config.d.ts +42 -14
- package/dist/config.js +109 -28
- package/dist/config.js.map +1 -1
- package/dist/constructors.d.ts +2 -0
- package/dist/constructors.js +5 -0
- package/dist/constructors.js.map +1 -0
- package/dist/credentials.d.ts +25 -0
- package/dist/credentials.js +73 -5
- package/dist/credentials.js.map +1 -1
- package/dist/data.d.ts +2 -0
- package/dist/data.js +3 -0
- package/dist/data.js.map +1 -0
- package/dist/datafile.d.ts +38 -3
- package/dist/datafile.js +166 -13
- package/dist/datafile.js.map +1 -1
- package/dist/db.d.ts +5 -3
- package/dist/db.js +88 -21
- package/dist/db.js.map +1 -1
- package/dist/define.d.ts +10 -4
- package/dist/define.js +1 -5
- package/dist/define.js.map +1 -1
- package/dist/describe.d.ts +54 -8
- package/dist/describe.js +84 -11
- package/dist/describe.js.map +1 -1
- package/dist/direct.d.ts +9 -0
- package/dist/direct.js +11 -0
- package/dist/direct.js.map +1 -0
- package/dist/drift.d.ts +64 -12
- package/dist/drift.js +118 -41
- package/dist/drift.js.map +1 -1
- package/dist/errors.d.ts +16 -1
- package/dist/errors.js +30 -1
- package/dist/errors.js.map +1 -1
- package/dist/expectations.d.ts +4 -4
- package/dist/expectations.js +43 -9
- package/dist/expectations.js.map +1 -1
- package/dist/host.d.ts +56 -0
- package/dist/host.js +45 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +12 -1
- package/dist/ledger.js +18 -11
- package/dist/ledger.js.map +1 -1
- package/dist/lint.d.ts +5 -4
- package/dist/lint.js +24 -7
- package/dist/lint.js.map +1 -1
- package/dist/lockfile.d.ts +36 -0
- package/dist/lockfile.js +69 -0
- package/dist/lockfile.js.map +1 -0
- package/dist/op.d.ts +9 -0
- package/dist/op.js.map +1 -1
- package/dist/outline.d.ts +2 -0
- package/dist/outline.js +1 -1
- package/dist/outline.js.map +1 -1
- package/dist/paths.d.ts +4 -0
- package/dist/paths.js +17 -3
- package/dist/paths.js.map +1 -1
- package/dist/person.d.ts +61 -0
- package/dist/person.js +69 -0
- package/dist/person.js.map +1 -0
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/policy.d.ts +51 -55
- package/dist/policy.js +14 -36
- package/dist/policy.js.map +1 -1
- package/dist/resource.d.ts +207 -25
- package/dist/resource.js +184 -30
- package/dist/resource.js.map +1 -1
- package/dist/resources.d.ts +76 -9
- package/dist/resources.js +170 -30
- package/dist/resources.js.map +1 -1
- package/dist/run.d.ts +31 -1
- package/dist/run.js +6 -1
- package/dist/run.js.map +1 -1
- package/dist/sandbox.js +5 -1
- package/dist/sandbox.js.map +1 -1
- package/dist/scenario.d.ts +25 -9
- package/dist/scenario.js +125 -27
- package/dist/scenario.js.map +1 -1
- package/dist/scenarios.d.ts +10 -6
- package/dist/scenarios.js +8 -4
- package/dist/scenarios.js.map +1 -1
- package/dist/schema.d.ts +32 -0
- package/dist/schema.js +225 -0
- package/dist/schema.js.map +1 -0
- package/dist/sdk.d.ts +34 -0
- package/dist/sdk.js +168 -0
- package/dist/sdk.js.map +1 -0
- package/dist/secret.d.ts +42 -0
- package/dist/secret.js +58 -0
- package/dist/secret.js.map +1 -0
- package/dist/shared.d.ts +188 -4
- package/dist/shared.js +165 -5
- package/dist/shared.js.map +1 -1
- package/dist/sites.d.ts +52 -0
- package/dist/sites.js +174 -0
- package/dist/sites.js.map +1 -0
- package/dist/source.d.ts +58 -0
- package/dist/source.js +54 -0
- package/dist/source.js.map +1 -0
- package/dist/version.d.ts +3 -2
- package/dist/version.js +3 -2
- package/dist/version.js.map +1 -1
- package/dist/worker.d.ts +6 -2
- package/dist/worker.js +37 -8
- package/dist/worker.js.map +1 -1
- package/dist/writer.d.ts +35 -0
- package/dist/writer.js +201 -0
- package/dist/writer.js.map +1 -0
- package/oxlint.json +5 -16
- package/package.json +11 -1
- package/src/apply-steps.ts +110 -0
- package/src/apply.ts +626 -0
- package/src/approvals.ts +49 -13
- package/src/call-workflow.ts +44 -0
- package/src/call.ts +173 -46
- package/src/cedar.ts +493 -0
- package/src/client.ts +450 -49
- package/src/collection.ts +431 -0
- package/src/config.ts +168 -48
- package/src/constructors.ts +4 -0
- package/src/credentials.ts +90 -5
- package/src/data.ts +10 -0
- package/src/datafile.ts +207 -15
- package/src/db.ts +90 -22
- package/src/define.ts +11 -9
- package/src/describe.ts +146 -23
- package/src/direct.ts +15 -0
- package/src/drift.ts +155 -45
- package/src/errors.ts +36 -1
- package/src/expectations.ts +46 -11
- package/src/host.ts +96 -0
- package/src/index.ts +56 -2
- package/src/ledger.ts +35 -17
- package/src/lint.ts +29 -12
- package/src/lockfile.ts +95 -0
- package/src/op.ts +9 -0
- package/src/outline.ts +1 -1
- package/src/paths.ts +18 -3
- package/src/person.ts +75 -0
- package/src/plugin.ts +1 -1
- package/src/policy.ts +59 -63
- package/src/resource.ts +302 -52
- package/src/resources.ts +226 -30
- package/src/run.ts +33 -1
- package/src/sandbox.ts +5 -1
- package/src/scenario.ts +175 -43
- package/src/scenarios.ts +15 -8
- package/src/schema.ts +261 -0
- package/src/sdk.ts +211 -0
- package/src/secret.ts +92 -0
- package/src/shared.ts +279 -6
- package/src/sites.ts +220 -0
- package/src/source.ts +82 -0
- package/src/version.ts +3 -2
- package/src/worker.ts +45 -11
- package/src/writer.ts +225 -0
package/dist/db.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { DBOS, DBOSClient } from "@dbos-inc/dbos-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
3
|
+
import { Client, escapeIdentifier, Pool } from "pg";
|
|
3
4
|
import { warn } from "./log.js";
|
|
4
5
|
import { errorMessage } from "./shared.js";
|
|
5
6
|
/** Where the credentials set from the app live. */
|
|
6
7
|
export const CREDENTIALS_TABLE = "sanoma_credentials";
|
|
7
8
|
/** Where the Postgres ledger keeps its records. */
|
|
8
9
|
export const LEDGER_TABLE = "sanoma_ledger";
|
|
10
|
+
/** Where the collections keep their records (`collection.ts`): one row per collection and key, the record as JSON. */
|
|
11
|
+
export const DATA_TABLE = "sanoma_data";
|
|
9
12
|
/** The runtime's tables, each with the word the messages name it by. */
|
|
10
13
|
const TABLES = [
|
|
11
14
|
[
|
|
@@ -21,11 +24,21 @@ const TABLES = [
|
|
|
21
24
|
`run_id text NOT NULL, seq integer NOT NULL, record jsonb NOT NULL); ` +
|
|
22
25
|
`CREATE INDEX IF NOT EXISTS ${LEDGER_TABLE}_run_seq ON ${LEDGER_TABLE} (run_id, seq, n)`,
|
|
23
26
|
],
|
|
27
|
+
[
|
|
28
|
+
"data",
|
|
29
|
+
`CREATE TABLE IF NOT EXISTS ${DATA_TABLE} (collection text NOT NULL, key text NOT NULL, record jsonb NOT NULL, ` +
|
|
30
|
+
"updated_at timestamptz NOT NULL DEFAULT now(), updated_by text NOT NULL, PRIMARY KEY (collection, key))",
|
|
31
|
+
],
|
|
24
32
|
];
|
|
25
33
|
/** The Postgres error code of `err`, or an empty string when it has none. */
|
|
26
34
|
export const pgCode = (err) => err?.code?.toString() ?? "";
|
|
27
|
-
/**
|
|
28
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Postgres's codes for a database, a row type or a table another process made first. Two racing
|
|
37
|
+
* `CREATE TABLE IF NOT EXISTS` both pass the check, and the loser fails on the table's row type in
|
|
38
|
+
* `pg_type`: as a unique violation (23505), or as a duplicate object (42710, "type ... already
|
|
39
|
+
* exists"). Two racing `CREATE DATABASE` fail as 42P04, or on `pg_database` as 23505.
|
|
40
|
+
*/
|
|
41
|
+
const MADE_ALREADY = new Set(["23505", "42P04", "42P07", "42710"]);
|
|
29
42
|
/** True for the failure of a create that another process won: what was to be made is there. */
|
|
30
43
|
export const madeAlready = (err) => MADE_ALREADY.has(pgCode(err));
|
|
31
44
|
/**
|
|
@@ -63,6 +76,8 @@ export const dbosClient = (databaseUrl, applicationName) => DBOSClient.create({
|
|
|
63
76
|
const IDLE_IN_TRANSACTION_TIMEOUT = "60s";
|
|
64
77
|
/** Postgres's code for a statement the role lacks the privilege for. */
|
|
65
78
|
const INSUFFICIENT_PRIVILEGE = "42501";
|
|
79
|
+
/** Postgres's code for a database that is not there (`invalid_catalog_name`). */
|
|
80
|
+
const NO_DATABASE = "3D000";
|
|
66
81
|
/**
|
|
67
82
|
* A pool for `what` on the database at `databaseUrl`, opened on the first `db()` once the
|
|
68
83
|
* database is prepared (`prepareDatabase`). A preparation that fails lets the pool go, so the
|
|
@@ -101,9 +116,9 @@ const prepared = new Map();
|
|
|
101
116
|
* Makes the database at `databaseUrl` ready for the runtime, once per process and URL: the
|
|
102
117
|
* database itself and DBOS's tables when they are not there yet (as a worker's launch makes
|
|
103
118
|
* them; credentials may be set, and a ledger read, before any worker has run), then the
|
|
104
|
-
* credentials and
|
|
105
|
-
* Two processes preparing one database both succeed
|
|
106
|
-
* preparation that fails is forgotten, so the next call tries again.
|
|
119
|
+
* credentials, ledger and data tables, and its idle-transaction timeout (`guardIdleTransactions`).
|
|
120
|
+
* Two processes preparing one database both succeed: the second waits for the first
|
|
121
|
+
* (`lockPreparation`). A preparation that fails is forgotten, so the next call tries again.
|
|
107
122
|
*/
|
|
108
123
|
export function prepareDatabase(databaseUrl) {
|
|
109
124
|
let preparing = prepared.get(databaseUrl);
|
|
@@ -117,36 +132,89 @@ export function prepareDatabase(databaseUrl) {
|
|
|
117
132
|
}
|
|
118
133
|
return preparing;
|
|
119
134
|
}
|
|
135
|
+
/** The error a preparation fails with, its cause `err`. */
|
|
136
|
+
const unprepared = (err) => new Error(`could not prepare the database: ${errorMessage(err)}`, { cause: err });
|
|
120
137
|
async function prepare(databaseUrl) {
|
|
138
|
+
const conn = await lockPreparation(databaseUrl).catch((err) => {
|
|
139
|
+
throw unprepared(err);
|
|
140
|
+
});
|
|
141
|
+
try {
|
|
142
|
+
await DBOS.migrate(databaseUrl).catch((err) => {
|
|
143
|
+
// A DBOS table made meanwhile by a release from before the lock, mid-upgrade: it is there.
|
|
144
|
+
if (!madeAlready(err))
|
|
145
|
+
throw unprepared(err);
|
|
146
|
+
});
|
|
147
|
+
for (const [what, ddl] of TABLES)
|
|
148
|
+
await createTable(conn, ddl, what);
|
|
149
|
+
await guardIdleTransactions(conn);
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
// Ending the session releases the lock; a failure to end it must not hide the preparation's.
|
|
153
|
+
await conn.end().catch(() => undefined);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A connection to the database at `databaseUrl` (made first when missing) holding the
|
|
158
|
+
* preparation's session lock until it ends, so a second process waits, then finds everything
|
|
159
|
+
* made. Racing `DBOS.migrate`s lose to each other in many ways (40P01, XX000), so the race is
|
|
160
|
+
* prevented rather than each loss forgiven. The lock is polled, never waited for by a blocked
|
|
161
|
+
* statement: `CREATE INDEX CONCURRENTLY` waits on that statement's snapshot, a deadlock Postgres
|
|
162
|
+
* cannot see (the lock's holder is this connection, not the migration's).
|
|
163
|
+
*/
|
|
164
|
+
async function lockPreparation(databaseUrl) {
|
|
165
|
+
const conn = await connect(databaseUrl).catch(async (err) => {
|
|
166
|
+
if (pgCode(err) !== NO_DATABASE)
|
|
167
|
+
throw err;
|
|
168
|
+
await createDatabase(databaseUrl);
|
|
169
|
+
return connect(databaseUrl);
|
|
170
|
+
});
|
|
121
171
|
try {
|
|
122
|
-
|
|
172
|
+
const ask = "SELECT pg_try_advisory_lock(hashtext('sanoma.prepareDatabase')) AS locked";
|
|
173
|
+
while (!(await conn.query(ask)).rows[0].locked)
|
|
174
|
+
await delay(50);
|
|
175
|
+
return conn;
|
|
123
176
|
}
|
|
124
177
|
catch (err) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
throw new Error(`could not prepare the database: ${errorMessage(err)}`, { cause: err });
|
|
178
|
+
await conn.end().catch(() => undefined);
|
|
179
|
+
throw err;
|
|
128
180
|
}
|
|
129
|
-
|
|
181
|
+
}
|
|
182
|
+
async function connect(databaseUrl) {
|
|
183
|
+
const conn = new Client({ connectionString: databaseUrl, connectionTimeoutMillis: 10_000 });
|
|
184
|
+
// An error nobody listens for ends the process; the query in flight fails with it.
|
|
185
|
+
conn.on("error", (err) => warn(`a preparation connection failed: ${errorMessage(err)}`));
|
|
130
186
|
await conn.connect();
|
|
187
|
+
return conn;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Makes the database at `databaseUrl` through its server's `postgres` database, as `DBOS.migrate`
|
|
191
|
+
* would. Another process making it first is no failure.
|
|
192
|
+
*/
|
|
193
|
+
async function createDatabase(databaseUrl) {
|
|
194
|
+
const url = new URL(databaseUrl);
|
|
195
|
+
const name = decodeURI(url.pathname.slice(1));
|
|
196
|
+
url.pathname = "/postgres";
|
|
197
|
+
const admin = await connect(url.toString());
|
|
131
198
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
199
|
+
await admin.query(`CREATE DATABASE ${escapeIdentifier(name)}`);
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
if (!madeAlready(err))
|
|
203
|
+
throw err;
|
|
135
204
|
}
|
|
136
205
|
finally {
|
|
137
|
-
await
|
|
206
|
+
await admin.end();
|
|
138
207
|
}
|
|
139
208
|
}
|
|
140
209
|
/**
|
|
141
210
|
* Sets `idle_in_transaction_session_timeout` on the database, for each session that starts after,
|
|
142
211
|
* as DBOS would per connection (`DBOS_DATABASE_OPTIONS`), unless the server, the role or the
|
|
143
|
-
* database sets it already.
|
|
144
|
-
*
|
|
212
|
+
* database sets it already. `db` holds the preparation's lock, so one process at a time. A role
|
|
213
|
+
* that may not alter the database leaves it, quietly: its administrator decides.
|
|
145
214
|
*/
|
|
146
215
|
async function guardIdleTransactions(db) {
|
|
147
216
|
try {
|
|
148
217
|
await db.query(`DO $$ BEGIN
|
|
149
|
-
PERFORM pg_advisory_xact_lock(hashtext('sanoma.idle_in_transaction_session_timeout'));
|
|
150
218
|
IF current_setting('idle_in_transaction_session_timeout') = '0' AND NOT EXISTS (
|
|
151
219
|
SELECT FROM pg_db_role_setting s JOIN pg_database d ON d.oid = s.setdatabase, unnest(s.setconfig) c
|
|
152
220
|
WHERE d.datname = current_database() AND s.setrole = 0 AND c LIKE 'idle_in_transaction_session_timeout=%'
|
|
@@ -157,9 +225,8 @@ async function guardIdleTransactions(db) {
|
|
|
157
225
|
END $$`);
|
|
158
226
|
}
|
|
159
227
|
catch (err) {
|
|
160
|
-
if (pgCode(err) !== INSUFFICIENT_PRIVILEGE)
|
|
161
|
-
throw
|
|
162
|
-
}
|
|
228
|
+
if (pgCode(err) !== INSUFFICIENT_PRIVILEGE)
|
|
229
|
+
throw unprepared(err);
|
|
163
230
|
}
|
|
164
231
|
}
|
|
165
232
|
/**
|
package/dist/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../src/db.ts"],"names":[],"mappings":"A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gB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;YAAE,MAAM,GAAG,CAAC;IACnC,CAAC;YAAS,CAAC;QACT,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,qBAAqB,CAAC,EAAM;IACzC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,KAAK,CAAC;;;;;;aAMN,2BAA2B;;WAE7B,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,sBAAsB;YAAE,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAM,EAAE,GAAW,EAAE,IAAY;IACjE,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,WAAW,CAAC,GAAG,CAAC;YAAE,OAAO;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,WAAW,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC"}
|
package/dist/define.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type Op } from "./op.ts";
|
|
3
3
|
/**
|
|
4
|
-
* Who is acting: the person or
|
|
5
|
-
*
|
|
4
|
+
* Who is acting: the person or agent that starts a run, calls an operation or decides an
|
|
5
|
+
* approval. With people declared (`sanoma.person`, `sanoma.agent`, `sanoma.group` in data files),
|
|
6
|
+
* a principal is a declared one, its `groups` every group that lists it; an agent is in the group
|
|
7
|
+
* `agents`, and `onBehalfOf` names the person it acts for.
|
|
6
8
|
*/
|
|
7
9
|
export interface Principal {
|
|
8
10
|
id: string;
|
|
9
11
|
groups?: string[];
|
|
12
|
+
/** For an agent: the id of the person whose instruction it carries. */
|
|
13
|
+
onBehalfOf?: string;
|
|
10
14
|
}
|
|
11
15
|
export declare const Principal: z.ZodType<Principal>;
|
|
12
16
|
export type Builtin = "approval" | "sleep" | "all";
|
|
@@ -16,8 +20,6 @@ export type Approver = string | {
|
|
|
16
20
|
group: string;
|
|
17
21
|
};
|
|
18
22
|
export declare const Approver: z.ZodType<Approver>;
|
|
19
|
-
/** Why `by` may not decide the approval, naming who may. */
|
|
20
|
-
export declare const notApprover: ({ approver }: Pick<ApprovalState, "approver">, by: Principal) => string;
|
|
21
23
|
/** True when the two name the same approver: the same id, or the same group. */
|
|
22
24
|
export declare const sameApprover: (a: Approver, b: Approver) => boolean;
|
|
23
25
|
/** `covers` as given (operations), parsed to their ids. */
|
|
@@ -68,6 +70,8 @@ export interface ApprovalState extends Omit<ApprovalRequest, "covers"> {
|
|
|
68
70
|
opSeq?: number;
|
|
69
71
|
/** For a policy request: the held call's input. */
|
|
70
72
|
input?: unknown;
|
|
73
|
+
/** For a policy request: the policies that held the call, by id, when the policy names them. */
|
|
74
|
+
reasons?: string[];
|
|
71
75
|
status: "pending" | "approved" | "rejected";
|
|
72
76
|
requestedAt: number;
|
|
73
77
|
decidedBy?: string;
|
|
@@ -75,6 +79,8 @@ export interface ApprovalState extends Omit<ApprovalRequest, "covers"> {
|
|
|
75
79
|
note?: string;
|
|
76
80
|
/** The `id` of the decision message the run decided with, when it had one. */
|
|
77
81
|
decidedWith?: string;
|
|
82
|
+
/** Set when the run's own actor decided it: nobody else could (`mayDecide`). */
|
|
83
|
+
alone?: true;
|
|
78
84
|
/**
|
|
79
85
|
* Messages that were ignored: decisions sent by someone who may not decide the approval,
|
|
80
86
|
* and messages that were not a decision. `by` is the sender, when the message named one, and
|
package/dist/define.js
CHANGED
|
@@ -2,16 +2,12 @@ import { fileURLToPath } from "node:url";
|
|
|
2
2
|
import { getCallSites } from "node:util";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { isOp } from "./op.js";
|
|
5
|
-
import { approverLabel } from "./shared.js";
|
|
6
5
|
export const Principal = z.object({
|
|
7
6
|
id: z.string().regex(/\S/, "id must not be blank"),
|
|
8
7
|
groups: z.array(z.string()).optional(),
|
|
8
|
+
onBehalfOf: z.string().regex(/\S/, "onBehalfOf must not be blank").optional(),
|
|
9
9
|
});
|
|
10
10
|
export const Approver = z.union([z.string().regex(/\S/), z.object({ group: z.string().regex(/\S/) })], { error: 'needs an approver: a name, or { group: "name" }' });
|
|
11
|
-
/** Why `by` may not decide the approval, naming who may. */
|
|
12
|
-
export const notApprover = ({ approver }, by) => typeof approver === "string"
|
|
13
|
-
? `${by.id} is not the approver; ${approverLabel(approver)} is`
|
|
14
|
-
: `${by.id} is not in ${approverLabel(approver)}`;
|
|
15
11
|
/** True when the two name the same approver: the same id, or the same group. */
|
|
16
12
|
export const sameApprover = (a, b) => typeof a === "string" || typeof b === "string" ? a === b : a.group === b.group;
|
|
17
13
|
const notOps = "covers must be a list of operations";
|
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAW,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAA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G,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnH,MAAM,UAAU,cAAc,CAC5B,GAAoD;IAEpD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kBAAkB,GAAG,CAAC,IAAI,gDAAgD,CAAC,CAAC;IAC9F,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,aAAa,GAAG,CAAC,IAAI,2EAA2E;YAC9F,qEAAqE,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,6GAA6G;IAC7G,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACpD,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,UAAU,CAAC,MAA0B;IACnD,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,MAAM,IAAI,SAAS,CAAC;IAC7D,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/describe.d.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
import { type LintProblem } from "./ast.ts";
|
|
2
|
+
import { type Field } from "./collection.ts";
|
|
2
3
|
import { type SanomaConfig } from "./config.ts";
|
|
3
4
|
import { type Builtin } from "./define.ts";
|
|
4
5
|
import { type Effect } from "./op.ts";
|
|
5
6
|
import { type Outline } from "./outline.ts";
|
|
6
7
|
import { type ResourceFields } from "./resource.ts";
|
|
7
|
-
import { type DeclaredResource, type ResourceProblem } from "./resources.ts";
|
|
8
|
+
import { type DataFiles, type DeclaredCollection, type DeclaredResource, type ResourceProblem } from "./resources.ts";
|
|
9
|
+
import { type SiteEntry } from "./sites.ts";
|
|
8
10
|
export { outlineWorkflow, type Outline, type OutlineNode, type Span } from "./outline.ts";
|
|
9
11
|
export type { LintProblem } from "./ast.ts";
|
|
10
|
-
export { readDataFiles,
|
|
12
|
+
export { admit, readDataFiles, readPeople, type DataFiles, type DeclaredCollection, type DeclaredPeople, type DeclaredResource, type ResourceProblem, } from "./resources.ts";
|
|
13
|
+
export { formatOptions, renderDataFile, setFields, type DataFileContent } from "./writer.ts";
|
|
14
|
+
export { Reference, type DataValue } from "./datafile.ts";
|
|
15
|
+
/**
|
|
16
|
+
* The resources the config's data files declare, read without importing or running them; throws
|
|
17
|
+
* one error listing every problem, each at `file:line:column`, for a test or CI to fail on.
|
|
18
|
+
* `describeConfig` lists the same, with the problems beside them instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readResources(config: SanomaConfig): DeclaredResource[];
|
|
21
|
+
export { LOCKFILE, readLockfile, serializeLockfile, writeLockfile, diffLockfiles, type Binding, type Bindings, type Rebind, } from "./lockfile.ts";
|
|
22
|
+
export { readSites, type SiteCall, type SiteEntry } from "./sites.ts";
|
|
23
|
+
export { API_FILE, generateApi, writeApi, writeGenerated } from "./sdk.ts";
|
|
24
|
+
export { SCHEMA_FILE, schemaOf, schemaText, type CedarSchemaJson } from "./schema.ts";
|
|
25
|
+
export type { ApplyInput, ApplyPlan, ApplyReport, ApplyResult, PlanAnswer, PlanStep } from "./apply.ts";
|
|
11
26
|
/** What a workflow is, read from its definition: enough to draw a start form and show what it may call. */
|
|
12
27
|
export interface WorkflowEntry {
|
|
13
28
|
name: string;
|
|
14
29
|
title?: string;
|
|
15
30
|
trigger: "manual";
|
|
16
31
|
/**
|
|
17
|
-
* Set for a workflow the runtime adds itself, `drift`, rather than the config: a label. It
|
|
32
|
+
* Set for a workflow the runtime adds itself, `drift`, `apply` or `call`, rather than the config: a label. It
|
|
18
33
|
* starts like any other.
|
|
19
34
|
*/
|
|
20
35
|
builtin?: true;
|
|
@@ -57,6 +72,8 @@ export interface OpEntry {
|
|
|
57
72
|
given?: string;
|
|
58
73
|
expect?: string;
|
|
59
74
|
};
|
|
75
|
+
/** Whether it may be called directly, outside a run (`isDirect`): the one rule, read here, never derived again. */
|
|
76
|
+
direct: boolean;
|
|
60
77
|
/** What a call sends, as JSON Schema (`io: "input"`: fields with defaults are optional). */
|
|
61
78
|
input: Record<string, unknown>;
|
|
62
79
|
/** What a call returns once its schema has parsed the vendor's reply (`io: "output"`). */
|
|
@@ -85,8 +102,8 @@ export interface ResourceTypeEntry {
|
|
|
85
102
|
vendor: string;
|
|
86
103
|
type: string;
|
|
87
104
|
title: string;
|
|
88
|
-
/** How a declared resource's
|
|
89
|
-
identity
|
|
105
|
+
/** How a declared resource's identity is made, such as `name` or `repository_id:pattern`; absent when it is found only by its binding. */
|
|
106
|
+
identity?: string;
|
|
90
107
|
/** Its flagged fields, by dotted path. */
|
|
91
108
|
fields: ResourceFields;
|
|
92
109
|
/**
|
|
@@ -94,8 +111,23 @@ export interface ResourceTypeEntry {
|
|
|
94
111
|
* `sanoma:resource-type/<id>`: the operations' contracts `$ref` it instead of repeating it.
|
|
95
112
|
*/
|
|
96
113
|
schema: Record<string, unknown>;
|
|
97
|
-
/** Its operations' ids: `<id>.import` and `<id>.read
|
|
114
|
+
/** Its operations' ids, sorted: `<id>.import` and `<id>.read`, and for a writable type its change operations. */
|
|
115
|
+
ops: string[];
|
|
116
|
+
}
|
|
117
|
+
/** A collection the config declares (`collection()`). */
|
|
118
|
+
export interface CollectionEntry {
|
|
119
|
+
name: string;
|
|
120
|
+
title?: string;
|
|
121
|
+
/** The field each record is found by. */
|
|
122
|
+
key: string;
|
|
123
|
+
/** Its fields as declared. */
|
|
124
|
+
fields: Record<string, Field>;
|
|
125
|
+
/** What `save` accepts, as JSON Schema, with `$id` `sanoma:collection/<name>`. */
|
|
126
|
+
record: Record<string, unknown>;
|
|
127
|
+
/** Its operations' ids: `data.<name>.get`, `.list`, `.save` and `.delete`. */
|
|
98
128
|
ops: string[];
|
|
129
|
+
/** Where `resources/data.ts` declares it, read as the data files are; absent for one declared elsewhere. */
|
|
130
|
+
declared?: DeclaredCollection;
|
|
99
131
|
}
|
|
100
132
|
/**
|
|
101
133
|
* A plain-JSON description of what a config can do: its workflows, the operations they call,
|
|
@@ -112,24 +144,38 @@ export interface ConfigDescription {
|
|
|
112
144
|
vendors: Record<string, VendorEntry>;
|
|
113
145
|
/** The resource types the connectors declare, by `id`. */
|
|
114
146
|
resourceTypes: ResourceTypeEntry[];
|
|
147
|
+
/** The config's collections, by name. */
|
|
148
|
+
collections: CollectionEntry[];
|
|
115
149
|
/**
|
|
116
150
|
* The resources the data files under `resources/` declare, by file and then in file order,
|
|
117
151
|
* less any with a problem and any that names one.
|
|
118
152
|
*/
|
|
119
153
|
resources: DeclaredResource[];
|
|
154
|
+
/** Each binding in the lockfile (`LOCKFILE`) whose key no data file declares, as `readDataFiles` reports it. */
|
|
155
|
+
orphans: DataFiles["orphans"];
|
|
120
156
|
/** What is wrong in the data files (`readDataFiles`), each at its file, relative to the root, line and column. A workflow's are on its entry. */
|
|
121
157
|
problems: ResourceProblem[];
|
|
122
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* `defined` when the root has `policies/**\/*.cedar` (else the policy is `allowAll`), with their
|
|
160
|
+
* `version`, or while they have `problems` (`policyProblems`), none: then every call and start is refused.
|
|
161
|
+
*/
|
|
123
162
|
policy: {
|
|
124
163
|
defined: boolean;
|
|
125
164
|
version?: string;
|
|
165
|
+
problems?: string[];
|
|
126
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* The sites under `sites/`, by name, with what each calls (`readSites`), and its calls to what
|
|
169
|
+
* the config does not have as its problems; none when the root has no `sites/`.
|
|
170
|
+
*/
|
|
171
|
+
sites: SiteEntry[];
|
|
127
172
|
}
|
|
128
173
|
/**
|
|
129
174
|
* Describes a config. Throws what `startWorker` would refuse (see `resolveConfig`), except missing
|
|
130
175
|
* credentials (`SanomaClient.credentials` gives their statuses) and what is wrong in a workflow's
|
|
131
176
|
* file, which the worker refuses when it reads the outline: that is data, on each workflow's
|
|
132
177
|
* entry, as the data files' problems are, `problems`, beside the resources read without any.
|
|
133
|
-
* Each workflow's file is read and parsed once, however many workflows it defines.
|
|
178
|
+
* Each workflow's file is read and parsed once, however many workflows it defines. The sites'
|
|
179
|
+
* code is read too (`readSites`): what each calls, and its calls to what the config lacks as its problems.
|
|
134
180
|
*/
|
|
135
181
|
export declare function describeConfig(config: SanomaConfig): ConfigDescription;
|
package/dist/describe.js
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
import { readSource } from "./ast.js";
|
|
2
|
-
import {
|
|
2
|
+
import { recordSchemaOf } from "./collection.js";
|
|
3
|
+
import { connectorsOf, resolveConfig, rootOf } from "./config.js";
|
|
3
4
|
import { jsonSchemaOf, opIdsOf } from "./define.js";
|
|
4
|
-
import {
|
|
5
|
+
import { isDirect } from "./direct.js";
|
|
5
6
|
import { lintWorkflow } from "./lint.js";
|
|
6
7
|
import { VENDOR } from "./op.js";
|
|
7
8
|
import { outlineWithSource } from "./outline.js";
|
|
8
9
|
import { allowAll, policyOpOf } from "./policy.js";
|
|
9
10
|
import { resourceTypesOf } from "./resource.js";
|
|
10
|
-
import { readDataFiles } from "./resources.js";
|
|
11
|
+
import { readDataFiles, } from "./resources.js";
|
|
12
|
+
import { apiNameProblem } from "./sdk.js";
|
|
13
|
+
import { apiNameOf, BUILT_IN_WORKFLOWS, DATA_VENDOR, problemLine } from "./shared.js";
|
|
14
|
+
import { readSites } from "./sites.js";
|
|
11
15
|
// `@sanoma-ai/workflows/describe`: what a UI renders from, apart from the main entry.
|
|
12
16
|
export { outlineWorkflow } from "./outline.js";
|
|
13
|
-
export { readDataFiles,
|
|
17
|
+
export { admit, readDataFiles, readPeople, } from "./resources.js";
|
|
18
|
+
// The writer: setting a resource's fields in its data file, and rendering a new one.
|
|
19
|
+
export { formatOptions, renderDataFile, setFields } from "./writer.js";
|
|
20
|
+
export { Reference } from "./datafile.js";
|
|
21
|
+
/**
|
|
22
|
+
* The resources the config's data files declare, read without importing or running them; throws
|
|
23
|
+
* one error listing every problem, each at `file:line:column`, for a test or CI to fail on.
|
|
24
|
+
* `describeConfig` lists the same, with the problems beside them instead.
|
|
25
|
+
*/
|
|
26
|
+
export function readResources(config) {
|
|
27
|
+
const { resources, problems } = readDataFiles(rootOf(config), connectorsOf(config));
|
|
28
|
+
if (problems.length) {
|
|
29
|
+
const lines = problems.map((p) => ` ${problemLine(p)}`);
|
|
30
|
+
throw new Error(`The resources' data files have problems:\n${lines.join("\n")}`);
|
|
31
|
+
}
|
|
32
|
+
return resources;
|
|
33
|
+
}
|
|
34
|
+
export { LOCKFILE, readLockfile, serializeLockfile, writeLockfile, diffLockfiles, } from "./lockfile.js";
|
|
35
|
+
// What the sites call, read from their source: a workflow's Used by.
|
|
36
|
+
export { readSites } from "./sites.js";
|
|
37
|
+
// The generated SDK, `.sanoma/api.ts`: a site's `api` typed from this description.
|
|
38
|
+
export { API_FILE, generateApi, writeApi, writeGenerated } from "./sdk.js";
|
|
39
|
+
// The Cedar schema, `.sanoma/schema.cedarschema`: what a company's policies are validated and decided against.
|
|
40
|
+
export { SCHEMA_FILE, schemaOf, schemaText } from "./schema.js";
|
|
14
41
|
/**
|
|
15
42
|
* Describes a config. Throws what `startWorker` would refuse (see `resolveConfig`), except missing
|
|
16
43
|
* credentials (`SanomaClient.credentials` gives their statuses) and what is wrong in a workflow's
|
|
17
44
|
* file, which the worker refuses when it reads the outline: that is data, on each workflow's
|
|
18
45
|
* entry, as the data files' problems are, `problems`, beside the resources read without any.
|
|
19
|
-
* Each workflow's file is read and parsed once, however many workflows it defines.
|
|
46
|
+
* Each workflow's file is read and parsed once, however many workflows it defines. The sites'
|
|
47
|
+
* code is read too (`readSites`): what each calls, and its calls to what the config lacks as its problems.
|
|
20
48
|
*/
|
|
21
49
|
export function describeConfig(config) {
|
|
22
50
|
const resolved = resolveConfig(config);
|
|
@@ -27,11 +55,11 @@ export function describeConfig(config) {
|
|
|
27
55
|
const { id, info } = connector[VENDOR];
|
|
28
56
|
vendors[id] ??= vendorEntry(id, info, resolved.fakes.has(id));
|
|
29
57
|
}
|
|
30
|
-
const resources = resourceTypesOf(config
|
|
58
|
+
const resources = resourceTypesOf(connectorsOf(config));
|
|
31
59
|
// Each resource type's state is described once, on its entry, and referenced from its operations.
|
|
32
60
|
const refs = new Map([...resources].map(([id, r]) => [r.schema, resourceTypeUri(id)]));
|
|
33
61
|
const resourceTypes = [...resources]
|
|
34
|
-
.map(([id, { vendor, type, title, identity, fields, schema }]) => ({
|
|
62
|
+
.map(([id, { vendor, type, title, identity, fields, schema, ops }]) => ({
|
|
35
63
|
id,
|
|
36
64
|
vendor,
|
|
37
65
|
type,
|
|
@@ -39,14 +67,30 @@ export function describeConfig(config) {
|
|
|
39
67
|
identity,
|
|
40
68
|
fields,
|
|
41
69
|
schema: { $id: resourceTypeUri(id), ...toJsonSchema(schema, `${id} state`, "output") },
|
|
42
|
-
ops:
|
|
70
|
+
ops: Object.keys(ops)
|
|
71
|
+
.map((name) => `${id}.${name}`)
|
|
72
|
+
.toSorted(),
|
|
43
73
|
}))
|
|
44
74
|
.toSorted((a, b) => a.id.localeCompare(b.id));
|
|
75
|
+
const dataFiles = readDataFiles(resolved.root, connectorsOf(config), resources);
|
|
76
|
+
const declared = new Map(dataFiles.collections.map((d) => [d.name, d]));
|
|
77
|
+
const collections = [...resolved.collections.values()]
|
|
78
|
+
.map((c) => ({
|
|
79
|
+
name: c.name,
|
|
80
|
+
...(c.title !== undefined && { title: c.title }),
|
|
81
|
+
key: c.key,
|
|
82
|
+
fields: c.fields,
|
|
83
|
+
record: { $id: `sanoma:collection/${c.name}`, ...toJsonSchema(recordSchemaOf(c), `${c.name} record`, "input") },
|
|
84
|
+
ops: [c.get, c.list, c.save, c.delete].map((op) => op.id),
|
|
85
|
+
...(declared.has(c.name) && { declared: declared.get(c.name) }),
|
|
86
|
+
}))
|
|
87
|
+
.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
45
88
|
const ops = [...resolved.ops.values()].map((op) => ({
|
|
46
89
|
...policyOpOf(op),
|
|
47
90
|
idempotent: op.idempotent,
|
|
48
91
|
description: op.description,
|
|
49
92
|
...(op.phrases && { phrases: op.phrases }),
|
|
93
|
+
direct: isDirect(op, resolved.types),
|
|
50
94
|
input: toJsonSchema(op.input, `${op.id} input`, "input", refs),
|
|
51
95
|
output: toJsonSchema(op.output, `${op.id} output`, "output", refs),
|
|
52
96
|
}));
|
|
@@ -58,7 +102,8 @@ export function describeConfig(config) {
|
|
|
58
102
|
const { outline, source, found } = outlineWithSource(wf, file);
|
|
59
103
|
// What the lint does not report: the file unread, or no workflow of this name in it.
|
|
60
104
|
const own = "error" in outline && !found && (typeof file === "string" || !file.problems.length);
|
|
61
|
-
const
|
|
105
|
+
const builtin = BUILT_IN_WORKFLOWS.has(wf.name);
|
|
106
|
+
const problems = builtin
|
|
62
107
|
? []
|
|
63
108
|
: [
|
|
64
109
|
...(typeof file === "string" ? [] : lint(file)),
|
|
@@ -68,7 +113,7 @@ export function describeConfig(config) {
|
|
|
68
113
|
name: wf.name,
|
|
69
114
|
title: wf.title,
|
|
70
115
|
trigger: wf.trigger,
|
|
71
|
-
...(
|
|
116
|
+
...(builtin && { builtin: true }),
|
|
72
117
|
input: toJsonSchema(wf.input, `${wf.name} input`, "input"),
|
|
73
118
|
ops: opIdsOf(wf),
|
|
74
119
|
builtins: wf.uses.filter((u) => typeof u === "string"),
|
|
@@ -79,7 +124,7 @@ export function describeConfig(config) {
|
|
|
79
124
|
};
|
|
80
125
|
});
|
|
81
126
|
workflows.sort((a, b) => a.name.localeCompare(b.name));
|
|
82
|
-
|
|
127
|
+
addApiNameProblems(workflows, new Set(ops.map((op) => op.vendor)));
|
|
83
128
|
return {
|
|
84
129
|
appName: resolved.appName,
|
|
85
130
|
version: resolved.version,
|
|
@@ -87,14 +132,42 @@ export function describeConfig(config) {
|
|
|
87
132
|
ops,
|
|
88
133
|
vendors,
|
|
89
134
|
resourceTypes,
|
|
135
|
+
collections,
|
|
90
136
|
resources: dataFiles.resources,
|
|
137
|
+
orphans: dataFiles.orphans,
|
|
91
138
|
problems: dataFiles.problems,
|
|
92
139
|
policy: {
|
|
93
140
|
defined: resolved.policy !== allowAll,
|
|
94
141
|
...(resolved.policy.version === undefined ? {} : { version: resolved.policy.version }),
|
|
142
|
+
...(resolved.policyProblems.length ? { problems: resolved.policyProblems } : {}),
|
|
95
143
|
},
|
|
144
|
+
sites: readSites(resolved.root, { workflows, collections, ops }),
|
|
96
145
|
};
|
|
97
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* A site's `api` names each workflow `apiNameOf(name)` beside the vendors' operations and the
|
|
149
|
+
* collections (`api.data`), so a workflow whose name comes out as another's, a vendor's id or
|
|
150
|
+
* `data` is a problem, at 1:1 of its file. A built-in is never the one renamed.
|
|
151
|
+
*/
|
|
152
|
+
function addApiNameProblems(workflows, vendors) {
|
|
153
|
+
for (const wf of workflows) {
|
|
154
|
+
if (wf.builtin)
|
|
155
|
+
continue;
|
|
156
|
+
const api = apiNameOf(wf.name);
|
|
157
|
+
const others = workflows.filter((other) => other !== wf && apiNameOf(other.name) === api);
|
|
158
|
+
const taken = others.length
|
|
159
|
+
? `as workflow ${others.map((other) => `"${other.name}"`).join(" and ")} is`
|
|
160
|
+
: api === DATA_VENDOR
|
|
161
|
+
? "which is the collections'"
|
|
162
|
+
: vendors.has(api)
|
|
163
|
+
? `which is the vendor ${api}'s operations`
|
|
164
|
+
: api === "then"
|
|
165
|
+
? "which a promise would take for its own"
|
|
166
|
+
: undefined;
|
|
167
|
+
if (taken)
|
|
168
|
+
wf.problems.push({ line: 1, column: 1, message: apiNameProblem(api, taken) });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
98
171
|
/** `fn`, called once per argument for as long as the returned function lives. */
|
|
99
172
|
function memoised(fn) {
|
|
100
173
|
const seen = new Map();
|
package/dist/describe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,UAAU,EAAmB,MAAM,UAAU,CAAC;AACzE,OAAO,EAAE,aAAa,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,UAAU,EAAmB,MAAM,UAAU,CAAC;AACzE,OAAO,EAAc,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AACrF,OAAO,EAAgB,YAAY,EAAE,OAAO,EAAY,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAe,MAAM,EAAmB,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAgB,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAuB,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAIL,aAAa,GAEd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,SAAS,EAAkB,MAA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AAM,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,oBAAqB,CAAW,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC;AACH,CAAC"}
|
package/dist/direct.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Op } from "./op.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Whether an operation may be called directly, outside a run (`SanomaClient.call`), as the
|
|
4
|
+
* person: a collection's (`data.<name>.<op>`), or a `read` that is neither the runtime's own
|
|
5
|
+
* (the vendor `sanoma`) nor a resource type's (`isResourceOp`), which only drift and apply call.
|
|
6
|
+
* Anything else (an effect at a vendor) is a workflow's. The one rule: the built-in `call`
|
|
7
|
+
* workflow, the SDK and the app read it, from here or from `OpEntry.direct`, and never derive it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const isDirect: (op: Pick<Op, "vendor" | "resource" | "effect">, types: ReadonlyMap<string, unknown>) => boolean;
|