@formancy/report-data-provider 0.2.0 → 0.3.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 CHANGED
@@ -7,7 +7,10 @@ the client carries. It reads the header's one record, the detail rows a
7
7
  page at a time and each lookup's label, and hands over the data
8
8
  `@formancy/report-runtime` renders from, or every reason it will not. No
9
9
  framework and no Node. It is the one package of this repository that may
10
- depend on Data's contracts. What it decides, and why, is decision
10
+ depend on Data's contracts; the report server depends on Data's identity
11
+ verifier alone, and reads no record
12
+ ([0047](../../docs/decisions/0047-report-server-verifies-the-hosts-token-with-formancy-datas-data-identity-0-3-0.md)).
13
+ What it decides, and why, is decision
11
14
  [0016](../../docs/decisions/0016-the-data-provider-reads-formancy-data-0-1-0-best-effort.md).
12
15
 
13
16
  **Best-effort.** Data 0.1.0 has no snapshot export, so the header, each
@@ -16,6 +19,17 @@ its `consistency`, and the render's manifest carries it. A row changed
16
19
  between two pages can be printed twice or not at all, and a total can mix
17
20
  moments.
18
21
 
22
+ **Its source.** The data names the published form each dataset was read
23
+ from, by the id the binding addressed it by -- `{ provider:
24
+ 'formancy-data', forms: { header: 'quotation', detail: 'quotation-line' }
25
+ }` -- and the render's manifest carries it as `source`
26
+ ([0041](../../docs/decisions/0041-a-renders-manifest-names-where-its-data-came-from-by-identifiers-alone.md)).
27
+ Data 0.1.0 publishes a form only under its own id, so a form answered
28
+ under another is refused, below. A report that reads no dataset names no
29
+ source. It names no record: a record's token spells the record's key
30
+ (formancy.ai-data 0012), and a key can be the customer's own data. Nor
31
+ which publication of a form answered, which Data 0.1.0 does not say.
32
+
19
33
  ## Read a report's data
20
34
 
21
35
  ```ts
@@ -50,6 +64,8 @@ A report field reads the form field with the same key.
50
64
 
51
65
  **The checks before any record is read:**
52
66
  - every dataset is bound, and nothing else;
67
+ - each form Data answers is published under the id the binding names,
68
+ a formancy form id, or it is refused as `unexpected-form`;
53
69
  - every field the report declares is one the form lets this person read;
54
70
  - no field is an image, since Data 0.1.0 holds no approved asset;
55
71
  - the detail form offers this person a list;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { DataClient, ListSortTerm } from "@formancy/data-client";
2
2
  import { ReportData } from "@formancy/report-runtime";
3
3
  import { ReportDefinition } from "@formancy/report-spec";
4
- //#region src/binding.d.ts
5
4
  /** The header's one record: a published form, and the token that addresses the record in it. */
6
5
  interface HeaderBinding {
7
6
  readonly form: string;
@@ -27,7 +26,7 @@ interface DataBinding {
27
26
  readonly header?: HeaderBinding;
28
27
  readonly detail?: DetailBinding;
29
28
  }
30
- export declare const PROVIDER_ERROR_CODES: readonly ["invalid-report", "invalid-cap", "unbound-dataset", "undeclared-dataset", "unknown-parent", "unreadable-field", "unsupported-field", "not-listable", "unresolved-label", "refused"];
29
+ export declare const PROVIDER_ERROR_CODES: readonly ["invalid-report", "invalid-cap", "unbound-dataset", "undeclared-dataset", "unknown-parent", "unreadable-field", "unsupported-field", "not-listable", "unexpected-form", "unresolved-label", "refused"];
31
30
  type ProviderErrorCode = (typeof PROVIDER_ERROR_CODES)[number];
32
31
  /**
33
32
  * What the provider can say is wrong. The path is a JSON Pointer into the
@@ -47,8 +46,6 @@ interface ProviderError {
47
46
  readonly code: string;
48
47
  };
49
48
  }
50
- //#endregion
51
- //#region src/read.d.ts
52
49
  interface ReadOptions {
53
50
  /**
54
51
  * The most detail rows to read: a whole number from 1 to the runtime's
@@ -70,10 +67,9 @@ type ProviderRead = {
70
67
  * The data `report` renders from, read from Formancy Data through `client`
71
68
  * where `binding` says, or every reason it was not. Its consistency is
72
69
  * `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and
73
- * each label are read at different moments. Rejects only with the abort
74
- * `options.signal` raised.
70
+ * each label are read at different moments. Its source names the forms it
71
+ * read (0041). Rejects only with the abort `options.signal` raised.
75
72
  */
76
73
  export declare function readReportData(client: DataClient, report: ReportDefinition, binding: DataBinding, options?: ReadOptions): Promise<ProviderRead>;
77
- //#endregion
78
74
  export type { DataBinding, DetailBinding, HeaderBinding, ProviderError, ProviderErrorCode, ProviderRead, ReadOptions };
79
75
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/binding.ts","../src/read.ts"],"mappings":";;;;;UASiB;WACN;WACA;;;;;;;;;UAUM;WACN;WACA;aAA+B;aAAwB;;WACvD,gBAAgB;;;UAIV;WACN,SAAS;WACT,SAAS;;qBAGP;KAsBD,4BAA4B;;;;;;;;;UAUvB;WACN;WACA,MAAM;WACN;;WAEA;aAAqB;aAAyB;;;;;UCjDxC;;;;;;WAMN;;WAEA,SAAS;;KAGR;WAA0B;WAAmB,MAAM;;WAA0B;WAAoB,iBAAiB;;;;;;;;;wBAkGxG,eAAe,QAAQ,YAAY,QAAQ,kBAAkB,SAAS,aAAa,UAAS,cAAmB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/binding.ts","../src/read.ts"],"mappings":";;;;UASiB;WACN;WACA;;;;;;;;;UAUM;WACN;WACA;aAA+B;aAAwB;;WACvD,gBAAgB;;;UAIV;WACN,SAAS;WACT,SAAS;;qBAGP;KAwBD,4BAA4B;;;;;;;;;UAUvB;WACN;WACA,MAAM;WACN;;WAEA;aAAqB;aAAyB;;;UC3CxC;;;;;;WAMN;;WAEA,SAAS;;KAGR;WAA0B;WAAmB,MAAM;;WAA0B;WAAoB,iBAAiB;;;;;;;;;wBA2HxG,eAAe,QAAQ,YAAY,QAAQ,kBAAkB,SAAS,aAAa,UAAS,cAAmB,QAAQ"}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { LIST_PAGE_SIZE } from "@formancy/data-client";
2
2
  import { MAX_DETAIL_ROWS } from "@formancy/report-runtime";
3
- import { validateReport } from "@formancy/report-spec";
4
- //#region src/binding.ts
3
+ import { isFormId, validateReport } from "@formancy/report-spec";
4
+ // src/binding.ts
5
5
  const PROVIDER_ERROR_CODES = [
6
6
  "invalid-report",
7
7
  "invalid-cap",
@@ -11,6 +11,7 @@ const PROVIDER_ERROR_CODES = [
11
11
  "unreadable-field",
12
12
  "unsupported-field",
13
13
  "not-listable",
14
+ "unexpected-form",
14
15
  "unresolved-label",
15
16
  "refused"
16
17
  ];
@@ -85,8 +86,7 @@ function planFields(role, contract, published) {
85
86
  errors
86
87
  };
87
88
  }
88
- //#endregion
89
- //#region src/read.ts
89
+ // src/read.ts
90
90
  /**
91
91
  * A report's data, read from Formancy Data 0.1.0's runtime plane through
92
92
  * `@formancy/data-client`, as the person whose token the client carries:
@@ -98,6 +98,14 @@ function planFields(role, contract, published) {
98
98
  * The values are Data's, as Data gave them, with one translation: a
99
99
  * nullable yes-or-no's "true" and "false" become booleans. Whether each
100
100
  * fits its field is the runtime's to say, once (0010).
101
+ *
102
+ * The data names its source: the published form each dataset was read
103
+ * from, by the id the binding addressed it by, which the render's manifest
104
+ * carries (0041). Data 0.1.0 publishes a form only under its own id, so a
105
+ * form answered under another is refused before any record is read. Not
106
+ * the header record's token: a token spells the record's key
107
+ * (formancy.ai-data 0012), and a key can be the customer's own data. Data
108
+ * read from no form names no source.
101
109
  */
102
110
  const refused = (errors) => ({
103
111
  ok: false,
@@ -212,8 +220,8 @@ async function labelled(client, role, form, plan, records, signal) {
212
220
  * The data `report` renders from, read from Formancy Data through `client`
213
221
  * where `binding` says, or every reason it was not. Its consistency is
214
222
  * `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and
215
- * each label are read at different moments. Rejects only with the abort
216
- * `options.signal` raised.
223
+ * each label are read at different moments. Its source names the forms it
224
+ * read (0041). Rejects only with the abort `options.signal` raised.
217
225
  */
218
226
  async function readReportData(client, report, binding, options = {}) {
219
227
  const { signal } = options;
@@ -234,6 +242,7 @@ async function readReportData(client, report, binding, options = {}) {
234
242
  const unbound = bindingErrors(datasets, binding);
235
243
  if (unbound.length > 0) return refused(unbound);
236
244
  const plans = /* @__PURE__ */ new Map();
245
+ const forms = {};
237
246
  const errors = [];
238
247
  for (const role of ROLES) {
239
248
  const contract = datasets[role];
@@ -242,6 +251,11 @@ async function readReportData(client, report, binding, options = {}) {
242
251
  signal?.throwIfAborted();
243
252
  const published = await client.form(bound.form);
244
253
  if (!published.ok) return refused([fromRefusal(`/${role}`, published)]);
254
+ if (published.value.form.id !== bound.form || !isFormId(bound.form)) return refused([{
255
+ path: `/${role}`,
256
+ code: "unexpected-form",
257
+ message: `Data answered the ${role} form with a published form under another id, or one that is no formancy form id; Data 0.1.0 publishes a form only under its own`
258
+ }]);
245
259
  const { plan, errors: found } = planFields(role, contract, published.value);
246
260
  errors.push(...found);
247
261
  if (role === "detail" && published.value.list === null) errors.push({
@@ -250,6 +264,7 @@ async function readReportData(client, report, binding, options = {}) {
250
264
  message: "the detail form offers this person no list of its records"
251
265
  });
252
266
  plans.set(role, plan);
267
+ forms[role] = bound.form;
253
268
  }
254
269
  let parent;
255
270
  if (binding.detail !== void 0) {
@@ -279,6 +294,10 @@ async function readReportData(client, report, binding, options = {}) {
279
294
  errors.push(...await labelled(client, "detail", binding.detail.form, detailPlan, detail.rows, signal));
280
295
  }
281
296
  if (errors.length > 0) return refused(errors);
297
+ const source = Object.keys(forms).length === 0 ? void 0 : {
298
+ provider: "formancy-data",
299
+ forms
300
+ };
282
301
  return {
283
302
  ok: true,
284
303
  data: {
@@ -292,11 +311,11 @@ async function readReportData(client, report, binding, options = {}) {
292
311
  captured: detail.rows.length,
293
312
  cap
294
313
  },
295
- consistency: "best-effort"
314
+ consistency: "best-effort",
315
+ ...source === void 0 ? {} : { source }
296
316
  }
297
317
  };
298
318
  }
299
- //#endregion
300
319
  export { PROVIDER_ERROR_CODES, readReportData };
301
320
 
302
321
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/binding.ts","../src/read.ts"],"sourcesContent":["/**\n * Where a report's datasets come from in Formancy Data, and what a published\n * form says about the fields a report reads from it -- everything the\n * provider can check before it reads a record.\n */\nimport type { ListSortTerm, PublishedForm } from '@formancy/data-client'\nimport type { DatasetContract, DatasetRole, Datasets } from '@formancy/report-spec'\n\n/** The header's one record: a published form, and the token that addresses the record in it. */\nexport interface HeaderBinding {\n readonly form: string\n readonly record: string\n}\n\n/**\n * The detail rows: a published form's records, in the order of `sort`\n * (Data's key order when there is none). `parent` narrows them to one\n * record's children: `'header'` for the header record's, by the lookup\n * field the person's menu names between the two forms, or a field and a\n * record token given outright.\n */\nexport interface DetailBinding {\n readonly form: string\n readonly parent?: 'header' | { readonly field: string; readonly record: string }\n readonly sort?: readonly ListSortTerm[]\n}\n\n/** Which published form each of the report's datasets reads. */\nexport interface DataBinding {\n readonly header?: HeaderBinding\n readonly detail?: DetailBinding\n}\n\nexport const PROVIDER_ERROR_CODES = [\n /** A report that `validateReport` refuses: the runtime would refuse it too, and says why. */\n 'invalid-report',\n /** A cap that is not a whole number from 1 to the runtime's `MAX_DETAIL_ROWS`. */\n 'invalid-cap',\n /** A dataset the report declares and the binding does not say where to read. */\n 'unbound-dataset',\n /** A binding for a dataset the report does not declare. */\n 'undeclared-dataset',\n /** `parent: 'header'`, and the person's menu does not name the detail form as the header form's child exactly once. */\n 'unknown-parent',\n /** A field the report declares that the form does not let this person read, or does not have. */\n 'unreadable-field',\n /** An image field: Data 0.1.0 holds no approved asset for one to print. */\n 'unsupported-field',\n /** The detail form offers this person no list of its records. */\n 'not-listable',\n /** A lookup value whose label Data did not give this person. */\n 'unresolved-label',\n /** Data refused a request; `refusal` carries its status and code, and the message is its sentence. */\n 'refused',\n] as const\nexport type ProviderErrorCode = (typeof PROVIDER_ERROR_CODES)[number]\n\n/**\n * What the provider can say is wrong. The path is a JSON Pointer into the\n * binding -- `/detail/parent` -- or into the data it would have handed over\n * -- `/header/customer`, `/detail/17/order`. Neither it nor the message\n * ever holds a value: a token or an answer is the customer's, and an error\n * ends up in a log. Data's own sentences promise the same\n * (formancy.ai-data 0011).\n */\nexport interface ProviderError {\n readonly path: string\n readonly code: ProviderErrorCode\n readonly message: string\n /** Data's answer, when Data refused: its HTTP status (0 when nothing answered) and its code. */\n readonly refusal?: { readonly status: number; readonly code: string }\n}\n\nexport const ROLES: readonly DatasetRole[] = ['header', 'detail']\n\n/** A binding that says where each declared dataset is, and nothing else. */\nexport function bindingErrors(datasets: Datasets, binding: DataBinding): ProviderError[] {\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const declared = datasets[role] !== undefined\n const bound = binding[role] !== undefined\n if (declared && !bound) errors.push({ path: `/${role}`, code: 'unbound-dataset', message: `the report reads a ${role} dataset and the binding names no form for it` })\n if (bound && !declared) errors.push({ path: `/${role}`, code: 'undeclared-dataset', message: `the binding names a form for a ${role} dataset the report does not declare` })\n }\n return errors\n}\n\ntype Field = PublishedForm['form']['model']['fields'][number]\n\n/** Every field whose answer is in a record, by key: groups and pages hold fields of the record; a repeater's are inside its rows. */\nfunction answeredFields(fields: readonly Field[], into = new Map<string, Field>()): Map<string, Field> {\n for (const field of fields) {\n if (field.type === 'group' || field.type === 'page') answeredFields(field.fields ?? [], into)\n else if (field.type !== 'repeater') into.set(field.key, field)\n }\n return into\n}\n\n/**\n * A nullable yes-or-no column, as Data generates its control: a radio of\n * exactly \"true\" and \"false\" (formancy.ai-data's controls), whose answer is\n * one of those strings or null. A report that reads it as a boolean gets\n * true or false.\n */\nfunction isYesOrNo(field: Field): boolean {\n const values = (field.options ?? []).map((option) => option.value)\n return field.type === 'radio' && values.length === 2 && values.includes('true') && values.includes('false')\n}\n\n/** How the provider reads one dataset's fields from a form: which are lookups, by source, and which yes-or-no strings become booleans. */\nexport interface FieldPlan {\n readonly fields: readonly string[]\n readonly lookups: ReadonlyMap<string, string>\n readonly yesOrNo: ReadonlySet<string>\n}\n\n/**\n * What `published` says about reading `contract` from it, for this person:\n * every declared field readable, none an image, and how each is read.\n */\nexport function planFields(role: DatasetRole, contract: DatasetContract, published: PublishedForm): { plan: FieldPlan; errors: ProviderError[] } {\n const readable = new Set(published.readable)\n const fields = answeredFields(published.form.model.fields)\n const errors: ProviderError[] = []\n const lookups = new Map<string, string>()\n const yesOrNo = new Set<string>()\n for (const declared of contract.fields) {\n const path = `/${role}/${declared.id}`\n const field = fields.get(declared.id)\n if (declared.type === 'image') {\n errors.push({ path, code: 'unsupported-field', message: `${declared.id} is an image field, and a Formancy Data 0.1.0 form holds no approved asset to print` })\n } else if (field === undefined || !readable.has(declared.id)) {\n errors.push({ path, code: 'unreadable-field', message: `the form gives this person no field ${declared.id} to read: the form does not have it, or its policy does not let them read it` })\n } else if (typeof field.optionsSource === 'string') {\n lookups.set(declared.id, field.optionsSource)\n } else if (declared.type === 'boolean' && isYesOrNo(field)) {\n yesOrNo.add(declared.id)\n }\n }\n return { plan: { fields: contract.fields.map((field) => field.id), lookups, yesOrNo }, errors }\n}\n","/**\n * A report's data, read from Formancy Data 0.1.0's runtime plane through\n * `@formancy/data-client`, as the person whose token the client carries:\n * the header's one record, the detail rows a page at a time, and each\n * lookup's label. Everything that can be checked without a record -- the\n * binding, the fields the person may read, the parent -- is checked first,\n * and a refusal anywhere hands over nothing.\n *\n * The values are Data's, as Data gave them, with one translation: a\n * nullable yes-or-no's \"true\" and \"false\" become booleans. Whether each\n * fits its field is the runtime's to say, once (0010).\n */\nimport { LIST_PAGE_SIZE } from '@formancy/data-client'\nimport type { DataClient, FormRecord, Refusal } from '@formancy/data-client'\nimport { MAX_DETAIL_ROWS } from '@formancy/report-runtime'\nimport type { ReportData } from '@formancy/report-runtime'\nimport { validateReport } from '@formancy/report-spec'\nimport type { DatasetRole, ReportDefinition } from '@formancy/report-spec'\nimport { bindingErrors, planFields, ROLES } from './binding.js'\nimport type { DataBinding, DetailBinding, FieldPlan, HeaderBinding, ProviderError } from './binding.js'\n\nexport interface ReadOptions {\n /**\n * The most detail rows to read: a whole number from 1 to the runtime's\n * `MAX_DETAIL_ROWS`, which is the default. With more rows than that, the\n * data says it is incomplete, and a final render refuses it.\n */\n readonly cap?: number\n /** Stops the reads still to come; the call then rejects with the abort. */\n readonly signal?: AbortSignal\n}\n\nexport type ProviderRead = { readonly ok: true; readonly data: ReportData } | { readonly ok: false; readonly errors: readonly ProviderError[] }\n\ntype Answers = Record<string, unknown>\ntype Parent = { readonly field: string; readonly record: string }\n\nconst refused = (errors: readonly ProviderError[]): ProviderRead => ({ ok: false, errors })\n\n/** Data's refusal, as the provider passes it on: Data's sentence, status and code. */\nfunction fromRefusal(path: string, refusal: Refusal): ProviderError {\n return { path, code: 'refused', message: refusal.message, refusal: { status: refusal.status, code: refusal.code } }\n}\n\n/** The declared fields of one record, nothing else it holds, with yes-or-no strings read as booleans. */\nfunction pick(record: FormRecord, plan: FieldPlan): Answers {\n const answers: Answers = {}\n for (const field of plan.fields) {\n if (!Object.hasOwn(record.answers, field)) continue\n const value = record.answers[field]\n answers[field] = plan.yesOrNo.has(field) && (value === 'true' || value === 'false') ? value === 'true' : value\n }\n return answers\n}\n\n/** The parent the detail rows are narrowed to: given, or the header record by the one field the person's menu names. */\nasync function parentOf(client: DataClient, header: HeaderBinding | undefined, detail: DetailBinding, signal?: AbortSignal): Promise<Parent | undefined | ProviderError> {\n if (detail.parent !== 'header') return detail.parent\n const unknown = (message: string): ProviderError => ({ path: '/detail/parent', code: 'unknown-parent', message })\n if (header === undefined) return unknown(\"parent 'header' reads the header record's children, and the binding names no header record\")\n const menu = await client.forms(signal)\n if (!menu.ok) return fromRefusal('/detail/parent', menu)\n const children = menu.value.forms.find((form) => form.id === header.form)?.children ?? []\n const fields = children.filter((child) => child.form === detail.form).map((child) => child.field)\n const [field] = fields\n if (fields.length === 1 && field !== undefined) return { field, record: header.record }\n return unknown(\n fields.length === 0\n ? \"this person's menu does not list the detail form as a child of the header form\"\n : \"this person's menu lists the detail form under the header form by more than one field; name the field in parent\",\n )\n}\n\n/** Every detail row up to `cap`, a page at a time from offset 0, and whether Data said none follow. */\nasync function readRows(client: DataClient, detail: DetailBinding, parent: Parent | undefined, cap: number, signal?: AbortSignal): Promise<{ rows: FormRecord[]; complete: boolean } | ProviderError> {\n const rows: FormRecord[] = []\n // The offset moves by the page asked for, Data's own arithmetic: a row it\n // cannot address is still in its place (formancy.ai-data 0044).\n for (let offset = 0; offset < cap; ) {\n const limit = Math.min(LIST_PAGE_SIZE, cap - offset)\n const page = await client.list(detail.form, { ...(detail.sort === undefined ? {} : { sort: [...detail.sort] }), ...(parent === undefined ? {} : { parent }), offset, limit }, signal)\n if (!page.ok) return fromRefusal('/detail', page)\n rows.push(...page.value.rows.slice(0, limit))\n if (!page.value.hasMore) return { rows, complete: true }\n offset += limit\n }\n return { rows, complete: false }\n}\n\n/**\n * Each lookup value in `records` replaced by its label, asked of Data at\n * most a page's worth of tokens a request (formancy.ai-data 0044), each\n * token once. A token whose label Data did not give is an error naming the\n * field and where it first is, never the token.\n */\nasync function labelled(client: DataClient, role: DatasetRole, form: string, plan: FieldPlan, records: Answers[], signal?: AbortSignal): Promise<ProviderError[]> {\n const errors: ProviderError[] = []\n for (const [field, source] of plan.lookups) {\n const tokens = [...new Set(records.map((record) => record[field]).filter((value): value is string => typeof value === 'string'))]\n const labels = new Map<string, string>()\n for (let at = 0; at < tokens.length; at += LIST_PAGE_SIZE) {\n const resolved = await client.resolve(form, source, { operation: 'read', tokens: tokens.slice(at, at + LIST_PAGE_SIZE) }, signal)\n if (!resolved.ok) return [fromRefusal(`/${role}`, resolved)]\n for (const row of resolved.value) labels.set(row.token, row.label)\n }\n let unresolved = 0\n let first = -1\n records.forEach((record, index) => {\n const value = record[field]\n if (typeof value !== 'string') return\n const label = labels.get(value)\n if (label !== undefined) record[field] = label\n else if (unresolved++ === 0) first = index\n })\n if (unresolved > 0) {\n const path = role === 'header' ? `/header/${field}` : `/detail/${String(first)}/${field}`\n const message = unresolved === 1 ? `one value of ${field} names a record whose label this person may not see` : `${String(unresolved)} values of ${field} name records whose label this person may not see`\n errors.push({ path, code: 'unresolved-label', message })\n }\n }\n return errors\n}\n\n/**\n * The data `report` renders from, read from Formancy Data through `client`\n * where `binding` says, or every reason it was not. Its consistency is\n * `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and\n * each label are read at different moments. Rejects only with the abort\n * `options.signal` raised.\n */\nexport async function readReportData(client: DataClient, report: ReportDefinition, binding: DataBinding, options: ReadOptions = {}): Promise<ProviderRead> {\n const { signal } = options\n signal?.throwIfAborted()\n const checked = validateReport(report)\n if (!checked.valid) return refused([{ path: '', code: 'invalid-report', message: 'report-spec refuses this report; validateReport says why' }])\n const cap = options.cap ?? MAX_DETAIL_ROWS\n if (!Number.isInteger(cap) || cap < 1 || cap > MAX_DETAIL_ROWS) {\n return refused([{ path: '', code: 'invalid-cap', message: `a cap is a whole number of rows from 1 to ${String(MAX_DETAIL_ROWS)}` }])\n }\n const { datasets } = checked.report\n const unbound = bindingErrors(datasets, binding)\n if (unbound.length > 0) return refused(unbound)\n\n // Every form, and the parent, before any record: what can be refused\n // without reading the customer's data is refused without reading it.\n const plans = new Map<DatasetRole, FieldPlan>()\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const contract = datasets[role]\n const bound = binding[role]\n if (contract === undefined || bound === undefined) continue\n signal?.throwIfAborted()\n const published = await client.form(bound.form)\n if (!published.ok) return refused([fromRefusal(`/${role}`, published)])\n const { plan, errors: found } = planFields(role, contract, published.value)\n errors.push(...found)\n if (role === 'detail' && published.value.list === null) {\n errors.push({ path: '/detail', code: 'not-listable', message: 'the detail form offers this person no list of its records' })\n }\n plans.set(role, plan)\n }\n let parent: Parent | undefined\n if (binding.detail !== undefined) {\n const found = await parentOf(client, binding.header, binding.detail, signal)\n if (found !== undefined && 'code' in found) errors.push(found)\n else parent = found\n }\n if (errors.length > 0) return refused(errors)\n\n const headerPlan = plans.get('header')\n let header: Answers | undefined\n if (binding.header !== undefined && headerPlan !== undefined) {\n signal?.throwIfAborted()\n const record = await client.read(binding.header.form, binding.header.record)\n if (!record.ok) return refused([fromRefusal('/header', record)])\n header = pick(record.value, headerPlan)\n errors.push(...(await labelled(client, 'header', binding.header.form, headerPlan, [header], signal)))\n }\n const detailPlan = plans.get('detail')\n let detail: { rows: Answers[]; complete: boolean } | undefined\n if (binding.detail !== undefined && detailPlan !== undefined) {\n const read = await readRows(client, binding.detail, parent, cap, signal)\n if ('code' in read) return refused([read])\n detail = { rows: read.rows.map((row) => pick(row, detailPlan)), complete: read.complete }\n errors.push(...(await labelled(client, 'detail', binding.detail.form, detailPlan, detail.rows, signal)))\n }\n if (errors.length > 0) return refused(errors)\n\n return {\n ok: true,\n data: {\n ...(header === undefined ? {} : { header }),\n ...(detail === undefined ? {} : { detail: detail.rows }),\n completeness: detail === undefined ? { complete: true, captured: 0 } : { complete: detail.complete, captured: detail.rows.length, cap },\n consistency: 'best-effort',\n },\n }\n}\n"],"mappings":";;;;AAiCA,MAAa,uBAAuB;CAElC;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;AACF;AAmBA,MAAa,QAAgC,CAAC,UAAU,QAAQ;;AAGhE,SAAgB,cAAc,UAAoB,SAAuC;CACvF,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,SAAS,UAAU,KAAA;EACpC,MAAM,QAAQ,QAAQ,UAAU,KAAA;EAChC,IAAI,YAAY,CAAC,OAAO,OAAO,KAAK;GAAE,MAAM,IAAI;GAAQ,MAAM;GAAmB,SAAS,sBAAsB,KAAK;EAA+C,CAAC;EACrK,IAAI,SAAS,CAAC,UAAU,OAAO,KAAK;GAAE,MAAM,IAAI;GAAQ,MAAM;GAAsB,SAAS,kCAAkC,KAAK;EAAsC,CAAC;CAC7K;CACA,OAAO;AACT;;AAKA,SAAS,eAAe,QAA0B,uBAAO,IAAI,IAAmB,GAAuB;CACrG,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,WAAW,MAAM,SAAS,QAAQ,eAAe,MAAM,UAAU,CAAC,GAAG,IAAI;MACvF,IAAI,MAAM,SAAS,YAAY,KAAK,IAAI,MAAM,KAAK,KAAK;CAE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KAAK,KAAK,KAAK,QAAQ,KAAK,KAAK,UAAU,CAAC;GAAG,UAAU,KAAK;EAAS;EACxF,OAAO,KAAK,GAAI,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,MAAM,CAAE;CACzG;CACA,IAAI,OAAO,SAAS,GAAG,OAAO,QAAQ,MAAM;CAE5C,OAAO;EACL,IAAI;EACJ,MAAM;GACJ,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;GACzC,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,KAAK;GACtD,cAAc,WAAW,KAAA,IAAY;IAAE,UAAU;IAAM,UAAU;GAAE,IAAI;IAAE,UAAU,OAAO;IAAU,UAAU,OAAO,KAAK;IAAQ;GAAI;GACtI,aAAa;EACf;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/binding.ts","../src/read.ts"],"sourcesContent":["/**\n * Where a report's datasets come from in Formancy Data, and what a published\n * form says about the fields a report reads from it -- everything the\n * provider can check before it reads a record.\n */\nimport type { ListSortTerm, PublishedForm } from '@formancy/data-client'\nimport type { DatasetContract, DatasetRole, Datasets } from '@formancy/report-spec'\n\n/** The header's one record: a published form, and the token that addresses the record in it. */\nexport interface HeaderBinding {\n readonly form: string\n readonly record: string\n}\n\n/**\n * The detail rows: a published form's records, in the order of `sort`\n * (Data's key order when there is none). `parent` narrows them to one\n * record's children: `'header'` for the header record's, by the lookup\n * field the person's menu names between the two forms, or a field and a\n * record token given outright.\n */\nexport interface DetailBinding {\n readonly form: string\n readonly parent?: 'header' | { readonly field: string; readonly record: string }\n readonly sort?: readonly ListSortTerm[]\n}\n\n/** Which published form each of the report's datasets reads. */\nexport interface DataBinding {\n readonly header?: HeaderBinding\n readonly detail?: DetailBinding\n}\n\nexport const PROVIDER_ERROR_CODES = [\n /** A report that `validateReport` refuses: the runtime would refuse it too, and says why. */\n 'invalid-report',\n /** A cap that is not a whole number from 1 to the runtime's `MAX_DETAIL_ROWS`. */\n 'invalid-cap',\n /** A dataset the report declares and the binding does not say where to read. */\n 'unbound-dataset',\n /** A binding for a dataset the report does not declare. */\n 'undeclared-dataset',\n /** `parent: 'header'`, and the person's menu does not name the detail form as the header form's child exactly once. */\n 'unknown-parent',\n /** A field the report declares that the form does not let this person read, or does not have. */\n 'unreadable-field',\n /** An image field: Data 0.1.0 holds no approved asset for one to print. */\n 'unsupported-field',\n /** The detail form offers this person no list of its records. */\n 'not-listable',\n /** Data answered a binding's form with a published form under another id, or one that is no formancy form id: Data 0.1.0 publishes a form only under its own (0041). */\n 'unexpected-form',\n /** A lookup value whose label Data did not give this person. */\n 'unresolved-label',\n /** Data refused a request; `refusal` carries its status and code, and the message is its sentence. */\n 'refused',\n] as const\nexport type ProviderErrorCode = (typeof PROVIDER_ERROR_CODES)[number]\n\n/**\n * What the provider can say is wrong. The path is a JSON Pointer into the\n * binding -- `/detail/parent` -- or into the data it would have handed over\n * -- `/header/customer`, `/detail/17/order`. Neither it nor the message\n * ever holds a value: a token or an answer is the customer's, and an error\n * ends up in a log. Data's own sentences promise the same\n * (formancy.ai-data 0011).\n */\nexport interface ProviderError {\n readonly path: string\n readonly code: ProviderErrorCode\n readonly message: string\n /** Data's answer, when Data refused: its HTTP status (0 when nothing answered) and its code. */\n readonly refusal?: { readonly status: number; readonly code: string }\n}\n\nexport const ROLES: readonly DatasetRole[] = ['header', 'detail']\n\n/** A binding that says where each declared dataset is, and nothing else. */\nexport function bindingErrors(datasets: Datasets, binding: DataBinding): ProviderError[] {\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const declared = datasets[role] !== undefined\n const bound = binding[role] !== undefined\n if (declared && !bound)\n errors.push({ path: `/${role}`, code: 'unbound-dataset', message: `the report reads a ${role} dataset and the binding names no form for it` })\n if (bound && !declared)\n errors.push({ path: `/${role}`, code: 'undeclared-dataset', message: `the binding names a form for a ${role} dataset the report does not declare` })\n }\n return errors\n}\n\ntype Field = PublishedForm['form']['model']['fields'][number]\n\n/** Every field whose answer is in a record, by key: groups and pages hold fields of the record; a repeater's are inside its rows. */\nfunction answeredFields(fields: readonly Field[], into = new Map<string, Field>()): Map<string, Field> {\n for (const field of fields) {\n if (field.type === 'group' || field.type === 'page') answeredFields(field.fields ?? [], into)\n else if (field.type !== 'repeater') into.set(field.key, field)\n }\n return into\n}\n\n/**\n * A nullable yes-or-no column, as Data generates its control: a radio of\n * exactly \"true\" and \"false\" (formancy.ai-data's controls), whose answer is\n * one of those strings or null. A report that reads it as a boolean gets\n * true or false.\n */\nfunction isYesOrNo(field: Field): boolean {\n const values = (field.options ?? []).map((option) => option.value)\n return field.type === 'radio' && values.length === 2 && values.includes('true') && values.includes('false')\n}\n\n/** How the provider reads one dataset's fields from a form: which are lookups, by source, and which yes-or-no strings become booleans. */\nexport interface FieldPlan {\n readonly fields: readonly string[]\n readonly lookups: ReadonlyMap<string, string>\n readonly yesOrNo: ReadonlySet<string>\n}\n\n/**\n * What `published` says about reading `contract` from it, for this person:\n * every declared field readable, none an image, and how each is read.\n */\nexport function planFields(role: DatasetRole, contract: DatasetContract, published: PublishedForm): { plan: FieldPlan; errors: ProviderError[] } {\n const readable = new Set(published.readable)\n const fields = answeredFields(published.form.model.fields)\n const errors: ProviderError[] = []\n const lookups = new Map<string, string>()\n const yesOrNo = new Set<string>()\n for (const declared of contract.fields) {\n const path = `/${role}/${declared.id}`\n const field = fields.get(declared.id)\n if (declared.type === 'image') {\n errors.push({\n path,\n code: 'unsupported-field',\n message: `${declared.id} is an image field, and a Formancy Data 0.1.0 form holds no approved asset to print`,\n })\n } else if (field === undefined || !readable.has(declared.id)) {\n errors.push({\n path,\n code: 'unreadable-field',\n message: `the form gives this person no field ${declared.id} to read: the form does not have it, or its policy does not let them read it`,\n })\n } else if (typeof field.optionsSource === 'string') {\n lookups.set(declared.id, field.optionsSource)\n } else if (declared.type === 'boolean' && isYesOrNo(field)) {\n yesOrNo.add(declared.id)\n }\n }\n return { plan: { fields: contract.fields.map((field) => field.id), lookups, yesOrNo }, errors }\n}\n","/**\n * A report's data, read from Formancy Data 0.1.0's runtime plane through\n * `@formancy/data-client`, as the person whose token the client carries:\n * the header's one record, the detail rows a page at a time, and each\n * lookup's label. Everything that can be checked without a record -- the\n * binding, the fields the person may read, the parent -- is checked first,\n * and a refusal anywhere hands over nothing.\n *\n * The values are Data's, as Data gave them, with one translation: a\n * nullable yes-or-no's \"true\" and \"false\" become booleans. Whether each\n * fits its field is the runtime's to say, once (0010).\n *\n * The data names its source: the published form each dataset was read\n * from, by the id the binding addressed it by, which the render's manifest\n * carries (0041). Data 0.1.0 publishes a form only under its own id, so a\n * form answered under another is refused before any record is read. Not\n * the header record's token: a token spells the record's key\n * (formancy.ai-data 0012), and a key can be the customer's own data. Data\n * read from no form names no source.\n */\nimport { LIST_PAGE_SIZE } from '@formancy/data-client'\nimport type { DataClient, FormRecord, Refusal } from '@formancy/data-client'\nimport { MAX_DETAIL_ROWS } from '@formancy/report-runtime'\nimport type { FormancyDataSource, ReportData } from '@formancy/report-runtime'\nimport { isFormId, validateReport } from '@formancy/report-spec'\nimport type { DatasetRole, ReportDefinition } from '@formancy/report-spec'\nimport { bindingErrors, planFields, ROLES } from './binding.js'\nimport type { DataBinding, DetailBinding, FieldPlan, HeaderBinding, ProviderError } from './binding.js'\n\nexport interface ReadOptions {\n /**\n * The most detail rows to read: a whole number from 1 to the runtime's\n * `MAX_DETAIL_ROWS`, which is the default. With more rows than that, the\n * data says it is incomplete, and a final render refuses it.\n */\n readonly cap?: number\n /** Stops the reads still to come; the call then rejects with the abort. */\n readonly signal?: AbortSignal\n}\n\nexport type ProviderRead = { readonly ok: true; readonly data: ReportData } | { readonly ok: false; readonly errors: readonly ProviderError[] }\n\ntype Answers = Record<string, unknown>\ntype Parent = { readonly field: string; readonly record: string }\n\nconst refused = (errors: readonly ProviderError[]): ProviderRead => ({ ok: false, errors })\n\n/** Data's refusal, as the provider passes it on: Data's sentence, status and code. */\nfunction fromRefusal(path: string, refusal: Refusal): ProviderError {\n return { path, code: 'refused', message: refusal.message, refusal: { status: refusal.status, code: refusal.code } }\n}\n\n/** The declared fields of one record, nothing else it holds, with yes-or-no strings read as booleans. */\nfunction pick(record: FormRecord, plan: FieldPlan): Answers {\n const answers: Answers = {}\n for (const field of plan.fields) {\n if (!Object.hasOwn(record.answers, field)) continue\n const value = record.answers[field]\n answers[field] = plan.yesOrNo.has(field) && (value === 'true' || value === 'false') ? value === 'true' : value\n }\n return answers\n}\n\n/** The parent the detail rows are narrowed to: given, or the header record by the one field the person's menu names. */\nasync function parentOf(\n client: DataClient,\n header: HeaderBinding | undefined,\n detail: DetailBinding,\n signal?: AbortSignal,\n): Promise<Parent | undefined | ProviderError> {\n if (detail.parent !== 'header') return detail.parent\n const unknown = (message: string): ProviderError => ({ path: '/detail/parent', code: 'unknown-parent', message })\n if (header === undefined) return unknown(\"parent 'header' reads the header record's children, and the binding names no header record\")\n const menu = await client.forms(signal)\n if (!menu.ok) return fromRefusal('/detail/parent', menu)\n const children = menu.value.forms.find((form) => form.id === header.form)?.children ?? []\n const fields = children.filter((child) => child.form === detail.form).map((child) => child.field)\n const [field] = fields\n if (fields.length === 1 && field !== undefined) return { field, record: header.record }\n return unknown(\n fields.length === 0\n ? \"this person's menu does not list the detail form as a child of the header form\"\n : \"this person's menu lists the detail form under the header form by more than one field; name the field in parent\",\n )\n}\n\n/** Every detail row up to `cap`, a page at a time from offset 0, and whether Data said none follow. */\nasync function readRows(\n client: DataClient,\n detail: DetailBinding,\n parent: Parent | undefined,\n cap: number,\n signal?: AbortSignal,\n): Promise<{ rows: FormRecord[]; complete: boolean } | ProviderError> {\n const rows: FormRecord[] = []\n // The offset moves by the page asked for, Data's own arithmetic: a row it\n // cannot address is still in its place (formancy.ai-data 0044).\n for (let offset = 0; offset < cap;) {\n const limit = Math.min(LIST_PAGE_SIZE, cap - offset)\n const page = await client.list(\n detail.form,\n { ...(detail.sort === undefined ? {} : { sort: [...detail.sort] }), ...(parent === undefined ? {} : { parent }), offset, limit },\n signal,\n )\n if (!page.ok) return fromRefusal('/detail', page)\n rows.push(...page.value.rows.slice(0, limit))\n if (!page.value.hasMore) return { rows, complete: true }\n offset += limit\n }\n return { rows, complete: false }\n}\n\n/**\n * Each lookup value in `records` replaced by its label, asked of Data at\n * most a page's worth of tokens a request (formancy.ai-data 0044), each\n * token once. A token whose label Data did not give is an error naming the\n * field and where it first is, never the token.\n */\nasync function labelled(\n client: DataClient,\n role: DatasetRole,\n form: string,\n plan: FieldPlan,\n records: Answers[],\n signal?: AbortSignal,\n): Promise<ProviderError[]> {\n const errors: ProviderError[] = []\n for (const [field, source] of plan.lookups) {\n const tokens = [...new Set(records.map((record) => record[field]).filter((value): value is string => typeof value === 'string'))]\n const labels = new Map<string, string>()\n for (let at = 0; at < tokens.length; at += LIST_PAGE_SIZE) {\n const resolved = await client.resolve(form, source, { operation: 'read', tokens: tokens.slice(at, at + LIST_PAGE_SIZE) }, signal)\n if (!resolved.ok) return [fromRefusal(`/${role}`, resolved)]\n for (const row of resolved.value) labels.set(row.token, row.label)\n }\n let unresolved = 0\n let first = -1\n records.forEach((record, index) => {\n const value = record[field]\n if (typeof value !== 'string') return\n const label = labels.get(value)\n if (label !== undefined) record[field] = label\n else if (unresolved++ === 0) first = index\n })\n if (unresolved > 0) {\n const path = role === 'header' ? `/header/${field}` : `/detail/${String(first)}/${field}`\n const message =\n unresolved === 1\n ? `one value of ${field} names a record whose label this person may not see`\n : `${String(unresolved)} values of ${field} name records whose label this person may not see`\n errors.push({ path, code: 'unresolved-label', message })\n }\n }\n return errors\n}\n\n/**\n * The data `report` renders from, read from Formancy Data through `client`\n * where `binding` says, or every reason it was not. Its consistency is\n * `best-effort`: Data 0.1.0 has no snapshot, so the header, each page and\n * each label are read at different moments. Its source names the forms it\n * read (0041). Rejects only with the abort `options.signal` raised.\n */\nexport async function readReportData(client: DataClient, report: ReportDefinition, binding: DataBinding, options: ReadOptions = {}): Promise<ProviderRead> {\n const { signal } = options\n signal?.throwIfAborted()\n const checked = validateReport(report)\n if (!checked.valid) return refused([{ path: '', code: 'invalid-report', message: 'report-spec refuses this report; validateReport says why' }])\n const cap = options.cap ?? MAX_DETAIL_ROWS\n if (!Number.isInteger(cap) || cap < 1 || cap > MAX_DETAIL_ROWS) {\n return refused([{ path: '', code: 'invalid-cap', message: `a cap is a whole number of rows from 1 to ${String(MAX_DETAIL_ROWS)}` }])\n }\n const { datasets } = checked.report\n const unbound = bindingErrors(datasets, binding)\n if (unbound.length > 0) return refused(unbound)\n\n // Every form, and the parent, before any record: what can be refused\n // without reading the customer's data is refused without reading it.\n const plans = new Map<DatasetRole, FieldPlan>()\n const forms: { [R in DatasetRole]?: string } = {}\n const errors: ProviderError[] = []\n for (const role of ROLES) {\n const contract = datasets[role]\n const bound = binding[role]\n if (contract === undefined || bound === undefined) continue\n signal?.throwIfAborted()\n const published = await client.form(bound.form)\n if (!published.ok) return refused([fromRefusal(`/${role}`, published)])\n // The source names this form, and the fields are planned from it: an\n // answer under another id is not the form the records are read from.\n if (published.value.form.id !== bound.form || !isFormId(bound.form)) {\n return refused([\n {\n path: `/${role}`,\n code: 'unexpected-form',\n message: `Data answered the ${role} form with a published form under another id, or one that is no formancy form id; Data 0.1.0 publishes a form only under its own`,\n },\n ])\n }\n const { plan, errors: found } = planFields(role, contract, published.value)\n errors.push(...found)\n if (role === 'detail' && published.value.list === null) {\n errors.push({ path: '/detail', code: 'not-listable', message: 'the detail form offers this person no list of its records' })\n }\n plans.set(role, plan)\n forms[role] = bound.form\n }\n let parent: Parent | undefined\n if (binding.detail !== undefined) {\n const found = await parentOf(client, binding.header, binding.detail, signal)\n if (found !== undefined && 'code' in found) errors.push(found)\n else parent = found\n }\n if (errors.length > 0) return refused(errors)\n\n const headerPlan = plans.get('header')\n let header: Answers | undefined\n if (binding.header !== undefined && headerPlan !== undefined) {\n signal?.throwIfAborted()\n const record = await client.read(binding.header.form, binding.header.record)\n if (!record.ok) return refused([fromRefusal('/header', record)])\n header = pick(record.value, headerPlan)\n errors.push(...(await labelled(client, 'header', binding.header.form, headerPlan, [header], signal)))\n }\n const detailPlan = plans.get('detail')\n let detail: { rows: Answers[]; complete: boolean } | undefined\n if (binding.detail !== undefined && detailPlan !== undefined) {\n const read = await readRows(client, binding.detail, parent, cap, signal)\n if ('code' in read) return refused([read])\n detail = { rows: read.rows.map((row) => pick(row, detailPlan)), complete: read.complete }\n errors.push(...(await labelled(client, 'detail', binding.detail.form, detailPlan, detail.rows, signal)))\n }\n if (errors.length > 0) return refused(errors)\n\n // Data read from no form has no source to name.\n const source: FormancyDataSource | undefined = Object.keys(forms).length === 0 ? undefined : { provider: 'formancy-data', forms }\n return {\n ok: true,\n data: {\n ...(header === undefined ? {} : { header }),\n ...(detail === undefined ? {} : { detail: detail.rows }),\n completeness: detail === undefined ? { complete: true, captured: 0 } : { complete: detail.complete, captured: detail.rows.length, cap },\n consistency: 'best-effort',\n ...(source === undefined ? {} : { source }),\n },\n }\n}\n"],"mappings":";;;;AAiCA,MAAa,uBAAuB;CAElC;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;AACF;AAmBA,MAAa,QAAgC,CAAC,UAAU,QAAQ;;AAGhE,SAAgB,cAAc,UAAoB,SAAuC;CACvF,MAAM,SAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,SAAS,UAAU,KAAA;EACpC,MAAM,QAAQ,QAAQ,UAAU,KAAA;EAChC,IAAI,YAAY,CAAC,OACf,OAAO,KAAK;GAAE,MAAM,IAAI;GAAQ,MAAM;GAAmB,SAAS,sBAAsB,KAAK;EAA+C,CAAC;EAC/I,IAAI,SAAS,CAAC,UACZ,OAAO,KAAK;GAAE,MAAM,IAAI;GAAQ,MAAM;GAAsB,SAAS,kCAAkC,KAAK;EAAsC,CAAC;CACvJ;CACA,OAAO;AACT;;AAKA,SAAS,eAAe,QAA0B,uBAAO,IAAI,IAAmB,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,OAAO,KAAK,GAAI,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,GAAG,MAAM,CAAE;CACtG;CACA,MAAM,aAAa,MAAM,IAAI,QAAQ;CACrC,IAAI;CACJ,IAAI,QAAQ,WAAW,KAAA,KAAa,eAAe,KAAA,GAAW;EAC5D,MAAM,OAAO,MAAM,SAAS,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,MAAM;EACvE,IAAI,UAAU,MAAM,OAAO,QAAQ,CAAC,IAAI,CAAC;EACzC,SAAS;GAAE,MAAM,KAAK,KAAK,KAAK,QAAQ,KAAK,KAAK,UAAU,CAAC;GAAG,UAAU,KAAK;EAAS;EACxF,OAAO,KAAK,GAAI,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,MAAM,YAAY,OAAO,MAAM,MAAM,CAAE;CACzG;CACA,IAAI,OAAO,SAAS,GAAG,OAAO,QAAQ,MAAM;CAG5C,MAAM,SAAyC,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,IAAI,KAAA,IAAY;EAAE,UAAU;EAAiB;CAAM;CAChI,OAAO;EACL,IAAI;EACJ,MAAM;GACJ,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;GACzC,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,OAAO,KAAK;GACtD,cAAc,WAAW,KAAA,IAAY;IAAE,UAAU;IAAM,UAAU;GAAE,IAAI;IAAE,UAAU,OAAO;IAAU,UAAU,OAAO,KAAK;IAAQ;GAAI;GACtI,aAAa;GACb,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EAC3C;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formancy/report-data-provider",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Formancy Report's Formancy Data provider: reads a published Data form's records, through @formancy/data-client 0.1.0 and the person's own token, into the data a report renders from, labelled best-effort. No framework, no Node.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -18,8 +18,8 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "@formancy/data-client": "0.1.0",
21
- "@formancy/report-runtime": "0.2.0",
22
- "@formancy/report-spec": "0.2.0"
21
+ "@formancy/report-runtime": "0.3.0",
22
+ "@formancy/report-spec": "0.3.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@arethetypeswrong/cli": "^0.18.5",