@panomc/client 1.0.0-dev.61 → 1.0.0-dev.63

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panomc/client",
3
- "version": "1.0.0-dev.61",
3
+ "version": "1.0.0-dev.63",
4
4
  "description": "Typed JavaScript client for the Pano HTTP API (JSDoc types, no dependencies, no framework).",
5
5
  "author": "PanoMC",
6
6
  "license": "MIT",
@@ -16,8 +16,7 @@
16
16
  "./package.json": "./package.json"
17
17
  },
18
18
  "files": [
19
- "src",
20
- "scripts"
19
+ "src"
21
20
  ],
22
21
  "publishConfig": {
23
22
  "access": "public"
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Regenerates src/core/ from the platform's core OpenAPI snapshot (doc 06 section 2.4, Builds).
4
- *
5
- * node scripts/generate-core.js [path/to/openapi-core.json]
6
- *
7
- * Default input: pano-web-platform/Pano/api/openapi-core.json next to this repo (umbrella layout), or
8
- * $PANO_OPENAPI_CORE. The result is committed; a second run changes nothing.
9
- */
10
- import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
11
- import { dirname, resolve } from "node:path";
12
- import { fileURLToPath } from "node:url";
13
- import { generateClient } from "../../client-gen/src/generate.js";
14
- import { writeFiles } from "../../client-gen/src/pull.js";
15
-
16
- const here = dirname(fileURLToPath(import.meta.url));
17
- const outDir = resolve(here, "../src/core");
18
- const defaultInput = resolve(here, "../../../../pano-web-platform/Pano/api/openapi-core.json");
19
- const input = resolve(process.argv[2] ?? process.env.PANO_OPENAPI_CORE ?? defaultInput);
20
-
21
- if (!existsSync(input)) {
22
- console.error(`generate-core: cannot read ${input}`);
23
- process.exit(1);
24
- }
25
-
26
- const gen = generateClient(readFileSync(input, "utf8"));
27
- gen.warnings.forEach((w) => console.error(`warning: ${w}`));
28
-
29
- // the folder is entirely generated: drop stale files so a removed output cannot linger
30
- rmSync(outDir, { recursive: true, force: true });
31
- mkdirSync(outDir, { recursive: true });
32
- writeFiles(outDir, gen.files);
33
- console.log(`generated ${gen.operations.length} operations in ${outDir}`);
@@ -1,43 +0,0 @@
1
- import { expect, test } from "bun:test";
2
- import { execFileSync } from "node:child_process";
3
- import { cpSync, existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
4
- import { tmpdir } from "node:os";
5
- import { dirname, join, resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- import { panoClientGen } from "../../plugin-kit/src/rollup/client-gen.js";
8
-
9
- const here = dirname(fileURLToPath(import.meta.url));
10
- const script = join(here, "generate-core.js");
11
- const mini = resolve(here, "../../client-gen/src/golden/mini");
12
-
13
- test("generate-core.js is deterministic: a run over the committed snapshot changes no file", () => {
14
- const core = join(here, "../src/core");
15
- const read = () => Object.fromEntries(readdirSync(core).sort().map((f) => [f, readFileSync(join(core, f), "utf8")]));
16
- const before = read();
17
- expect(Object.keys(before)).toEqual(["index.js", "openapi.json", "operations.js", "types.js"]);
18
- execFileSync("node", [script, join(core, "openapi.json")]);
19
- expect(read()).toEqual(before);
20
- expect(before["types.js"].trimEnd().endsWith("export {};")).toBe(true);
21
- });
22
-
23
- test("the panoClientGen hook writes client/ from api/openapi.json and keeps an existing package.json", async () => {
24
- const root = mkdtempSync(join(tmpdir(), "client-hook-"));
25
- try {
26
- // no snapshot: nothing written
27
- await panoClientGen({ pluginId: "pano-plugin-demo", namespace: "demo", root }).buildStart.call({ warn() {} });
28
- expect(existsSync(join(root, "client"))).toBe(false);
29
-
30
- mkdirSync(join(root, "api"));
31
- cpSync(join(mini, "openapi.json"), join(root, "api/openapi.json"));
32
- await panoClientGen({ pluginId: "pano-plugin-demo", namespace: "demo", root }).buildStart.call({ warn() {} });
33
- expect(readFileSync(join(root, "client/index.js"), "utf8")).toBe(readFileSync(join(mini, "index.js"), "utf8"));
34
- const pkg = JSON.parse(readFileSync(join(root, "client/package.json"), "utf8"));
35
- expect(pkg.name).toBe("pano-client-demo");
36
-
37
- writeFileSync(join(root, "client/package.json"), '{"name":"@panomc/client-demo"}\n');
38
- await panoClientGen({ pluginId: "pano-plugin-demo", namespace: "demo", root }).buildStart.call({ warn() {} });
39
- expect(readFileSync(join(root, "client/package.json"), "utf8")).toBe('{"name":"@panomc/client-demo"}\n');
40
- } finally {
41
- rmSync(root, { recursive: true, force: true });
42
- }
43
- });