@formfeed/devkit 0.3.21 → 0.3.23

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/index.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  diagnose: () => diagnose,
34
34
  diagnoseAccessibility: () => diagnoseAccessibility,
35
35
  diagnoseEinvoice: () => diagnoseEinvoice,
36
+ diagnosePdfa: () => diagnosePdfa,
36
37
  findProject: () => findProject,
37
38
  generateTypes: () => generateTypes,
38
39
  htmlSnapshot: () => htmlSnapshot,
@@ -963,6 +964,33 @@ function diagnoseAccessibility(tpl) {
963
964
  return out;
964
965
  }
965
966
 
967
+ // packages/devkit/src/lib/pdfa.ts
968
+ var import_engine7 = require("@formfeed/engine");
969
+ var nowhere4 = { start: { line: 1, column: 1 }, end: { line: 1, column: 1 } };
970
+ var about2 = (severity, code, message) => ({
971
+ file: "settings.json",
972
+ diagnostics: [{ severity, code, message, range: nowhere4 }]
973
+ });
974
+ function diagnosePdfa(tpl) {
975
+ const declared = tpl.settings.pdf?.pdfa;
976
+ if (declared !== void 0 && !(0, import_engine7.isPdfaSetting)(declared))
977
+ return [about2("error", "pdfa-setting", import_engine7.PDFA_REFUSALS.invalid)];
978
+ const level = (0, import_engine7.resolvePdfa)(declared);
979
+ if (!level) return [];
980
+ if (tpl.meta.kind === "image")
981
+ return [
982
+ about2(
983
+ "warning",
984
+ "pdfa-image",
985
+ `settings.json declares ${(0, import_engine7.pdfaStandard)(level)}, which an image template never produces: PDF/A is a format of PDF`
986
+ )
987
+ ];
988
+ const einvoice = (0, import_engine7.resolveEinvoiceOptions)(tpl.settings.einvoice);
989
+ if (level === "2b" && einvoice.ok && einvoice.options)
990
+ return [about2("error", "pdfa-einvoice", import_engine7.PDFA_REFUSALS.einvoice)];
991
+ return [];
992
+ }
993
+
966
994
  // packages/devkit/src/lib/files.ts
967
995
  var import_node_crypto2 = require("node:crypto");
968
996
  var import_node_fs5 = require("node:fs");
@@ -1101,7 +1129,7 @@ function isRecord(value) {
1101
1129
  }
1102
1130
 
1103
1131
  // packages/devkit/src/lib/types/index.ts
1104
- var import_engine7 = require("@formfeed/engine");
1132
+ var import_engine8 = require("@formfeed/engine");
1105
1133
 
1106
1134
  // packages/devkit/src/lib/types/model.ts
1107
1135
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1589,7 +1617,7 @@ function localTypeSource(tpl) {
1589
1617
  const sets = Object.values(tpl.dataSets);
1590
1618
  return {
1591
1619
  slug: tpl.slug,
1592
- schema: (0, import_engine7.inferSchemaFromDataSets)(sets.length ? sets : [{}]),
1620
+ schema: (0, import_engine8.inferSchemaFromDataSets)(sets.length ? sets : [{}]),
1593
1621
  origin: "inferred"
1594
1622
  };
1595
1623
  }
@@ -1608,6 +1636,7 @@ function localTypeSource(tpl) {
1608
1636
  diagnose,
1609
1637
  diagnoseAccessibility,
1610
1638
  diagnoseEinvoice,
1639
+ diagnosePdfa,
1611
1640
  findProject,
1612
1641
  generateTypes,
1613
1642
  htmlSnapshot,
package/index.js CHANGED
@@ -923,6 +923,39 @@ function diagnoseAccessibility(tpl) {
923
923
  return out;
924
924
  }
925
925
 
926
+ // packages/devkit/src/lib/pdfa.ts
927
+ import {
928
+ PDFA_REFUSALS,
929
+ isPdfaSetting,
930
+ pdfaStandard,
931
+ resolveEinvoiceOptions as resolveEinvoiceOptions2,
932
+ resolvePdfa
933
+ } from "@formfeed/engine";
934
+ var nowhere4 = { start: { line: 1, column: 1 }, end: { line: 1, column: 1 } };
935
+ var about2 = (severity, code, message) => ({
936
+ file: "settings.json",
937
+ diagnostics: [{ severity, code, message, range: nowhere4 }]
938
+ });
939
+ function diagnosePdfa(tpl) {
940
+ const declared = tpl.settings.pdf?.pdfa;
941
+ if (declared !== void 0 && !isPdfaSetting(declared))
942
+ return [about2("error", "pdfa-setting", PDFA_REFUSALS.invalid)];
943
+ const level = resolvePdfa(declared);
944
+ if (!level) return [];
945
+ if (tpl.meta.kind === "image")
946
+ return [
947
+ about2(
948
+ "warning",
949
+ "pdfa-image",
950
+ `settings.json declares ${pdfaStandard(level)}, which an image template never produces: PDF/A is a format of PDF`
951
+ )
952
+ ];
953
+ const einvoice = resolveEinvoiceOptions2(tpl.settings.einvoice);
954
+ if (level === "2b" && einvoice.ok && einvoice.options)
955
+ return [about2("error", "pdfa-einvoice", PDFA_REFUSALS.einvoice)];
956
+ return [];
957
+ }
958
+
926
959
  // packages/devkit/src/lib/files.ts
927
960
  import { createHash as createHash2 } from "node:crypto";
928
961
  import { existsSync as existsSync5, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync5, statSync as statSync2, writeFileSync as writeFileSync4 } from "node:fs";
@@ -1567,6 +1600,7 @@ export {
1567
1600
  diagnose,
1568
1601
  diagnoseAccessibility,
1569
1602
  diagnoseEinvoice,
1603
+ diagnosePdfa,
1570
1604
  findProject,
1571
1605
  generateTypes,
1572
1606
  htmlSnapshot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formfeed/devkit",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "Formfeed template folders, project config and local rendering, shared by the CLI and @formfeed/testing.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  ],
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
- "@formfeed/engine": "0.3.21",
34
- "@formfeed/sdk": "0.3.21"
33
+ "@formfeed/engine": "0.3.23",
34
+ "@formfeed/sdk": "0.3.23"
35
35
  },
36
36
  "keywords": [
37
37
  "formfeed",
package/types/index.d.cts CHANGED
@@ -11,6 +11,7 @@ export type { LocalDiagnostic, OfficeLocalOptions } from './lib/local-render.cjs
11
11
  export { declaredEinvoice, diagnoseEinvoice, localEinvoiceXml, } from './lib/einvoice.cjs';
12
12
  export type { DataSetDiagnostics } from './lib/einvoice.cjs';
13
13
  export { diagnoseAccessibility } from './lib/accessibility.cjs';
14
+ export { diagnosePdfa } from './lib/pdfa.cjs';
14
15
  export type { FileDiagnostics } from './lib/accessibility.cjs';
15
16
  export { contentTypeFor, listLocalFiles, localFilePath, sha256File, writeLocalFile, } from './lib/files.cjs';
16
17
  export type { LocalFile, LocalFileListing } from './lib/files.cjs';
package/types/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export type { LocalDiagnostic, OfficeLocalOptions } from './lib/local-render.js'
11
11
  export { declaredEinvoice, diagnoseEinvoice, localEinvoiceXml, } from './lib/einvoice.js';
12
12
  export type { DataSetDiagnostics } from './lib/einvoice.js';
13
13
  export { diagnoseAccessibility } from './lib/accessibility.js';
14
+ export { diagnosePdfa } from './lib/pdfa.js';
14
15
  export type { FileDiagnostics } from './lib/accessibility.js';
15
16
  export { contentTypeFor, listLocalFiles, localFilePath, sha256File, writeLocalFile, } from './lib/files.js';
16
17
  export type { LocalFile, LocalFileListing } from './lib/files.js';
@@ -0,0 +1,4 @@
1
+ import type { FileDiagnostics } from './accessibility.cjs';
2
+ import type { LocalTemplate } from './project.cjs';
3
+ /** Empty for a template that does not declare `pdf.pdfa`, or declares it as the API takes it. */
4
+ export declare function diagnosePdfa(tpl: LocalTemplate): FileDiagnostics[];
@@ -0,0 +1,4 @@
1
+ import type { FileDiagnostics } from './accessibility.js';
2
+ import type { LocalTemplate } from './project.js';
3
+ /** Empty for a template that does not declare `pdf.pdfa`, or declares it as the API takes it. */
4
+ export declare function diagnosePdfa(tpl: LocalTemplate): FileDiagnostics[];