@sanoma-ai/workflows 0.2.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.
Files changed (144) hide show
  1. package/README.md +121 -62
  2. package/dist/approvals.d.ts +11 -6
  3. package/dist/approvals.js +38 -10
  4. package/dist/approvals.js.map +1 -1
  5. package/dist/call-workflow.d.ts +16 -0
  6. package/dist/call-workflow.js +35 -0
  7. package/dist/call-workflow.js.map +1 -0
  8. package/dist/call.d.ts +33 -4
  9. package/dist/call.js +107 -42
  10. package/dist/call.js.map +1 -1
  11. package/dist/cedar.d.ts +87 -0
  12. package/dist/cedar.js +365 -0
  13. package/dist/cedar.js.map +1 -0
  14. package/dist/client.d.ts +85 -7
  15. package/dist/client.js +289 -25
  16. package/dist/client.js.map +1 -1
  17. package/dist/collection.d.ts +107 -0
  18. package/dist/collection.js +306 -0
  19. package/dist/collection.js.map +1 -0
  20. package/dist/config.d.ts +42 -14
  21. package/dist/config.js +82 -18
  22. package/dist/config.js.map +1 -1
  23. package/dist/constructors.d.ts +2 -0
  24. package/dist/constructors.js +5 -0
  25. package/dist/constructors.js.map +1 -0
  26. package/dist/data.d.ts +2 -0
  27. package/dist/data.js +3 -0
  28. package/dist/data.js.map +1 -0
  29. package/dist/datafile.d.ts +28 -2
  30. package/dist/datafile.js +118 -19
  31. package/dist/datafile.js.map +1 -1
  32. package/dist/db.d.ts +5 -3
  33. package/dist/db.js +88 -21
  34. package/dist/db.js.map +1 -1
  35. package/dist/define.d.ts +10 -4
  36. package/dist/define.js +1 -5
  37. package/dist/define.js.map +1 -1
  38. package/dist/describe.d.ts +45 -5
  39. package/dist/describe.js +72 -7
  40. package/dist/describe.js.map +1 -1
  41. package/dist/direct.d.ts +9 -0
  42. package/dist/direct.js +11 -0
  43. package/dist/direct.js.map +1 -0
  44. package/dist/errors.d.ts +16 -1
  45. package/dist/errors.js +30 -1
  46. package/dist/errors.js.map +1 -1
  47. package/dist/expectations.d.ts +3 -3
  48. package/dist/expectations.js +16 -7
  49. package/dist/expectations.js.map +1 -1
  50. package/dist/index.d.ts +8 -4
  51. package/dist/index.js +10 -4
  52. package/dist/index.js.map +1 -1
  53. package/dist/ledger.d.ts +12 -1
  54. package/dist/ledger.js +18 -11
  55. package/dist/ledger.js.map +1 -1
  56. package/dist/lint.d.ts +5 -4
  57. package/dist/lint.js +24 -7
  58. package/dist/lint.js.map +1 -1
  59. package/dist/op.d.ts +6 -0
  60. package/dist/op.js.map +1 -1
  61. package/dist/outline.d.ts +2 -0
  62. package/dist/outline.js +1 -1
  63. package/dist/outline.js.map +1 -1
  64. package/dist/paths.d.ts +4 -0
  65. package/dist/paths.js +17 -3
  66. package/dist/paths.js.map +1 -1
  67. package/dist/person.d.ts +61 -0
  68. package/dist/person.js +69 -0
  69. package/dist/person.js.map +1 -0
  70. package/dist/plugin.js +1 -1
  71. package/dist/plugin.js.map +1 -1
  72. package/dist/policy.d.ts +51 -55
  73. package/dist/policy.js +14 -36
  74. package/dist/policy.js.map +1 -1
  75. package/dist/resource.d.ts +21 -5
  76. package/dist/resource.js +12 -3
  77. package/dist/resource.js.map +1 -1
  78. package/dist/resources.d.ts +58 -6
  79. package/dist/resources.js +119 -26
  80. package/dist/resources.js.map +1 -1
  81. package/dist/run.d.ts +17 -1
  82. package/dist/run.js.map +1 -1
  83. package/dist/scenario.d.ts +16 -9
  84. package/dist/scenario.js +93 -20
  85. package/dist/scenario.js.map +1 -1
  86. package/dist/scenarios.d.ts +10 -6
  87. package/dist/scenarios.js +8 -4
  88. package/dist/scenarios.js.map +1 -1
  89. package/dist/schema.d.ts +32 -0
  90. package/dist/schema.js +225 -0
  91. package/dist/schema.js.map +1 -0
  92. package/dist/sdk.d.ts +34 -0
  93. package/dist/sdk.js +168 -0
  94. package/dist/sdk.js.map +1 -0
  95. package/dist/shared.d.ts +181 -5
  96. package/dist/shared.js +160 -7
  97. package/dist/shared.js.map +1 -1
  98. package/dist/sites.d.ts +52 -0
  99. package/dist/sites.js +174 -0
  100. package/dist/sites.js.map +1 -0
  101. package/dist/version.d.ts +3 -2
  102. package/dist/version.js +3 -2
  103. package/dist/version.js.map +1 -1
  104. package/dist/worker.d.ts +3 -2
  105. package/dist/worker.js +24 -4
  106. package/dist/worker.js.map +1 -1
  107. package/oxlint.json +5 -16
  108. package/package.json +8 -3
  109. package/src/approvals.ts +49 -13
  110. package/src/call-workflow.ts +44 -0
  111. package/src/call.ts +157 -45
  112. package/src/cedar.ts +493 -0
  113. package/src/client.ts +368 -37
  114. package/src/collection.ts +431 -0
  115. package/src/config.ts +131 -34
  116. package/src/constructors.ts +4 -0
  117. package/src/data.ts +10 -0
  118. package/src/datafile.ts +141 -21
  119. package/src/db.ts +90 -22
  120. package/src/define.ts +11 -9
  121. package/src/describe.ts +113 -10
  122. package/src/direct.ts +15 -0
  123. package/src/errors.ts +36 -1
  124. package/src/expectations.ts +17 -8
  125. package/src/index.ts +33 -2
  126. package/src/ledger.ts +35 -17
  127. package/src/lint.ts +29 -12
  128. package/src/op.ts +6 -0
  129. package/src/outline.ts +1 -1
  130. package/src/paths.ts +18 -3
  131. package/src/person.ts +75 -0
  132. package/src/plugin.ts +1 -1
  133. package/src/policy.ts +59 -63
  134. package/src/resource.ts +35 -8
  135. package/src/resources.ts +165 -24
  136. package/src/run.ts +18 -1
  137. package/src/scenario.ts +128 -33
  138. package/src/scenarios.ts +15 -8
  139. package/src/schema.ts +261 -0
  140. package/src/sdk.ts +211 -0
  141. package/src/shared.ts +271 -8
  142. package/src/sites.ts +220 -0
  143. package/src/version.ts +3 -2
  144. package/src/worker.ts +29 -6
package/dist/config.js CHANGED
@@ -4,12 +4,17 @@ import { pathToFileURL } from "node:url";
4
4
  import { DBOS } from "@dbos-inc/dbos-sdk";
5
5
  import { applyWorkflow } from "./apply.js";
6
6
  import { applySteps } from "./apply-steps.js";
7
+ import { callWorkflow } from "./call-workflow.js";
8
+ import { collectionsConnector, collectionsDriver, collectionsFake, isCollection, } from "./collection.js";
9
+ import { lazyPool } from "./db.js";
7
10
  import { callerFile } from "./define.js";
8
11
  import { DRIFT_WORKFLOW, driftWorkflow } from "./drift.js";
9
12
  import { statusesOf, unconfigured } from "./env.js";
13
+ import { peopleConnector } from "./person.js";
10
14
  import { DriverError, isOp, checkConnector, setupOf, VENDOR, } from "./op.js";
15
+ import { policyAt } from "./cedar.js";
11
16
  import { isChangeOp, resourceTypesOf, withoutWriteOnly } from "./resource.js";
12
- import { APPLY_WORKFLOW, BUILT_IN_WORKFLOWS } from "./shared.js";
17
+ import { APPLY_WORKFLOW, BUILT_IN_WORKFLOWS, CALL_WORKFLOW, DATA_VENDOR } from "./shared.js";
13
18
  import { sourceDriver, sourceOps } from "./source.js";
14
19
  import { computeVersion } from "./version.js";
15
20
  export const DEFAULT_DATABASE_URL = "postgresql://postgres:dbos@localhost:5433/sanoma";
@@ -43,12 +48,13 @@ export function rootOf(config) {
43
48
  }
44
49
  /**
45
50
  * Checks a config and derives what the runtime needs from it: the drivers and fakes from the
46
- * connectors' setups (`withSetup`), and from `root`, the app's name (`package.json`) and the
47
- * scenarios (`scenarios/`). Throws what `startWorker` would refuse, with the same message, so
48
- * `describeConfig`, `SanomaClient.connect` and the app fail the same way the worker does. It
49
- * opens nothing and reads no file outside `root`. Each entry
50
- * point resolves once: the worker and the client when they start, the app at `startApp`, the
51
- * `sanoma` bin when it loads the config.
51
+ * connectors' setups (`withSetup`), the collections' operations, driver and fake, and from
52
+ * `root`, the app's name (`package.json`), the scenarios (`scenarios/`) and the policy
53
+ * (`policies/`, `policyAt`). Throws what
54
+ * `startWorker` would refuse, with the same message, so `describeConfig`, `SanomaClient.connect`
55
+ * and the app fail the same way the worker does. It opens nothing and reads no file outside
56
+ * `root`. Each entry point resolves once: the worker and the client when they start, the app at
57
+ * `startApp`, the `sanoma` bin when it loads the config.
52
58
  */
53
59
  export function resolveConfig(config) {
54
60
  if (!Array.isArray(config.connectors)) {
@@ -59,12 +65,14 @@ export function resolveConfig(config) {
59
65
  if (!Array.isArray(config.workflows)) {
60
66
  throw new Error("The config needs `workflows`: an array of defineWorkflow definitions");
61
67
  }
62
- if (typeof config.policy !== "function") {
63
- throw new Error("The config needs a `policy`; use `allowAll` to allow every operation call");
64
- }
65
68
  // An untyped config naming fake drivers would otherwise run live. Delete once sanoma-ops has migrated.
66
69
  if (config.drivers !== undefined || config.fakes !== undefined)
67
70
  throw new Error("The config's `drivers` and `fakes` are gone: each connector carries its driver and its fake; leave them out");
71
+ // An untyped config naming its policy would otherwise run allowing everything. Delete once sanoma-ops has migrated.
72
+ if (config.policy !== undefined) {
73
+ throw new Error("The config's `policy` is gone: the policy is policies/*.cedar in the root; leave it out");
74
+ }
75
+ const collections = collectionsOf(config);
68
76
  const ledger = ledgerOf(config);
69
77
  const root = rootOf(config);
70
78
  const appName = appNameAt(root);
@@ -72,10 +80,24 @@ export function resolveConfig(config) {
72
80
  const types = resourceTypesOf(config.connectors);
73
81
  // Built-in: `sanoma.source.resolve`, which apply and drift call for a host's revision.
74
82
  const hosts = [...types.values()].some((type) => type.host);
75
- const ops = indexConnectors([...config.connectors, ...(hosts ? [sourceOps] : [])]);
83
+ // Built-in: the collections' operations, `data.<name>.<op>`, on the config's database.
84
+ const databaseUrl = resolveDatabaseUrl(config);
85
+ const declared = [...collections.values()];
86
+ const dataStore = declared.length ? lazyPool(databaseUrl, "data") : undefined;
87
+ const ops = indexConnectors([
88
+ ...config.connectors,
89
+ ...(hosts ? [sourceOps] : []),
90
+ ...(dataStore ? [collectionsConnector(declared)] : []),
91
+ ]);
76
92
  const driversByVendor = new Map([...makersOf(config.connectors, "driver")].map(([vendor, make]) => [vendor, make()]));
77
- const drivers = indexDrivers([...driversByVendor.values(), ...(hosts ? [sourceDriver] : [])], ops);
93
+ const drivers = indexDrivers([
94
+ ...driversByVendor.values(),
95
+ ...(hosts ? [sourceDriver] : []),
96
+ ...(dataStore ? [collectionsDriver(declared, dataStore)] : []),
97
+ ], ops);
78
98
  const fakes = makersOf(config.connectors, "fake");
99
+ if (dataStore)
100
+ fakes.set(DATA_VENDOR, () => collectionsFake(declared));
79
101
  const names = new Map();
80
102
  for (const wf of config.workflows) {
81
103
  if (BUILT_IN_WORKFLOWS.has(wf.name)) {
@@ -90,13 +112,21 @@ export function resolveConfig(config) {
90
112
  }
91
113
  // Built-in: checking the resources the data files declare against their vendors, and applying them.
92
114
  if (types.size) {
93
- const read = () => readDeclared(root, config.connectors, types);
115
+ const connectors = connectorsOf(config);
116
+ // The types the data files may declare: the vendors' and the people's, whose resources are left out.
117
+ const declarable = resourceTypesOf(connectors);
118
+ const read = () => readDeclared(root, connectors, declarable, types);
94
119
  names.set(DRIFT_WORKFLOW, driftWorkflow(types, ops, drivers, () => DBOS.runStep(read, { name: "drift:data-files" })));
95
120
  names.set(APPLY_WORKFLOW, applyWorkflow(types, ops, drivers, applySteps(appName, root, read)));
96
121
  }
122
+ // Built-in: a direct call the policy holds for an approval, made a run, when any operation may be called directly.
123
+ const call = callWorkflow(ops, drivers, types);
124
+ if (call.uses.length)
125
+ names.set(CALL_WORKFLOW, call);
126
+ const { policy, problems: policyProblems } = policyAt(root, { ops, workflows: names, collections });
97
127
  return {
98
128
  appName,
99
- databaseUrl: resolveDatabaseUrl(config),
129
+ databaseUrl,
100
130
  // The built-in's code and operations are part of the app's version, like the config's own.
101
131
  version: computeVersion({ appName, workflows: [...names.values()] }),
102
132
  queueName: `sanoma:${appName}`,
@@ -107,12 +137,43 @@ export function resolveConfig(config) {
107
137
  ...(scenarios && { scenarios }),
108
138
  types,
109
139
  steps: [...new Set([...config.connectors.flatMap((c) => setupOf(c).steps ?? []), ...(config.steps ?? [])])],
140
+ collections,
141
+ ...(dataStore && { dataStore }),
110
142
  workflows: names,
111
- policy: config.policy,
143
+ policy,
144
+ policyProblems,
112
145
  ...(ledger !== undefined && { ledger }),
113
146
  ...(root !== undefined && { root }),
114
147
  };
115
148
  }
149
+ /**
150
+ * The config's collections by name, checked: each one `collection()` made, no two with one name,
151
+ * and no connector of their vendor, `DATA_VENDOR`.
152
+ */
153
+ function collectionsOf(config) {
154
+ const list = config.collections ?? [];
155
+ if (!Array.isArray(list)) {
156
+ throw new Error("The config's `collections` must be an array of the collections `collection()` declares");
157
+ }
158
+ if (config.connectors.some((c) => c[VENDOR].id === DATA_VENDOR)) {
159
+ throw new Error(`A connector in \`connectors\` is of the vendor "${DATA_VENDOR}", which the collections' operations are of; name it otherwise`);
160
+ }
161
+ const collections = new Map();
162
+ for (const c of list) {
163
+ if (!isCollection(c))
164
+ throw new Error("`collections` holds something `collection()` did not make");
165
+ const other = collections.get(c.name);
166
+ if (other && other !== c)
167
+ throw new Error(`Two collections are named "${c.name}"; name each once`);
168
+ collections.set(c.name, c);
169
+ }
170
+ return collections;
171
+ }
172
+ /** The config's connectors and the runtime's people types' (`peopleConnector`): what its data files are read against. */
173
+ export const connectorsOf = (config) => [
174
+ ...config.connectors,
175
+ peopleConnector,
176
+ ];
116
177
  /**
117
178
  * What the connectors' setups attach under `key` (`withSetup`), by vendor id in `connectors`
118
179
  * order. One vendor's connectors may name one maker, as copies of one connector do, never two.
@@ -164,12 +225,15 @@ function scenariosAt(root) {
164
225
  * names one, and stays), which a run never compares and never records, the bindings, the orphans
165
226
  * and the problems.
166
227
  */
167
- async function readDeclared(root, connectors, types) {
228
+ async function readDeclared(root, connectors, declarable, types) {
168
229
  // Loaded when a run reads the files, not with the worker: the reader parses with oxc-parser.
169
230
  const { readDataFiles } = await import("./resources.js");
170
- const { resources, bindings, orphans, problems } = readDataFiles(root, connectors, types);
231
+ const { resources, bindings, orphans, problems } = readDataFiles(root, connectors, declarable);
171
232
  return {
172
- resources: resources.map(({ id, vendor, type, name, identity, binding, desired, refs }) => ({
233
+ // Only `types`' resources have a vendor object to check or apply: not the people's (vendorless).
234
+ resources: resources
235
+ .filter((r) => types.has(`${r.vendor}.${r.type}`))
236
+ .map(({ id, vendor, type, name, identity, binding, desired, refs }) => ({
173
237
  id,
174
238
  vendor,
175
239
  type,
@@ -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AAE,IAAI;gBACxF,2BAA2B,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CACvF,CAAC;QACJ,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;YAC7B,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,yDAAyD,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC,IAAI,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { secret, type Secret } from "./secret.ts";
2
+ export { sanoma } from "./person.ts";
@@ -0,0 +1,5 @@
1
+ // `@sanoma-ai/workflows/resources`: what a data file imports from the runtime: `secret`, which
2
+ // names a stored secret, and `sanoma`, the constructors of its people types (`sanoma.person`, …).
3
+ export { secret } from "./secret.js";
4
+ export { sanoma } from "./person.js";
5
+ //# sourceMappingURL=constructors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constructors.js","sourceRoot":"","sources":["../src/constructors.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,kGAAkG;AAClG,OAAO,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
package/dist/data.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { collection, type Collection, type Field, type FieldType, type RecordOf, type RequiredTextKeys, } from "./collection.ts";
2
+ export type { ListQuery, Saved } from "./shared.ts";
package/dist/data.js ADDED
@@ -0,0 +1,3 @@
1
+ // `@sanoma-ai/workflows/data`: what a company's `resources/data.ts` declares its collections with.
2
+ export { collection, } from "./collection.js";
3
+ //# sourceMappingURL=data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EACL,UAAU,GAMX,MAAM,iBAAiB,CAAC"}
@@ -43,16 +43,38 @@ export interface DataFileExport {
43
43
  start: number;
44
44
  end: number;
45
45
  }
46
+ /** An `export const name = collection({ … })` in `resources/data.ts`, its declaration one `collection()` takes. */
47
+ export interface DataFileCollection {
48
+ /** The `export const`'s name. */
49
+ export: string;
50
+ /** The collection's name. */
51
+ name: string;
52
+ /** The `export const` statement. */
53
+ start: number;
54
+ end: number;
55
+ }
46
56
  export interface DataFile {
47
57
  imports: DataFileImport[];
48
58
  /** Each `export const` whose value is in the subset. */
49
59
  exports: DataFileExport[];
50
- /** Every name an `export const` declares, its value in the subset or not. */
60
+ /** Each collection `resources/data.ts` declares (`COLLECTIONS_FILE`); none in any other data file. */
61
+ collections: DataFileCollection[];
62
+ /** Every name an `export const` declares as a resource, its value in the subset or not: none in `resources/data.ts`. */
51
63
  declared: string[];
52
64
  problems: DataFileProblem[];
53
65
  }
54
- /** Where a data file imports `secret` from; checked before `CONSTRUCTORS`, which they match too. */
66
+ /**
67
+ * Where a data file imports `secret` from, and `sanoma`, the runtime's own resource constructors
68
+ * (its people: `sanoma.person`, `.agent`, `.group`); checked before `CONSTRUCTORS`, which they match too.
69
+ */
55
70
  export declare const SECRET_ENTRIES: ReadonlySet<string>;
71
+ /** Where `resources/data.ts` imports `collection` from, and the only imports it may make. */
72
+ export declare const DATA_ENTRIES: ReadonlySet<string>;
73
+ /**
74
+ * The one data file that holds collections, relative to `resources/`. Workflows and the runtime
75
+ * import it, so it imports only `collection` from "sanoma/data" and holds nothing else.
76
+ */
77
+ export declare const COLLECTIONS_FILE = "data.ts";
56
78
  /**
57
79
  * Reads a data file's program without running it: its imports, each `export const` resource
58
80
  * with its fields evaluated, and everything outside the data-file subset as a problem that says
@@ -62,6 +84,10 @@ export declare const SECRET_ENTRIES: ReadonlySet<string>;
62
84
  * `export const <name> = <vendor>.<type>({ … })`, one per statement, its argument built of
63
85
  * strings (template literals without `${}` too), numbers, booleans, null, objects and arrays,
64
86
  * and names of resources this file declares or imports; and `export default [a, b]`.
87
+ * `resources/data.ts` (`COLLECTIONS_FILE`) is the exception, the one data file workflows and the
88
+ * runtime import: it imports only `collection` from "sanoma/data", and each `export const` is
89
+ * `collection({ … })` with its values written out (`DataFile.collections`). No other data file
90
+ * declares a collection, and none imports one.
65
91
  *
66
92
  * `root` is the directory relative imports must stay in: by default the nearest `resources/`
67
93
  * directory above `filename`, else the file's own.
package/dist/datafile.js CHANGED
@@ -1,6 +1,7 @@
1
- import { basename, dirname, join } from "node:path";
1
+ import { basename, dirname, join, relative } from "node:path";
2
2
  import { inside, nearestDir, RELATIVE } from "./paths.js";
3
3
  import { SECRET_NAME } from "./secret.js";
4
+ import { checkCollection, errorMessage } from "./shared.js";
4
5
  /** A name in a data file that refers to a declared resource: one imported from a data file, or exported by this one. */
5
6
  export class Reference {
6
7
  name;
@@ -14,8 +15,21 @@ Object.defineProperty(Reference.prototype, REFERENCE, { value: true });
14
15
  export const isReference = (value) => typeof value === "object" && value !== null && REFERENCE in value;
15
16
  /** A connector's constructors entry: a package specifier that ends in `/resources`. */
16
17
  const CONSTRUCTORS = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*\/resources$/;
17
- /** Where a data file imports `secret` from; checked before `CONSTRUCTORS`, which they match too. */
18
+ /**
19
+ * Where a data file imports `secret` from, and `sanoma`, the runtime's own resource constructors
20
+ * (its people: `sanoma.person`, `.agent`, `.group`); checked before `CONSTRUCTORS`, which they match too.
21
+ */
18
22
  export const SECRET_ENTRIES = new Set(["sanoma/resources", "@sanoma-ai/workflows/resources"]);
23
+ /** Where `resources/data.ts` imports `collection` from, and the only imports it may make. */
24
+ export const DATA_ENTRIES = new Set(["sanoma/data", "@sanoma-ai/workflows/data"]);
25
+ /**
26
+ * The one data file that holds collections, relative to `resources/`. Workflows and the runtime
27
+ * import it, so it imports only `collection` from "sanoma/data" and holds nothing else.
28
+ */
29
+ export const COLLECTIONS_FILE = "data.ts";
30
+ const COLLECTION_CALL = '`export const <name> = collection({ name: "…", key: "…", fields: { … } })`';
31
+ const COLLECTIONS_ONLY = "resources/data.ts holds collections only, since workflows and the runtime import it: " +
32
+ `\`import { collection } from "sanoma/data"\` and ${COLLECTION_CALL}; declare a connector's resources in another data file`;
19
33
  const SECRET_CALL = '`secret("NAME")` or `secret("NAME", { generate: true })`, NAME upper case (A-Z, 0-9 and _)';
20
34
  const SHAPE = "a data file holds only imports, `export const <name> = <vendor>.<type>({ … })` and `export default [ … ]`";
21
35
  const IMPORTS = "import resource constructors from a connector's resources entry " +
@@ -31,6 +45,10 @@ const VALUES = "write a string, number, boolean, null, object or array, or name
31
45
  * `export const <name> = <vendor>.<type>({ … })`, one per statement, its argument built of
32
46
  * strings (template literals without `${}` too), numbers, booleans, null, objects and arrays,
33
47
  * and names of resources this file declares or imports; and `export default [a, b]`.
48
+ * `resources/data.ts` (`COLLECTIONS_FILE`) is the exception, the one data file workflows and the
49
+ * runtime import: it imports only `collection` from "sanoma/data", and each `export const` is
50
+ * `collection({ … })` with its values written out (`DataFile.collections`). No other data file
51
+ * declares a collection, and none imports one.
34
52
  *
35
53
  * `root` is the directory relative imports must stay in: by default the nearest `resources/`
36
54
  * directory above `filename`, else the file's own.
@@ -40,10 +58,15 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
40
58
  const fail = (node, message) => problems.push({ start: node.start, end: node.end, message });
41
59
  const imports = [];
42
60
  const exports = [];
61
+ const collections = [];
62
+ const collectionsFile = relative(root, filename) === COLLECTIONS_FILE;
63
+ // What the file may hold, for the problems that say so.
64
+ const shape = collectionsFile ? COLLECTIONS_ONLY : SHAPE;
43
65
  // Names a refused import or declaration binds: reported once, where they are bound.
44
66
  const refused = new Set();
45
- // The local names of `secret`.
67
+ // The local names of `secret`, and of `collection`.
46
68
  const secrets = new Set();
69
+ const collectionCalls = new Set();
47
70
  // Imports and top-level names first, each once: imports are hoisted, and a reference may name
48
71
  // a resource declared further down. An unexported const is refused where it is declared, not
49
72
  // again where it is used.
@@ -82,17 +105,17 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
82
105
  readDefault(s);
83
106
  break;
84
107
  case "ExportAllDeclaration":
85
- fail(s, `export * is not allowed in a data file: ${SHAPE}`);
108
+ fail(s, `export * is not allowed in a data file: ${shape}`);
86
109
  break;
87
110
  case "VariableDeclaration": {
88
111
  const name = s.declarations[0]?.id?.name;
89
112
  fail(s, name === undefined
90
- ? `an unexported declaration is not allowed in a data file: ${SHAPE}`
91
- : `\`${s.kind} ${name}\` is not allowed in a data file: export it as a resource, \`export const ${name} = <vendor>.<type>({ … })\`, or write its value where it is used`);
113
+ ? `an unexported declaration is not allowed in a data file: ${shape}`
114
+ : `\`${s.kind} ${name}\` is not allowed in a data file: export it as ${collectionsFile ? `a collection, \`export const ${name} = collection({ … })\`` : `a resource, \`export const ${name} = <vendor>.<type>({ … })\``}, or write its value where it is used`);
92
115
  break;
93
116
  }
94
117
  default:
95
- fail(s, `${describe(s)} is not allowed in a data file: ${SHAPE}`);
118
+ fail(s, `${describe(s)} is not allowed in a data file: ${shape}`);
96
119
  }
97
120
  }
98
121
  function readImport(s) {
@@ -101,6 +124,14 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
101
124
  fail(s, "`import type` is not allowed in a data file: it holds values only, and the constructors type them");
102
125
  return;
103
126
  }
127
+ if (collectionsFile !== DATA_ENTRIES.has(spec)) {
128
+ fail(s.source, collectionsFile
129
+ ? `import "${spec}" is not allowed in resources/data.ts: ${COLLECTIONS_ONLY}`
130
+ : `import "${spec}" is not allowed here: collections are declared in resources/data.ts, the one data file workflows and the runtime import; move it there`);
131
+ for (const sp of s.specifiers)
132
+ refused.add(sp.local.name);
133
+ return;
134
+ }
104
135
  const refusal = whyRefused(spec);
105
136
  if (refusal) {
106
137
  fail(s.source, `import "${spec}" is not allowed in a data file: ${refusal}`);
@@ -112,15 +143,27 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
112
143
  fail(s, `import "${spec}" is not allowed in a data file: it imports nothing, and a data file runs no code`);
113
144
  return;
114
145
  }
115
- if (SECRET_ENTRIES.has(spec)) {
146
+ // The one name each of these entries gives a data file.
147
+ const [only, locals] = SECRET_ENTRIES.has(spec)
148
+ ? ["secret", secrets]
149
+ : DATA_ENTRIES.has(spec)
150
+ ? ["collection", collectionCalls]
151
+ : [];
152
+ if (locals) {
116
153
  for (const sp of s.specifiers) {
117
- if (sp.type === "ImportSpecifier" &&
118
- sp.importKind !== "type" &&
119
- (sp.imported.name ?? sp.imported.value) === "secret") {
120
- secrets.add(sp.local.name);
154
+ const imported = sp.type === "ImportSpecifier" && sp.importKind !== "type" && (sp.imported.name ?? sp.imported.value);
155
+ if (imported === only) {
156
+ locals.add(sp.local.name);
157
+ }
158
+ else if (imported === "sanoma" && SECRET_ENTRIES.has(spec)) {
159
+ // The runtime's own constructors, matched to its connector as a connector's are.
160
+ imports.push({ kind: "constructors", source: spec, imported, local: sp.local.name, start: sp.start });
121
161
  }
122
162
  else {
123
- fail(sp, `a data file imports only \`secret\` from "${spec}": \`import { secret } from "${spec}"\``);
163
+ const [names, allowed] = SECRET_ENTRIES.has(spec)
164
+ ? ["`secret` and `sanoma`", `${only}, sanoma`]
165
+ : [`\`${only}\``, only];
166
+ fail(sp, `a data file imports only ${names} from "${spec}": \`import { ${allowed} } from "${spec}"\``);
124
167
  refused.add(sp.local.name);
125
168
  }
126
169
  }
@@ -144,9 +187,12 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
144
187
  /** Why an import's specifier is not allowed in a data file, or undefined when it is. */
145
188
  function whyRefused(spec) {
146
189
  if (!RELATIVE.test(spec))
147
- return CONSTRUCTORS.test(spec) ? undefined : IMPORTS;
190
+ return CONSTRUCTORS.test(spec) || DATA_ENTRIES.has(spec) ? undefined : IMPORTS;
148
191
  if (!spec.endsWith(".ts"))
149
192
  return "name the data file with its `.ts` extension";
193
+ if (join(dirname(filename), spec) === join(root, COLLECTIONS_FILE)) {
194
+ return "resources/data.ts holds collections, which no resource names; import resources from other data files";
195
+ }
150
196
  if (!inside(root, join(dirname(filename), spec))) {
151
197
  return `it reaches outside ${basename(root)}/; import only other data files`;
152
198
  }
@@ -161,7 +207,7 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
161
207
  return;
162
208
  }
163
209
  if (decl.type !== "VariableDeclaration") {
164
- fail(s, `${describe(decl)} is not allowed in a data file: ${SHAPE}`);
210
+ fail(s, `${describe(decl)} is not allowed in a data file: ${shape}`);
165
211
  return;
166
212
  }
167
213
  if (decl.kind !== "const") {
@@ -179,10 +225,18 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
179
225
  }
180
226
  const name = d.id.name;
181
227
  // A second declaration of the name was reported where it is bound.
182
- if (exports.some((e) => e.name === name))
228
+ if (exports.some((e) => e.name === name) || collections.some((c) => c.export === name))
183
229
  return;
184
230
  const init = d.init;
185
231
  const callee = init?.type === "CallExpression" ? init.callee : undefined;
232
+ // A name a refused import binds was reported with the import.
233
+ const head = callee?.type === "MemberExpression" ? callee.object : callee;
234
+ if (head?.type === "Identifier" && refused.has(head.name))
235
+ return;
236
+ if (collectionsFile) {
237
+ readCollection(s, init, name);
238
+ return;
239
+ }
186
240
  if (callee?.type !== "MemberExpression" ||
187
241
  callee.computed ||
188
242
  callee.object.type !== "Identifier" ||
@@ -192,8 +246,6 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
192
246
  }
193
247
  const vendor = callee.object.name;
194
248
  const type = callee.property.name;
195
- if (refused.has(vendor))
196
- return;
197
249
  if (imports.find((i) => i.local === vendor)?.kind !== "constructors") {
198
250
  fail(callee.object, `${vendor} is not a connector's resource constructors: import it from the connector's resources entry, \`import { ${vendor} } from "@sanoma-ai/connector-${vendor}/resources"\``);
199
251
  return;
@@ -208,7 +260,47 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
208
260
  exports.push({ name, vendor, type, desired: desired, start: s.start, end: s.end });
209
261
  }
210
262
  }
263
+ /** An `export const` in resources/data.ts: a collection, its declaration plain values `collection()` takes. */
264
+ function readCollection(s, init, name) {
265
+ if (init?.type !== "CallExpression" ||
266
+ init.callee.type !== "Identifier" ||
267
+ !collectionCalls.has(init.callee.name)) {
268
+ fail(init ?? s, `export const ${name} must be a collection: ${COLLECTIONS_ONLY}`);
269
+ return;
270
+ }
271
+ const [arg] = init.arguments;
272
+ if (init.arguments.length !== 1 || arg.type !== "ObjectExpression") {
273
+ fail(init, `collection() takes one object literal: ${COLLECTION_CALL}`);
274
+ return;
275
+ }
276
+ const declaration = value(arg);
277
+ if (declaration === undefined) {
278
+ // What value() refused it reported; the collection is still declared here, which the
279
+ // runtime runs, when its name is written out.
280
+ const named = arg.properties.find((p) => p.type === "Property" && !p.computed && keyName(p.key) === "name")?.value;
281
+ if (named?.type === "Literal" && typeof named.value === "string") {
282
+ collections.push({ export: name, name: named.value, start: s.start, end: s.end });
283
+ }
284
+ return;
285
+ }
286
+ if (Object.keys(declaration).some((k) => !DECLARATION_KEYS.has(k)) || namesDeclaration(declaration)) {
287
+ fail(arg, `collection() takes \`{ name, key, fields, title? }\`, its values written out: ${COLLECTION_CALL}`);
288
+ return;
289
+ }
290
+ try {
291
+ checkCollection(declaration);
292
+ }
293
+ catch (err) {
294
+ fail(arg, errorMessage(err));
295
+ return;
296
+ }
297
+ collections.push({ export: name, name: declaration.name, start: s.start, end: s.end });
298
+ }
211
299
  function readDefault(s) {
300
+ if (collectionsFile) {
301
+ fail(s, `export default is not allowed in resources/data.ts: ${COLLECTIONS_ONLY}`);
302
+ return;
303
+ }
212
304
  const list = s.declaration;
213
305
  if (list.type !== "ArrayExpression") {
214
306
  fail(list, "export default must list this file's resources: `export default [a, b]`");
@@ -287,6 +379,9 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
287
379
  case "CallExpression":
288
380
  if (node.callee.type === "Identifier" && secrets.has(node.callee.name))
289
381
  return readSecret(node);
382
+ if (node.callee.type === "Identifier" && collectionCalls.has(node.callee.name)) {
383
+ return refuse(node, `a collection is declared at the top of resources/data.ts: ${COLLECTION_CALL}`);
384
+ }
290
385
  if (node.callee.type === "Identifier" && node.callee.name === "secret" && !bound.has("secret")) {
291
386
  return refuse(node, `import secret to name one: \`import { secret } from "sanoma/resources"\``);
292
387
  }
@@ -365,8 +460,12 @@ export function readDataFile(program, filename, root = nearestDir(filename, ["re
365
460
  fail(node, message);
366
461
  return undefined;
367
462
  }
368
- return { imports, exports, declared: [...declared], problems };
463
+ return { imports, exports, collections, declared: collectionsFile ? [] : [...declared], problems };
369
464
  }
465
+ /** What `collection()` reads of its declaration. */
466
+ const DECLARATION_KEYS = new Set(["name", "key", "fields", "title"]);
467
+ /** True when a value names a declaration: a collection's declaration is plain values only. */
468
+ const namesDeclaration = (v) => v instanceof Reference || (typeof v === "object" && v !== null && Object.values(v).some(namesDeclaration));
370
469
  /** A property's name: an identifier's, or a literal's as a string; undefined for any other key. */
371
470
  export const keyName = (key) => key.type === "Identifier" ? key.name : key.type === "Literal" ? String(key.value) : undefined;
372
471
  /** A node's kind, for a message: `a function declaration`, `an if statement`. */