apick-api 4.0.0 → 4.1.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.
@@ -1,12 +1,12 @@
1
- const { ApickClient } = require('apick-api');
2
-
3
- async function main() {
4
- const client = new ApickClient(process.env.APICK_API_KEY);
5
- const result = await client.whois('apick.app');
6
- console.log(result.data);
7
- }
8
-
9
- main().catch((error) => {
10
- console.error(error.message);
11
- process.exitCode = 1;
12
- });
1
+ const { ApickClient } = require('apick-api');
2
+
3
+ async function main() {
4
+ const client = new ApickClient(process.env.APICK_API_KEY);
5
+ const result = await client.whois('apick.app');
6
+ console.log(result.data);
7
+ }
8
+
9
+ main().catch((error) => {
10
+ console.error(error.message);
11
+ process.exitCode = 1;
12
+ });
@@ -1,9 +1,9 @@
1
- import { ApickClient } from 'apick-api';
2
-
3
- const client = new ApickClient(process.env.APICK_API_KEY);
4
-
5
- const ocr = await client.ocr('./receipt.jpg');
6
- console.log(ocr.data.result.full_text);
7
-
8
- const pdf = await client.htmlToPdf('<h1>APICK report</h1>', { pagination: true });
9
- await pdf.save('./report.pdf');
1
+ import { ApickClient } from 'apick-api';
2
+
3
+ const client = new ApickClient(process.env.APICK_API_KEY);
4
+
5
+ const ocr = await client.ocr('./receipt.jpg');
6
+ console.log(ocr.data.result.full_text);
7
+
8
+ const pdf = await client.htmlToPdf('<h1>APICK report</h1>', { pagination: true });
9
+ await pdf.save('./report.pdf');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apick-api",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Official zero-dependency Node.js client for APICK data, AI, and image APIs. 에이픽 데이터·AI·이미지 API 공식 Node.js SDK.",
5
5
  "type": "module",
6
6
  "main": "./src/index.cjs",
package/src/form.cjs CHANGED
@@ -1,28 +1,28 @@
1
- 'use strict';
2
-
3
- // Client-only multipart serialization. Each value occupies its own form part.
4
- function createForm(payload, endpoint) {
5
- const form = new FormData();
6
- const typed = endpoint === '/rest/json_to_excel';
7
- const forbidden = new Set(['__proto__', 'prototype', 'constructor']);
8
- function visit(value, parts) {
9
- if (parts.some(key => forbidden.has(key) || /[\[\]]/.test(key)) || parts.length > 12) throw new TypeError('Invalid form field path.');
10
- const name = parts[0] + parts.slice(1).map(key => `[${key}]`).join('');
11
- const cell = typed && parts[0] === 'data_list';
12
- if (value === undefined || (value === null && !cell)) return;
13
- if (value instanceof Blob) { form.append(name, value); return; }
14
- if (value && typeof value === 'object' && Object.keys(value).length) {
15
- if (cell) form.append('__apick_type' + parts.map(key => `[${key}]`).join(''), Array.isArray(value) ? 'array' : 'object');
16
- for (const key of Object.keys(value)) visit(value[key], parts.concat(key));
17
- return;
18
- }
19
- if (cell && typeof value !== 'string') {
20
- form.append('__apick_type' + parts.map(key => `[${key}]`).join(''), value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value);
21
- }
22
- if (!cell && value && typeof value === 'object') return;
23
- form.append(name, value === null || typeof value === 'object' ? '' : String(value));
24
- }
25
- for (const key of Object.keys(payload || {})) visit(payload[key], [key]);
26
- return form;
27
- }
28
- module.exports = { createForm };
1
+ 'use strict';
2
+
3
+ // Client-only multipart serialization. Each value occupies its own form part.
4
+ function createForm(payload, endpoint) {
5
+ const form = new FormData();
6
+ const typed = endpoint === '/rest/json_to_excel';
7
+ const forbidden = new Set(['__proto__', 'prototype', 'constructor']);
8
+ function visit(value, parts) {
9
+ if (parts.some(key => forbidden.has(key) || /[\[\]]/.test(key)) || parts.length > 12) throw new TypeError('Invalid form field path.');
10
+ const name = parts[0] + parts.slice(1).map(key => `[${key}]`).join('');
11
+ const cell = typed && parts[0] === 'data_list';
12
+ if (value === undefined || (value === null && !cell)) return;
13
+ if (value instanceof Blob) { form.append(name, value); return; }
14
+ if (value && typeof value === 'object' && Object.keys(value).length) {
15
+ if (cell) form.append('__apick_type' + parts.map(key => `[${key}]`).join(''), Array.isArray(value) ? 'array' : 'object');
16
+ for (const key of Object.keys(value)) visit(value[key], parts.concat(key));
17
+ return;
18
+ }
19
+ if (cell && typeof value !== 'string') {
20
+ form.append('__apick_type' + parts.map(key => `[${key}]`).join(''), value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value);
21
+ }
22
+ if (!cell && value && typeof value === 'object') return;
23
+ form.append(name, value === null || typeof value === 'object' ? '' : String(value));
24
+ }
25
+ for (const key of Object.keys(payload || {})) visit(payload[key], [key]);
26
+ return form;
27
+ }
28
+ module.exports = { createForm };