@oicana/node 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
@@ -1,6 +1,6 @@
1
- import { CompilationMode } from './CompilationMode';
2
- import type { ExportFormat } from './ExportFormat';
3
- import type { BlobWithMetadata } from './inputs';
1
+ import { CompilationMode } from './CompilationMode.js';
2
+ import type { ExportFormat } from './ExportFormat.js';
3
+ import type { BlobWithMetadata } from './inputs/index.js';
4
4
  /**
5
5
  * A template
6
6
  *
package/dist/Template.js CHANGED
@@ -1,5 +1,5 @@
1
- import { compileTemplate, registerTemplate, } from '@oicana/node-native';
2
- import { CompilationMode } from './CompilationMode';
1
+ import { compileTemplate, registerTemplate, exportDocument } from '@oicana/node-native';
2
+ import { CompilationMode } from './CompilationMode.js';
3
3
  /**
4
4
  * A template
5
5
  *
@@ -19,8 +19,7 @@ export class Template {
19
19
  constructor(name, template, jsonInputs, blobInputs, compilationMode) {
20
20
  this.template = name;
21
21
  this.defaultCompilationMode = CompilationMode.Production;
22
- const format = { format: 'pdf' };
23
- registerTemplate(this.template, template, Object.fromEntries(jsonInputs ?? new Map()), this.convertBlobWithMetadata(blobInputs ?? new Map()), JSON.stringify(format), this.mapCompilationMode(compilationMode ?? CompilationMode.Development));
22
+ registerTemplate(this.template, template, Object.fromEntries(jsonInputs ?? new Map()), this.convertBlobWithMetadata(blobInputs ?? new Map()), this.mapCompilationMode(compilationMode ?? CompilationMode.Development));
24
23
  }
25
24
  /**
26
25
  * Compile the template with the given inputs
@@ -31,7 +30,8 @@ export class Template {
31
30
  */
32
31
  compile(jsonInputs, blobInputs, exportFormat, compilationMode) {
33
32
  const format = exportFormat ?? { format: 'pdf' };
34
- return compileTemplate(this.template, Object.fromEntries(jsonInputs ?? new Map()), this.convertBlobWithMetadata(blobInputs ?? new Map()), JSON.stringify(format), this.mapCompilationMode(compilationMode ?? CompilationMode.Production));
33
+ const document = compileTemplate(this.template, Object.fromEntries(jsonInputs ?? new Map()), this.convertBlobWithMetadata(blobInputs ?? new Map()), this.mapCompilationMode(compilationMode ?? CompilationMode.Production));
34
+ return exportDocument(document, JSON.stringify(format));
35
35
  }
36
36
  /**
37
37
  * Get the default compilation mode of this template
@@ -1 +1 @@
1
- {"version":3,"file":"Template.js","sourceRoot":"","sources":["../src/Template.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAEf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACF,QAAQ,CAAS;IAC1B,sBAAsB,CAAkB;IAuBhD;;;;;;;OAOG;IACH,YACE,IAAY,EACZ,QAAoB,EACpB,UAAgC,EAChC,UAA0C,EAC1C,eAAiC;QAEjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,sBAAsB,GAAG,eAAe,CAAC,UAAU,CAAC;QACzD,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAEjC,gBAAgB,CACd,IAAI,CAAC,QAAQ,EACb,QAAQ,EACR,MAAM,CAAC,WAAW,CAAC,UAAU,IAAI,IAAI,GAAG,EAAkB,CAAC,EAC3D,IAAI,CAAC,uBAAuB,CAC1B,UAAU,IAAI,IAAI,GAAG,EAA4B,CAClD,EACD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EACtB,IAAI,CAAC,kBAAkB,CAAC,eAAe,IAAI,eAAe,CAAC,WAAW,CAAC,CACxE,CAAC;IACJ,CAAC;IA6BD;;;;;;OAMG;IACI,OAAO,CACZ,UAAgC,EAChC,UAA0C,EAC1C,YAA2B,EAC3B,eAAiC;QAEjC,MAAM,MAAM,GAAiB,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAE/D,OAAO,eAAe,CACpB,IAAI,CAAC,QAAQ,EACb,MAAM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AAC,eAAgC;QACpD,IAAI,CAAC,sBAAsB,GAAG,eAAe,CAAC;IAChD,CAAC;IAEO,uBAAuB,CAC7B,UAAyC;QAEzC,OAAO,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAChD,MAAM,WAAW,GAAG;gBAClB,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;aACnE,CAAC;YACF,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAC5B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,IAAqB;QAC9C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,eAAe,CAAC,WAAW;gBAC9B,iDAAyC;YAC3C,KAAK,eAAe,CAAC,UAAU;gBAC7B,gDAAwC;QAC5C,CAAC;IACH,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './CompilationMode';
2
- export * from './ExportFormat';
3
- export * from './inputs';
4
- export * from './Template';
1
+ export * from './CompilationMode.js';
2
+ export * from './ExportFormat.js';
3
+ export * from './inputs/index.js';
4
+ export * from './Template.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export * from './CompilationMode';
2
- export * from './ExportFormat';
3
- export * from './inputs';
4
- export * from './Template';
1
+ export * from './CompilationMode.js';
2
+ export * from './ExportFormat.js';
3
+ export * from './inputs/index.js';
4
+ export * from './Template.js';
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
@@ -1,5 +1,5 @@
1
- import { BlobInputDefinition, BlobWithMetadata } from './BlobInput';
2
- import { JsonInputDefinition } from './JsonInput';
1
+ import { BlobInputDefinition, BlobWithMetadata } from './BlobInput.js';
2
+ import { JsonInputDefinition } from './JsonInput.js';
3
3
  export { JsonInputDefinition, BlobInputDefinition, BlobWithMetadata };
4
4
  export interface Inputs {
5
5
  json: JsonInputDefinition[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oicana/node",
3
3
  "author": "Oicana <hello@oicana.com>",
4
- "version": "0.1.0-alpha.1",
4
+ "version": "0.1.0-alpha.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "readme": "README.md",
@@ -22,7 +22,7 @@
22
22
  "lint": "biome ci"
23
23
  },
24
24
  "dependencies": {
25
- "@oicana/node-native": "0.1.0-alpha.1"
25
+ "@oicana/node-native": "0.1.0-alpha.3"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.2.4",
package/src/Template.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import {
2
2
  type BlobWithMetadata as BlobWithMetadataNative,
3
3
  compileTemplate,
4
+ exportDocument,
4
5
  CompilationMode as NativeCompilationMode,
5
6
  registerTemplate,
7
+ removeDocument,
6
8
  } from '@oicana/node-native';
7
- import { CompilationMode } from './CompilationMode';
8
- import type { ExportFormat } from './ExportFormat';
9
- import type { BlobWithMetadata } from './inputs';
9
+ import { CompilationMode } from './CompilationMode.js';
10
+ import type { ExportFormat } from './ExportFormat.js';
11
+ import type { BlobWithMetadata } from './inputs/index.js';
10
12
 
11
13
  /**
12
14
  * A template
@@ -55,7 +57,6 @@ export class Template {
55
57
  ) {
56
58
  this.template = name;
57
59
  this.defaultCompilationMode = CompilationMode.Production;
58
- const format = { format: 'pdf' };
59
60
 
60
61
  registerTemplate(
61
62
  this.template,
@@ -64,7 +65,6 @@ export class Template {
64
65
  this.convertBlobWithMetadata(
65
66
  blobInputs ?? new Map<string, BlobWithMetadata>(),
66
67
  ),
67
- JSON.stringify(format),
68
68
  this.mapCompilationMode(compilationMode ?? CompilationMode.Development),
69
69
  );
70
70
  }
@@ -111,15 +111,19 @@ export class Template {
111
111
  ): Uint8Array {
112
112
  const format: ExportFormat = exportFormat ?? { format: 'pdf' };
113
113
 
114
- return compileTemplate(
114
+ const document = compileTemplate(
115
115
  this.template,
116
116
  Object.fromEntries(jsonInputs ?? new Map<string, string>()),
117
117
  this.convertBlobWithMetadata(
118
118
  blobInputs ?? new Map<string, BlobWithMetadata>(),
119
119
  ),
120
- JSON.stringify(format),
121
120
  this.mapCompilationMode(compilationMode ?? CompilationMode.Production),
122
121
  );
122
+ try {
123
+ return exportDocument(document, JSON.stringify(format));
124
+ } finally {
125
+ removeDocument(document);
126
+ }
123
127
  }
124
128
 
125
129
  /**
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './CompilationMode';
2
- export * from './ExportFormat';
3
- export * from './inputs';
4
- export * from './Template';
1
+ export * from './CompilationMode.js';
2
+ export * from './ExportFormat.js';
3
+ export * from './inputs/index.js';
4
+ export * from './Template.js';
@@ -1,5 +1,5 @@
1
- import { BlobInputDefinition, BlobWithMetadata } from './BlobInput';
2
- import { JsonInputDefinition } from './JsonInput';
1
+ import { BlobInputDefinition, BlobWithMetadata } from './BlobInput.js';
2
+ import { JsonInputDefinition } from './JsonInput.js';
3
3
 
4
4
  export { JsonInputDefinition, BlobInputDefinition, BlobWithMetadata };
5
5
 
package/tsconfig.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "sourceMap": true,
6
6
  "declaration": true,
7
7
  "outDir": "dist",
8
- "module": "esnext",
9
- "moduleResolution": "node",
8
+ "module": "NodeNext",
9
+ "moduleResolution": "NodeNext",
10
10
  "esModuleInterop": true,
11
11
  "forceConsistentCasingInFileNames": true
12
12
  },