qorstack-report-sdk 0.0.1

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.
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ /* tslint:disable */
4
+ // @ts-nocheck
5
+ /*
6
+ * ---------------------------------------------------------------
7
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
8
+ * ## ##
9
+ * ## AUTHOR: acacode ##
10
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
11
+ * ---------------------------------------------------------------
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.Api = exports.HttpClient = exports.ContentType = void 0;
15
+ var ContentType;
16
+ (function (ContentType) {
17
+ ContentType["Json"] = "application/json";
18
+ ContentType["JsonApi"] = "application/vnd.api+json";
19
+ ContentType["FormData"] = "multipart/form-data";
20
+ ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
21
+ ContentType["Text"] = "text/plain";
22
+ })(ContentType || (exports.ContentType = ContentType = {}));
23
+ class HttpClient {
24
+ constructor(apiConfig = {}) {
25
+ this.baseUrl = "";
26
+ this.securityData = null;
27
+ this.abortControllers = new Map();
28
+ this.customFetch = (...fetchParams) => fetch(...fetchParams);
29
+ this.baseApiParams = {
30
+ credentials: "same-origin",
31
+ headers: {},
32
+ redirect: "follow",
33
+ referrerPolicy: "no-referrer",
34
+ };
35
+ this.setSecurityData = (data) => {
36
+ this.securityData = data;
37
+ };
38
+ this.contentFormatters = {
39
+ [ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string")
40
+ ? JSON.stringify(input)
41
+ : input,
42
+ [ContentType.JsonApi]: (input) => input !== null && (typeof input === "object" || typeof input === "string")
43
+ ? JSON.stringify(input)
44
+ : input,
45
+ [ContentType.Text]: (input) => input !== null && typeof input !== "string"
46
+ ? JSON.stringify(input)
47
+ : input,
48
+ [ContentType.FormData]: (input) => {
49
+ if (input instanceof FormData) {
50
+ return input;
51
+ }
52
+ return Object.keys(input || {}).reduce((formData, key) => {
53
+ const property = input[key];
54
+ formData.append(key, property instanceof Blob
55
+ ? property
56
+ : typeof property === "object" && property !== null
57
+ ? JSON.stringify(property)
58
+ : `${property}`);
59
+ return formData;
60
+ }, new FormData());
61
+ },
62
+ [ContentType.UrlEncoded]: (input) => this.toQueryString(input),
63
+ };
64
+ this.createAbortSignal = (cancelToken) => {
65
+ if (this.abortControllers.has(cancelToken)) {
66
+ const abortController = this.abortControllers.get(cancelToken);
67
+ if (abortController) {
68
+ return abortController.signal;
69
+ }
70
+ return void 0;
71
+ }
72
+ const abortController = new AbortController();
73
+ this.abortControllers.set(cancelToken, abortController);
74
+ return abortController.signal;
75
+ };
76
+ this.abortRequest = (cancelToken) => {
77
+ const abortController = this.abortControllers.get(cancelToken);
78
+ if (abortController) {
79
+ abortController.abort();
80
+ this.abortControllers.delete(cancelToken);
81
+ }
82
+ };
83
+ this.request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => {
84
+ const secureParams = ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) &&
85
+ this.securityWorker &&
86
+ (await this.securityWorker(this.securityData))) ||
87
+ {};
88
+ const requestParams = this.mergeRequestParams(params, secureParams);
89
+ const queryString = query && this.toQueryString(query);
90
+ const payloadFormatter = this.contentFormatters[type || ContentType.Json];
91
+ const responseFormat = format || requestParams.format;
92
+ return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, {
93
+ ...requestParams,
94
+ headers: {
95
+ ...(requestParams.headers || {}),
96
+ ...(type && type !== ContentType.FormData
97
+ ? { "Content-Type": type }
98
+ : {}),
99
+ },
100
+ signal: (cancelToken
101
+ ? this.createAbortSignal(cancelToken)
102
+ : requestParams.signal) || null,
103
+ body: typeof body === "undefined" || body === null
104
+ ? null
105
+ : payloadFormatter(body),
106
+ }).then(async (response) => {
107
+ const r = response;
108
+ r.data = null;
109
+ r.error = null;
110
+ const responseToParse = responseFormat ? response.clone() : response;
111
+ const data = !responseFormat
112
+ ? r
113
+ : await responseToParse[responseFormat]()
114
+ .then((data) => {
115
+ if (r.ok) {
116
+ r.data = data;
117
+ }
118
+ else {
119
+ r.error = data;
120
+ }
121
+ return r;
122
+ })
123
+ .catch((e) => {
124
+ r.error = e;
125
+ return r;
126
+ });
127
+ if (cancelToken) {
128
+ this.abortControllers.delete(cancelToken);
129
+ }
130
+ if (!response.ok)
131
+ throw data;
132
+ return data;
133
+ });
134
+ };
135
+ Object.assign(this, apiConfig);
136
+ }
137
+ encodeQueryParam(key, value) {
138
+ const encodedKey = encodeURIComponent(key);
139
+ return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`;
140
+ }
141
+ addQueryParam(query, key) {
142
+ return this.encodeQueryParam(key, query[key]);
143
+ }
144
+ addArrayQueryParam(query, key) {
145
+ const value = query[key];
146
+ return value.map((v) => this.encodeQueryParam(key, v)).join("&");
147
+ }
148
+ toQueryString(rawQuery) {
149
+ const query = rawQuery || {};
150
+ const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
151
+ return keys
152
+ .map((key) => Array.isArray(query[key])
153
+ ? this.addArrayQueryParam(query, key)
154
+ : this.addQueryParam(query, key))
155
+ .join("&");
156
+ }
157
+ addQueryParams(rawQuery) {
158
+ const queryString = this.toQueryString(rawQuery);
159
+ return queryString ? `?${queryString}` : "";
160
+ }
161
+ mergeRequestParams(params1, params2) {
162
+ return {
163
+ ...this.baseApiParams,
164
+ ...params1,
165
+ ...(params2 || {}),
166
+ headers: {
167
+ ...(this.baseApiParams.headers || {}),
168
+ ...(params1.headers || {}),
169
+ ...((params2 && params2.headers) || {}),
170
+ },
171
+ };
172
+ }
173
+ }
174
+ exports.HttpClient = HttpClient;
175
+ /**
176
+ * @title Qorstack Report API
177
+ * @version v1
178
+ *
179
+ * API for generating PDF reports from Word templates
180
+ */
181
+ class Api extends HttpClient {
182
+ constructor() {
183
+ super(...arguments);
184
+ this.render = {
185
+ /**
186
+ * No description
187
+ *
188
+ * @tags Render
189
+ * @name PostRenderWordTemplate
190
+ * @request POST:/render/word/template
191
+ * @secure
192
+ */
193
+ postRenderWordTemplate: (data, params = {}) => this.request({
194
+ path: `/render/word/template`,
195
+ method: "POST",
196
+ body: data,
197
+ secure: true,
198
+ type: ContentType.Json,
199
+ format: "json",
200
+ ...params,
201
+ }),
202
+ /**
203
+ * No description
204
+ *
205
+ * @tags Render
206
+ * @name PostRenderExcelTemplate
207
+ * @request POST:/render/excel/template
208
+ * @secure
209
+ */
210
+ postRenderExcelTemplate: (data, params = {}) => this.request({
211
+ path: `/render/excel/template`,
212
+ method: "POST",
213
+ body: data,
214
+ secure: true,
215
+ type: ContentType.Json,
216
+ format: "json",
217
+ ...params,
218
+ }),
219
+ };
220
+ }
221
+ }
222
+ exports.Api = Api;
@@ -0,0 +1,12 @@
1
+ import { Api } from "./QorstackApi";
2
+ export * from "./QorstackApi";
3
+ export declare class QorstackApi<SecurityDataType = unknown> extends Api<SecurityDataType> {
4
+ /**
5
+ * Creates a new instance of QorstackApi.
6
+ * @param config Optional configuration. If baseUrl is not provided, it tries to read from QORSTACK_API_URL or RENDOX_API_URL environment variables.
7
+ */
8
+ constructor(config?: {
9
+ baseUrl?: string;
10
+ securityData?: SecurityDataType;
11
+ });
12
+ }
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.QorstackApi = void 0;
18
+ const QorstackApi_1 = require("./QorstackApi");
19
+ __exportStar(require("./QorstackApi"), exports);
20
+ class QorstackApi extends QorstackApi_1.Api {
21
+ /**
22
+ * Creates a new instance of QorstackApi.
23
+ * @param config Optional configuration. If baseUrl is not provided, it tries to read from QORSTACK_API_URL or RENDOX_API_URL environment variables.
24
+ */
25
+ constructor(config = {}) {
26
+ let baseUrl = config.baseUrl;
27
+ // Try to load from environment variable if not provided
28
+ if (!baseUrl) {
29
+ try {
30
+ if (typeof process !== "undefined" && process.env) {
31
+ baseUrl =
32
+ process.env.QORSTACK_API_URL || process.env.RENDOX_API_URL;
33
+ }
34
+ }
35
+ catch (e) {
36
+ // Ignore errors accessing process.env
37
+ }
38
+ }
39
+ // Fallback to default if still not found
40
+ baseUrl = baseUrl || "https://api.qorstack.dev";
41
+ super({
42
+ baseUrl,
43
+ securityWorker: (securityData) => {
44
+ if (securityData) {
45
+ return securityData;
46
+ }
47
+ return {};
48
+ },
49
+ });
50
+ if (config.securityData) {
51
+ this.setSecurityData(config.securityData);
52
+ }
53
+ }
54
+ }
55
+ exports.QorstackApi = QorstackApi;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "qorstack-report-sdk",
3
+ "version": "0.0.1",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "sync-config": "node scripts/sync-config.js",
11
+ "prebuild": "yarn sync-config",
12
+ "build": "tsc",
13
+ "test": "echo \"Error: no test specified\" && exit 1",
14
+ "gen:nodejs": "swagger-typescript-api generate -p ./src/qorstack-swagger.json -o ./src/nodejs --name QorstackApi.ts",
15
+ "gen:dotnet": "nswag openapi2csclient /input:src/qorstack-swagger.json /output:src/dotnet/QorstackApi.cs /namespace:Qorstack.Report.Sdk /ClassName:QorstackApi",
16
+ "gen:all": "yarn gen:nodejs && yarn gen:dotnet"
17
+ },
18
+ "keywords": [
19
+ "qorstack",
20
+ "report",
21
+ "sdk",
22
+ "pdf",
23
+ "word"
24
+ ],
25
+ "author": "Qorstack",
26
+ "license": "MIT",
27
+ "description": "Qorstack Report SDK for Node.js and .NET",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/qorstack/qorstack-report"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^25.2.1",
34
+ "nswag": "^14.6.3",
35
+ "swagger-typescript-api": "^13.2.16",
36
+ "typescript": "^5.9.3"
37
+ }
38
+ }