@vritti/api-sdk 0.2.4 → 0.2.5

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/dist/xlsx.cjs ADDED
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/xlsx.ts
22
+ var xlsx_exports = {};
23
+ __export(xlsx_exports, {
24
+ buildExportBuffer: () => buildExportBuffer,
25
+ getExportExt: () => getExportExt,
26
+ getExportMimeType: () => getExportMimeType
27
+ });
28
+ module.exports = __toCommonJS(xlsx_exports);
29
+
30
+ // src/utils/export.utils.ts
31
+ var import_xlsx = require("xlsx");
32
+ var FORMAT_CONFIG = {
33
+ xlsx: {
34
+ bookType: "xlsx",
35
+ mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
36
+ ext: "xlsx"
37
+ },
38
+ xls: {
39
+ bookType: "biff8",
40
+ mimeType: "application/vnd.ms-excel",
41
+ ext: "xls"
42
+ },
43
+ csv: {
44
+ bookType: "csv",
45
+ mimeType: "text/csv",
46
+ ext: "csv"
47
+ },
48
+ tsv: {
49
+ bookType: "csv",
50
+ mimeType: "text/tab-separated-values",
51
+ ext: "tsv",
52
+ opts: {
53
+ FS: " "
54
+ }
55
+ },
56
+ ods: {
57
+ bookType: "ods",
58
+ mimeType: "application/vnd.oasis.opendocument.spreadsheet",
59
+ ext: "ods"
60
+ }
61
+ };
62
+ function buildExportBuffer(rows, format = "xlsx") {
63
+ const config = FORMAT_CONFIG[format];
64
+ const ws = import_xlsx.utils.json_to_sheet(rows);
65
+ const wb = import_xlsx.utils.book_new();
66
+ import_xlsx.utils.book_append_sheet(wb, ws, "Sheet1");
67
+ return (0, import_xlsx.write)(wb, {
68
+ type: "buffer",
69
+ bookType: config.bookType,
70
+ ...config.opts
71
+ });
72
+ }
73
+ __name(buildExportBuffer, "buildExportBuffer");
74
+ function getExportMimeType(format) {
75
+ return FORMAT_CONFIG[format].mimeType;
76
+ }
77
+ __name(getExportMimeType, "getExportMimeType");
78
+ function getExportExt(format) {
79
+ return FORMAT_CONFIG[format].ext;
80
+ }
81
+ __name(getExportExt, "getExportExt");
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ buildExportBuffer,
85
+ getExportExt,
86
+ getExportMimeType
87
+ });
88
+ //# sourceMappingURL=xlsx.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/xlsx.ts","../src/utils/export.utils.ts"],"sourcesContent":["export { type ExportFormat, buildExportBuffer, getExportExt, getExportMimeType } from './utils/export.utils';\n","import { type BookType, utils, write } from 'xlsx';\n\nexport type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';\n\nconst FORMAT_CONFIG: Record<ExportFormat, { bookType: BookType; mimeType: string; ext: string; opts?: Record<string, unknown> }> = {\n xlsx: { bookType: 'xlsx', mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ext: 'xlsx' },\n xls: { bookType: 'biff8', mimeType: 'application/vnd.ms-excel', ext: 'xls' },\n csv: { bookType: 'csv', mimeType: 'text/csv', ext: 'csv' },\n tsv: { bookType: 'csv', mimeType: 'text/tab-separated-values', ext: 'tsv', opts: { FS: '\\t' } },\n ods: { bookType: 'ods', mimeType: 'application/vnd.oasis.opendocument.spreadsheet', ext: 'ods' },\n};\n\n// Converts an array of row objects into a spreadsheet buffer in the given format\nexport function buildExportBuffer(rows: Record<string, unknown>[], format: ExportFormat = 'xlsx'): Buffer {\n const config = FORMAT_CONFIG[format];\n const ws = utils.json_to_sheet(rows);\n const wb = utils.book_new();\n utils.book_append_sheet(wb, ws, 'Sheet1');\n return write(wb, { type: 'buffer', bookType: config.bookType, ...config.opts }) as Buffer;\n}\n\nexport function getExportMimeType(format: ExportFormat): string {\n return FORMAT_CONFIG[format].mimeType;\n}\n\nexport function getExportExt(format: ExportFormat): string {\n return FORMAT_CONFIG[format].ext;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;ACAA,kBAA4C;AAI5C,IAAMA,gBAA6H;EACjIC,MAAM;IAAEC,UAAU;IAAQC,UAAU;IAAqEC,KAAK;EAAO;EACrHC,KAAK;IAAEH,UAAU;IAASC,UAAU;IAA4BC,KAAK;EAAM;EAC3EE,KAAK;IAAEJ,UAAU;IAAOC,UAAU;IAAYC,KAAK;EAAM;EACzDG,KAAK;IAAEL,UAAU;IAAOC,UAAU;IAA6BC,KAAK;IAAOI,MAAM;MAAEC,IAAI;IAAK;EAAE;EAC9FC,KAAK;IAAER,UAAU;IAAOC,UAAU;IAAkDC,KAAK;EAAM;AACjG;AAGO,SAASO,kBAAkBC,MAAiCC,SAAuB,QAAM;AAC9F,QAAMC,SAASd,cAAca,MAAAA;AAC7B,QAAME,KAAKC,kBAAMC,cAAcL,IAAAA;AAC/B,QAAMM,KAAKF,kBAAMG,SAAQ;AACzBH,oBAAMI,kBAAkBF,IAAIH,IAAI,QAAA;AAChC,aAAOM,mBAAMH,IAAI;IAAEI,MAAM;IAAUpB,UAAUY,OAAOZ;IAAU,GAAGY,OAAON;EAAK,CAAA;AAC/E;AANgBG;AAQT,SAASY,kBAAkBV,QAAoB;AACpD,SAAOb,cAAca,MAAAA,EAAQV;AAC/B;AAFgBoB;AAIT,SAASC,aAAaX,QAAoB;AAC/C,SAAOb,cAAca,MAAAA,EAAQT;AAC/B;AAFgBoB;","names":["FORMAT_CONFIG","xlsx","bookType","mimeType","ext","xls","csv","tsv","opts","FS","ods","buildExportBuffer","rows","format","config","ws","utils","json_to_sheet","wb","book_new","book_append_sheet","write","type","getExportMimeType","getExportExt"]}
@@ -0,0 +1,6 @@
1
+ type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';
2
+ declare function buildExportBuffer(rows: Record<string, unknown>[], format?: ExportFormat): Buffer;
3
+ declare function getExportMimeType(format: ExportFormat): string;
4
+ declare function getExportExt(format: ExportFormat): string;
5
+
6
+ export { type ExportFormat, buildExportBuffer, getExportExt, getExportMimeType };
package/dist/xlsx.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';
2
+ declare function buildExportBuffer(rows: Record<string, unknown>[], format?: ExportFormat): Buffer;
3
+ declare function getExportMimeType(format: ExportFormat): string;
4
+ declare function getExportExt(format: ExportFormat): string;
5
+
6
+ export { type ExportFormat, buildExportBuffer, getExportExt, getExportMimeType };
package/dist/xlsx.js ADDED
@@ -0,0 +1,61 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/utils/export.utils.ts
5
+ import { utils, write } from "xlsx";
6
+ var FORMAT_CONFIG = {
7
+ xlsx: {
8
+ bookType: "xlsx",
9
+ mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
10
+ ext: "xlsx"
11
+ },
12
+ xls: {
13
+ bookType: "biff8",
14
+ mimeType: "application/vnd.ms-excel",
15
+ ext: "xls"
16
+ },
17
+ csv: {
18
+ bookType: "csv",
19
+ mimeType: "text/csv",
20
+ ext: "csv"
21
+ },
22
+ tsv: {
23
+ bookType: "csv",
24
+ mimeType: "text/tab-separated-values",
25
+ ext: "tsv",
26
+ opts: {
27
+ FS: " "
28
+ }
29
+ },
30
+ ods: {
31
+ bookType: "ods",
32
+ mimeType: "application/vnd.oasis.opendocument.spreadsheet",
33
+ ext: "ods"
34
+ }
35
+ };
36
+ function buildExportBuffer(rows, format = "xlsx") {
37
+ const config = FORMAT_CONFIG[format];
38
+ const ws = utils.json_to_sheet(rows);
39
+ const wb = utils.book_new();
40
+ utils.book_append_sheet(wb, ws, "Sheet1");
41
+ return write(wb, {
42
+ type: "buffer",
43
+ bookType: config.bookType,
44
+ ...config.opts
45
+ });
46
+ }
47
+ __name(buildExportBuffer, "buildExportBuffer");
48
+ function getExportMimeType(format) {
49
+ return FORMAT_CONFIG[format].mimeType;
50
+ }
51
+ __name(getExportMimeType, "getExportMimeType");
52
+ function getExportExt(format) {
53
+ return FORMAT_CONFIG[format].ext;
54
+ }
55
+ __name(getExportExt, "getExportExt");
56
+ export {
57
+ buildExportBuffer,
58
+ getExportExt,
59
+ getExportMimeType
60
+ };
61
+ //# sourceMappingURL=xlsx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/export.utils.ts"],"sourcesContent":["import { type BookType, utils, write } from 'xlsx';\n\nexport type ExportFormat = 'xlsx' | 'xls' | 'csv' | 'tsv' | 'ods';\n\nconst FORMAT_CONFIG: Record<ExportFormat, { bookType: BookType; mimeType: string; ext: string; opts?: Record<string, unknown> }> = {\n xlsx: { bookType: 'xlsx', mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ext: 'xlsx' },\n xls: { bookType: 'biff8', mimeType: 'application/vnd.ms-excel', ext: 'xls' },\n csv: { bookType: 'csv', mimeType: 'text/csv', ext: 'csv' },\n tsv: { bookType: 'csv', mimeType: 'text/tab-separated-values', ext: 'tsv', opts: { FS: '\\t' } },\n ods: { bookType: 'ods', mimeType: 'application/vnd.oasis.opendocument.spreadsheet', ext: 'ods' },\n};\n\n// Converts an array of row objects into a spreadsheet buffer in the given format\nexport function buildExportBuffer(rows: Record<string, unknown>[], format: ExportFormat = 'xlsx'): Buffer {\n const config = FORMAT_CONFIG[format];\n const ws = utils.json_to_sheet(rows);\n const wb = utils.book_new();\n utils.book_append_sheet(wb, ws, 'Sheet1');\n return write(wb, { type: 'buffer', bookType: config.bookType, ...config.opts }) as Buffer;\n}\n\nexport function getExportMimeType(format: ExportFormat): string {\n return FORMAT_CONFIG[format].mimeType;\n}\n\nexport function getExportExt(format: ExportFormat): string {\n return FORMAT_CONFIG[format].ext;\n}\n"],"mappings":";;;;AAAA,SAAwBA,OAAOC,aAAa;AAI5C,IAAMC,gBAA6H;EACjIC,MAAM;IAAEC,UAAU;IAAQC,UAAU;IAAqEC,KAAK;EAAO;EACrHC,KAAK;IAAEH,UAAU;IAASC,UAAU;IAA4BC,KAAK;EAAM;EAC3EE,KAAK;IAAEJ,UAAU;IAAOC,UAAU;IAAYC,KAAK;EAAM;EACzDG,KAAK;IAAEL,UAAU;IAAOC,UAAU;IAA6BC,KAAK;IAAOI,MAAM;MAAEC,IAAI;IAAK;EAAE;EAC9FC,KAAK;IAAER,UAAU;IAAOC,UAAU;IAAkDC,KAAK;EAAM;AACjG;AAGO,SAASO,kBAAkBC,MAAiCC,SAAuB,QAAM;AAC9F,QAAMC,SAASd,cAAca,MAAAA;AAC7B,QAAME,KAAKC,MAAMC,cAAcL,IAAAA;AAC/B,QAAMM,KAAKF,MAAMG,SAAQ;AACzBH,QAAMI,kBAAkBF,IAAIH,IAAI,QAAA;AAChC,SAAOM,MAAMH,IAAI;IAAEI,MAAM;IAAUpB,UAAUY,OAAOZ;IAAU,GAAGY,OAAON;EAAK,CAAA;AAC/E;AANgBG;AAQT,SAASY,kBAAkBV,QAAoB;AACpD,SAAOb,cAAca,MAAAA,EAAQV;AAC/B;AAFgBoB;AAIT,SAASC,aAAaX,QAAoB;AAC/C,SAAOb,cAAca,MAAAA,EAAQT;AAC/B;AAFgBoB;","names":["utils","write","FORMAT_CONFIG","xlsx","bookType","mimeType","ext","xls","csv","tsv","opts","FS","ods","buildExportBuffer","rows","format","config","ws","utils","json_to_sheet","wb","book_new","book_append_sheet","write","type","getExportMimeType","getExportExt"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vritti/api-sdk",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -35,6 +35,16 @@
35
35
  "types": "./dist/drizzle-pg-core.d.cts",
36
36
  "default": "./dist/drizzle-pg-core.cjs"
37
37
  }
38
+ },
39
+ "./xlsx": {
40
+ "import": {
41
+ "types": "./dist/xlsx.d.ts",
42
+ "default": "./dist/xlsx.js"
43
+ },
44
+ "require": {
45
+ "types": "./dist/xlsx.d.cts",
46
+ "default": "./dist/xlsx.cjs"
47
+ }
38
48
  }
39
49
  },
40
50
  "files": [
@@ -56,7 +66,8 @@
56
66
  "ioredis": "^5.4.1",
57
67
  "pg": "^8.16.0",
58
68
  "winston": "^3.11.0",
59
- "winston-daily-rotate-file": "^5.0.0"
69
+ "winston-daily-rotate-file": "^5.0.0",
70
+ "xlsx": "^0.18.5"
60
71
  },
61
72
  "peerDependencies": {
62
73
  "@nestjs/common": "^11.0.0",