@hendoi/henmesh 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ LicenseRef-Proprietary
2
+
3
+ HENMESH JavaScript/TypeScript SDK (HM-JS-SDK-001)
4
+ Copyright (c) HENDOI TECHNOLOGIES PRIVATE LIMITED. All rights reserved.
5
+
6
+ This software and associated documentation files (the "Software") are the
7
+ proprietary property of HENDOI TECHNOLOGIES PRIVATE LIMITED ("HENDOI").
8
+
9
+ Permission to use the Software is granted only under a valid HENDOI
10
+ subscription, agreement, or other written authorization from HENDOI, and
11
+ solely for interacting with HENMESH / HENDOI services as permitted by that
12
+ authorization.
13
+
14
+ You may not copy, modify, merge, publish, distribute, sublicense, sell,
15
+ rent, lease, reverse engineer (except to the limited extent that applicable
16
+ law forbids this restriction), or otherwise exploit the Software except as
17
+ expressly allowed by HENDOI in writing.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
22
+ HENDOI OR ITS LICENSORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
23
+ LIABILITY ARISING FROM USE OF THE SOFTWARE.
24
+
25
+ Contact: support@hendoi.com
26
+ Website: https://hendoi.com
package/README.md CHANGED
@@ -1,3 +1,125 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @hendoi/henmesh — JavaScript / TypeScript SDK (HM-JS-SDK-001)
2
+
3
+ Official headless HTTPS client for production **[HENMESH](https://henmesh.hendoi.com)** — HENDOI’s mesh / Δs₁ prep workspace.
4
+
5
+ Same REST surface as the workspace: 2-D airfoil/section mesh → quality / GCI independence → 3-D wing mesh → FSI map → CAD formats.
6
+
7
+ **Version 0.1.1** · **npm:** [@hendoi/henmesh](https://www.npmjs.com/package/@hendoi/henmesh) · **API docs:** [henmesh-overview](https://api.hendoi.com/?doc=henmesh-overview) · **Python twin:** [henmesh on PyPI](https://pypi.org/project/henmesh/)
8
+
9
+ Every request sends `X-Henmesh-Client: henmesh-js/0.1.1`.
10
+
11
+ ---
12
+
13
+ ## What this package is
14
+
15
+ `@hendoi/henmesh` automates HENMESH mesh generation and quality gates over HTTPS from Node.js / TypeScript. Use it to script screening grids before CFD/FEA — not as a local HyperMesh replacement.
16
+
17
+ Host: `https://henmesh.hendoi.com` · key prefix: `hmk_…`
18
+
19
+ ## Where it is used
20
+
21
+ | Context | Typical use |
22
+ |---|---|
23
+ | **Pre-CFD mesh prep** | `mesh2dAirfoil` / `mesh2dSection` then quality |
24
+ | **Independence / GCI scrub** | `mesh2dIndependence` before citing soft residuals |
25
+ | **Wing block prep** | `mesh3dWing` + `mesh3dQuality` |
26
+ | **FSI map** | `meshFsiMap` before structure handoff |
27
+ | **Stack** | After HENFOIL/HENSYNTH · before HENFLOW/HENSTRUCT |
28
+
29
+ Product page: [hendoi.com/products/henmesh](https://hendoi.com/products/henmesh)
30
+
31
+ ## Requirements
32
+
33
+ - **Node.js ≥ 18**
34
+ - HENMESH API key `hmk_…`
35
+ - License: **LicenseRef-Proprietary** (HENDOI)
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ npm install @hendoi/henmesh
41
+ npm install @hendoi/henmesh@0.1.1
42
+ ```
43
+
44
+ ## Auth & environment
45
+
46
+ ```bash
47
+ export HENMESH_API_KEY=hmk_YOUR_KEY
48
+ # export HENMESH_API_URL=https://henmesh.hendoi.com
49
+ # local: export HENMESH_API_URL=http://localhost:8005
50
+ ```
51
+
52
+ ```ts
53
+ import { Client } from "@hendoi/henmesh";
54
+ const c = new Client({ apiKey: "hmk_…" });
55
+ ```
56
+
57
+ ## Quick start
58
+
59
+ ```ts
60
+ import { Client } from "@hendoi/henmesh";
61
+
62
+ const c = new Client();
63
+ console.log(await c.usage());
64
+ console.log(await c.methods());
65
+
66
+ const mesh = await c.mesh2dAirfoil({
67
+ // coordinates / airfoil payload per API docs
68
+ });
69
+ const quality = await c.mesh2dQuality({ meshId: mesh.id /* … */ });
70
+ console.log(quality);
71
+ ```
72
+
73
+ ## Core features (method map)
74
+
75
+ | Method | What it does | REST notes |
76
+ |---|---|---|
77
+ | `usage` / `job` / `cancelJob` | Meters & jobs | `/usage` · `/jobs/:id` |
78
+ | `methods` | Mesh method catalogue | `GET /mesh/methods` |
79
+ | `projects` / `createProject` | Projects | `/projects*` |
80
+ | `mesh2dAirfoil` / `mesh2dSection` | 2-D generate | `/mesh/2d/*/generate` |
81
+ | `mesh2dQuality` / `mesh2dIndependence` | Quality / GCI | `/mesh/2d/quality` · `independence` |
82
+ | `mesh3dWing` / `mesh3dQuality` | 3-D wing | `/mesh/3d/*` |
83
+ | `meshFsiMap` | FSI mapping | `/mesh/fsi/map` |
84
+ | `cadFormats` | CAD import formats | `GET /cad/formats` |
85
+
86
+ ## Errors
87
+
88
+ Throws `HenmeshError` (`.status`, `.body`, `.quotaExceeded`).
89
+
90
+ ## What it cannot claim
91
+
92
+ Not HyperMesh / Pointwise certification meshing. Screening grids and honesty gates only.
93
+
94
+ ## TypeScript
95
+
96
+ ```ts
97
+ import { Client, HenmeshError, CLIENT_VERSION } from "@hendoi/henmesh";
98
+ import type { ClientOptions, Json } from "@hendoi/henmesh";
99
+ ```
100
+
101
+ ## Sister SDKs
102
+
103
+ | Python | JavaScript |
104
+ |---|---|
105
+ | [`henmesh`](https://pypi.org/project/henmesh/) | [`@hendoi/henmesh`](https://www.npmjs.com/package/@hendoi/henmesh) |
106
+ | [`henfoil`](https://pypi.org/project/henfoil/) | [`@hendoi/henfoil`](https://www.npmjs.com/package/@hendoi/henfoil) |
107
+ | [`hensynth`](https://pypi.org/project/hensynth/) | [`@hendoi/hensynth`](https://www.npmjs.com/package/@hendoi/hensynth) |
108
+ | [`henflow`](https://pypi.org/project/henflow/) | [`@hendoi/henflow`](https://www.npmjs.com/package/@hendoi/henflow) |
109
+ | [`henstruct`](https://pypi.org/project/henstruct/) | [`@hendoi/henstruct`](https://www.npmjs.com/package/@hendoi/henstruct) |
110
+
111
+ ## Links
112
+
113
+ | | |
114
+ |---|---|
115
+ | **npm** | https://www.npmjs.com/package/@hendoi/henmesh |
116
+ | Product app | https://henmesh.hendoi.com |
117
+ | Marketing | https://hendoi.com/products/henmesh |
118
+ | API overview | https://api.hendoi.com/?doc=henmesh-overview |
119
+ | Auth | https://api.hendoi.com/?doc=henmesh-authentication |
120
+ | Platform JS docs | https://api.hendoi.com/?doc=javascript-sdk |
121
+ | Support | support@hendoi.com |
122
+
123
+ ---
124
+
125
+ © HENDOI TECHNOLOGIES PRIVATE LIMITED. Proprietary — see `LICENSE`.
@@ -0,0 +1,49 @@
1
+ /** HTTP client for HENMESH /api/v1 — HM-JS-SDK-001 (0.1.1). */
2
+ export declare const CLIENT_VERSION = "0.1.1";
3
+ export type Json = Record<string, unknown>;
4
+ export declare class HenmeshError extends Error {
5
+ status: number;
6
+ body: unknown;
7
+ headers: Record<string, string>;
8
+ constructor(message: string, status?: number, body?: unknown, headers?: Record<string, string>);
9
+ get quotaExceeded(): boolean;
10
+ }
11
+ export type ClientOptions = {
12
+ apiKey?: string;
13
+ baseUrl?: string;
14
+ timeoutMs?: number;
15
+ pollIntervalMs?: number;
16
+ quotaWarnings?: boolean;
17
+ };
18
+ export declare class Client {
19
+ apiKey: string;
20
+ baseUrl: string;
21
+ timeoutMs: number;
22
+ pollIntervalMs: number;
23
+ quotaWarnings: boolean;
24
+ lastQuota: Record<string, unknown>;
25
+ private warned;
26
+ constructor(opts?: ClientOptions);
27
+ private headers;
28
+ private emitQuotaWarning;
29
+ private captureQuota;
30
+ private parse;
31
+ private get;
32
+ private post;
33
+ private awaitJob;
34
+ private maybeAwait;
35
+ usage(): Promise<Json>;
36
+ job(jobId: string): Promise<Json>;
37
+ cancelJob(jobId: string): Promise<Json>;
38
+ methods(): Promise<Json>;
39
+ projects(): Promise<Json>;
40
+ createProject(body: Record<string, unknown>): Promise<Json>;
41
+ mesh2dAirfoil(body: Record<string, unknown>, awaitJob?: boolean): Promise<Json>;
42
+ mesh2dSection(body: Record<string, unknown>, awaitJob?: boolean): Promise<Json>;
43
+ mesh2dQuality(body: Record<string, unknown>): Promise<Json>;
44
+ mesh2dIndependence(body: Record<string, unknown>, awaitJob?: boolean): Promise<Json>;
45
+ mesh3dWing(body: Record<string, unknown>, awaitJob?: boolean): Promise<Json>;
46
+ mesh3dQuality(body: Record<string, unknown>): Promise<Json>;
47
+ meshFsiMap(body: Record<string, unknown>, awaitJob?: boolean): Promise<Json>;
48
+ cadFormats(): Promise<Json>;
49
+ }
package/dist/client.js ADDED
@@ -0,0 +1,221 @@
1
+ /** HTTP client for HENMESH /api/v1 — HM-JS-SDK-001 (0.1.1). */
2
+ export const CLIENT_VERSION = "0.1.1";
3
+ const DEVELOPERS_HELP = "Create a hmk_… key: sign in at https://hendoi.com/login → open HENMESH → " +
4
+ "Developers (or Settings → API) → copy the key → export HENMESH_API_KEY=hmk_…";
5
+ export class HenmeshError extends Error {
6
+ status;
7
+ body;
8
+ headers;
9
+ constructor(message, status = 0, body = null, headers = {}) {
10
+ super(message);
11
+ this.name = "HenmeshError";
12
+ this.status = status;
13
+ this.body = body;
14
+ this.headers = headers;
15
+ }
16
+ get quotaExceeded() {
17
+ if (!this.body || typeof this.body !== "object")
18
+ return this.status === 403;
19
+ const b = this.body;
20
+ const meter = String(b.meter ?? "");
21
+ const code = String(b.code ?? b.error ?? "");
22
+ return (this.status === 403 &&
23
+ (meter === "apiRequests" || meter === "pythonSdk" || /QUOTA/i.test(code) || /quota/i.test(this.message)));
24
+ }
25
+ }
26
+ function env(name) {
27
+ return (typeof process !== "undefined" && process.env && process.env[name]) || "";
28
+ }
29
+ function headerInt(headers, ...names) {
30
+ for (const name of names) {
31
+ const v = headers.get(name);
32
+ if (v && v !== "unlimited") {
33
+ const n = Number.parseInt(v, 10);
34
+ if (!Number.isNaN(n))
35
+ return n;
36
+ }
37
+ }
38
+ return undefined;
39
+ }
40
+ function headerStr(headers, ...names) {
41
+ for (const name of names) {
42
+ const v = headers.get(name);
43
+ if (v)
44
+ return v;
45
+ }
46
+ return undefined;
47
+ }
48
+ function sleep(ms) {
49
+ return new Promise((r) => setTimeout(r, ms));
50
+ }
51
+ export class Client {
52
+ apiKey;
53
+ baseUrl;
54
+ timeoutMs;
55
+ pollIntervalMs;
56
+ quotaWarnings;
57
+ lastQuota = {};
58
+ warned = new Set();
59
+ constructor(opts = {}) {
60
+ this.apiKey = opts.apiKey || env("HENMESH_API_KEY") || "";
61
+ this.baseUrl = (opts.baseUrl || env("HENMESH_API_URL") || "https://henmesh.hendoi.com").replace(/\/$/, "");
62
+ this.timeoutMs = opts.timeoutMs ?? 120_000;
63
+ this.pollIntervalMs = opts.pollIntervalMs ?? 2_000;
64
+ this.quotaWarnings = opts.quotaWarnings ?? true;
65
+ if (!this.apiKey) {
66
+ throw new HenmeshError(`Missing API key. Set apiKey or HENMESH_API_KEY.\n${DEVELOPERS_HELP}\n` +
67
+ "There is no browser→terminal login yet — copy the key from Developers UI.");
68
+ }
69
+ }
70
+ headers() {
71
+ return {
72
+ Authorization: `Bearer ${this.apiKey}`,
73
+ "X-Henmesh-Key": this.apiKey,
74
+ "X-Henmesh-Client": `henmesh-js/${CLIENT_VERSION}`,
75
+ "User-Agent": `henmesh-js/${CLIENT_VERSION}`,
76
+ "Content-Type": "application/json",
77
+ Accept: "application/json",
78
+ };
79
+ }
80
+ emitQuotaWarning(text, key) {
81
+ if (!this.quotaWarnings || !text || this.warned.has(key))
82
+ return;
83
+ this.warned.add(key);
84
+ console.warn(`henmesh: ${text}`);
85
+ }
86
+ captureQuota(headers) {
87
+ const quota = {
88
+ apiLimit: headerInt(headers, "X-Henmesh-Api-Limit", "X-Api-Limit"),
89
+ apiRemaining: headerInt(headers, "X-Henmesh-Api-Remaining", "X-Api-Remaining"),
90
+ apiWarning: headerStr(headers, "X-Henmesh-Api-Warning", "X-Api-Warning"),
91
+ };
92
+ this.lastQuota = Object.fromEntries(Object.entries(quota).filter(([, v]) => v !== undefined));
93
+ if (quota.apiWarning)
94
+ this.emitQuotaWarning(String(quota.apiWarning), `api:${quota.apiRemaining}`);
95
+ }
96
+ async parse(res) {
97
+ this.captureQuota(res.headers);
98
+ let data = {};
99
+ const text = await res.text();
100
+ if (text) {
101
+ try {
102
+ data = JSON.parse(text);
103
+ }
104
+ catch {
105
+ data = { raw: text };
106
+ }
107
+ }
108
+ if (res.status >= 400) {
109
+ const body = data && typeof data === "object" ? data : {};
110
+ const msg = String(body.error ?? body.message ?? body.detail ?? "");
111
+ const err = new HenmeshError(msg || `HENMESH HTTP ${res.status}`, res.status, data, Object.fromEntries(res.headers.entries()));
112
+ if (err.quotaExceeded) {
113
+ this.emitQuotaWarning("Quota exceeded. Check plan limits or wait for monthly reset. See https://hendoi.com/pricing.", `exhausted:${res.status}`);
114
+ }
115
+ throw err;
116
+ }
117
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
118
+ throw new HenmeshError("Expected JSON object response", res.status, data);
119
+ }
120
+ return data;
121
+ }
122
+ async get(path, params, timeoutMs) {
123
+ const url = new URL(`${this.baseUrl}${path}`);
124
+ if (params) {
125
+ for (const [k, v] of Object.entries(params)) {
126
+ if (v !== undefined && v !== null)
127
+ url.searchParams.set(k, String(v));
128
+ }
129
+ }
130
+ const ac = new AbortController();
131
+ const t = setTimeout(() => ac.abort(), timeoutMs ?? this.timeoutMs);
132
+ try {
133
+ const res = await fetch(url, { method: "GET", headers: this.headers(), signal: ac.signal });
134
+ return await this.parse(res);
135
+ }
136
+ finally {
137
+ clearTimeout(t);
138
+ }
139
+ }
140
+ async post(path, body, timeoutMs) {
141
+ const ac = new AbortController();
142
+ const t = setTimeout(() => ac.abort(), timeoutMs ?? this.timeoutMs);
143
+ try {
144
+ const res = await fetch(`${this.baseUrl}${path}`, {
145
+ method: "POST",
146
+ headers: this.headers(),
147
+ body: JSON.stringify(body),
148
+ signal: ac.signal,
149
+ });
150
+ return await this.parse(res);
151
+ }
152
+ finally {
153
+ clearTimeout(t);
154
+ }
155
+ }
156
+ async awaitJob(job, timeoutMs = 1_800_000) {
157
+ const jobId = String(job.jobId ?? job.id ?? "");
158
+ if (!jobId)
159
+ return job;
160
+ const deadline = Date.now() + timeoutMs;
161
+ while (Date.now() < deadline) {
162
+ const data = await this.job(jobId);
163
+ const status = String(data.status ?? data.state ?? "").toLowerCase();
164
+ if (["done", "completed", "succeeded", "success", "completed_with_warnings"].includes(status)) {
165
+ const result = data.result ?? data.payload ?? data;
166
+ return result && typeof result === "object" && !Array.isArray(result)
167
+ ? result
168
+ : { result, job: data };
169
+ }
170
+ if (["failed", "error", "cancelled"].includes(status)) {
171
+ throw new HenmeshError(`Job ${jobId} ${status}`, 0, data);
172
+ }
173
+ await sleep(this.pollIntervalMs);
174
+ }
175
+ throw new HenmeshError(`Job ${jobId} timed out after ${timeoutMs}ms`, 408, job);
176
+ }
177
+ async maybeAwait(out, awaitJob) {
178
+ if (awaitJob && (out.jobId || out.status === "queued"))
179
+ return this.awaitJob(out);
180
+ return out;
181
+ }
182
+ async usage() {
183
+ return this.get("/api/v1/usage");
184
+ }
185
+ async job(jobId) {
186
+ return this.get(`/api/v1/jobs/${jobId}`);
187
+ }
188
+ async cancelJob(jobId) {
189
+ return this.post(`/api/v1/jobs/${jobId}/cancel`, {});
190
+ }
191
+ async methods() { return this.get("/api/v1/mesh/methods"); }
192
+ async projects() { return this.get("/api/v1/projects"); }
193
+ async createProject(body) { return this.post("/api/v1/projects", body); }
194
+ async mesh2dAirfoil(body, awaitJob = true) {
195
+ const out = await this.post("/api/v1/mesh/2d/airfoil/generate", body, Math.max(this.timeoutMs, 600_000));
196
+ return this.maybeAwait(out, awaitJob);
197
+ }
198
+ async mesh2dSection(body, awaitJob = true) {
199
+ const out = await this.post("/api/v1/mesh/2d/section/generate", body, Math.max(this.timeoutMs, 600_000));
200
+ return this.maybeAwait(out, awaitJob);
201
+ }
202
+ async mesh2dQuality(body) {
203
+ return this.post("/api/v1/mesh/2d/quality", body);
204
+ }
205
+ async mesh2dIndependence(body, awaitJob = true) {
206
+ const out = await this.post("/api/v1/mesh/2d/independence", body, Math.max(this.timeoutMs, 900_000));
207
+ return this.maybeAwait(out, awaitJob);
208
+ }
209
+ async mesh3dWing(body, awaitJob = true) {
210
+ const out = await this.post("/api/v1/mesh/3d/wing/generate", body, Math.max(this.timeoutMs, 900_000));
211
+ return this.maybeAwait(out, awaitJob);
212
+ }
213
+ async mesh3dQuality(body) {
214
+ return this.post("/api/v1/mesh/3d/quality", body);
215
+ }
216
+ async meshFsiMap(body, awaitJob = true) {
217
+ const out = await this.post("/api/v1/mesh/fsi/map", body, Math.max(this.timeoutMs, 600_000));
218
+ return this.maybeAwait(out, awaitJob);
219
+ }
220
+ async cadFormats() { return this.get("/api/v1/cad/formats"); }
221
+ }
@@ -0,0 +1,2 @@
1
+ export { CLIENT_VERSION, Client, HenmeshError } from "./client.js";
2
+ export type { ClientOptions, Json } from "./client.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { CLIENT_VERSION, Client, HenmeshError } from "./client.js";
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
- {
2
- "name": "@hendoi/henmesh",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@hendoi/henmesh",
3
+ "version": "0.1.1",
4
+ "description": "Official HENMESH JavaScript/TypeScript SDK — 2-D/3-D mesh, quality, GCI, FSI map.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "test": "npm run build && node --test test/client.test.js",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "engines": {
25
+ "node": ">=18"
26
+ },
27
+ "keywords": [
28
+ "henmesh",
29
+ "hendoi",
30
+ "aerospace",
31
+ "sdk",
32
+ "typescript"
33
+ ],
34
+ "author": "HENDOI TECHNOLOGIES PRIVATE LIMITED <support@hendoi.com>",
35
+ "license": "SEE LICENSE IN LICENSE",
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "homepage": "https://henmesh.hendoi.com",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/hendoi/hendoi.git",
43
+ "directory": "henmesh-sdk/js"
44
+ },
45
+ "bugs": {
46
+ "url": "https://hendoi.com/contact"
47
+ },
48
+ "devDependencies": {
49
+ "typescript": "^5.6.0",
50
+ "@types/node": "^22.0.0"
51
+ }
52
+ }