@snowtop/ent 0.2.10 → 0.2.11

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": "@snowtop/ent",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "snowtop ent framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -8,22 +8,22 @@
8
8
  "example": "examples"
9
9
  },
10
10
  "dependencies": {
11
- "@types/node": "^25.0.3",
12
- "dataloader": "^2.2.3",
13
- "glob": "^13.0.0",
14
- "js-yaml": "^4.1.1",
15
- "luxon": "^3.7.2",
16
- "pg": "^8.16.3",
17
- "ts-node": "^11.0.0-beta.1",
18
- "tsconfig-paths": "^4.2.0",
19
- "tslib": "^2.8.1",
20
- "typescript": "^5.9.3",
21
- "uuid": "^9.0.1"
11
+ "@types/node": "25.0.3",
12
+ "dataloader": "2.2.3",
13
+ "glob": "13.0.0",
14
+ "js-yaml": "4.1.1",
15
+ "luxon": "3.7.2",
16
+ "pg": "8.16.3",
17
+ "ts-node": "11.0.0-beta.1",
18
+ "tsconfig-paths": "4.2.0",
19
+ "tslib": "2.8.1",
20
+ "typescript": "5.9.3",
21
+ "uuid": "9.0.1"
22
22
  },
23
23
  "peerDependencies": {
24
- "@swc-node/register": "^1.6.8",
25
- "better-sqlite3": "^12.5.0",
26
- "graphql": "^16.8.1"
24
+ "@swc-node/register": "1.6.8",
25
+ "better-sqlite3": "12.5.0",
26
+ "graphql": "16.12.0"
27
27
  },
28
28
  "peerDependenciesMeta": {
29
29
  "better-sqlite3": {
@@ -48,6 +48,7 @@ const imports_1 = require("../imports");
48
48
  const process_1 = require("process");
49
49
  const child_process_1 = require("child_process");
50
50
  const const_1 = require("../core/const");
51
+ const stdout_1 = require("./stdout");
51
52
  const { parseArgs } = require("./parse_args");
52
53
  // need to use the GQLCapture from the package so that when we call GQLCapture.enable()
53
54
  // we're affecting the local paths as opposed to a different instance
@@ -243,23 +244,7 @@ async function processJSON(gqlCapture, json) {
243
244
  processCustomTypes(json.customTypes, gqlCapture);
244
245
  }
245
246
  }
246
- async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
247
- if (jsonPath !== undefined) {
248
- const json = parseJSONC(jsonPath, fs.readFileSync(jsonPath, {
249
- encoding: "utf8",
250
- }));
251
- processJSON(gqlCapture, json);
252
- return;
253
- }
254
- if (filesCsv !== undefined) {
255
- let files = filesCsv.split(",");
256
- for (let i = 0; i < files.length; i++) {
257
- // TODO fix. we have "src" in the path we get here
258
- files[i] = path.join(filePath, "..", files[i]);
259
- }
260
- await requireFiles(files);
261
- return;
262
- }
247
+ async function loadGraphQLDecoratorFiles(filePath) {
263
248
  // TODO delete all of this eventually
264
249
  // TODO configurable paths eventually
265
250
  // for now only files that are in the include path of the roots are allowed
@@ -286,6 +271,26 @@ async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
286
271
  .filter(fileImportsGraphQLDecorators);
287
272
  await requireFiles(files);
288
273
  }
274
+ async function captureCustom(filePath, filesCsv, jsonPath, gqlCapture) {
275
+ if (jsonPath !== undefined) {
276
+ const json = parseJSONC(jsonPath, fs.readFileSync(jsonPath, {
277
+ encoding: "utf8",
278
+ }));
279
+ await processJSON(gqlCapture, json);
280
+ await loadGraphQLDecoratorFiles(filePath);
281
+ return;
282
+ }
283
+ if (filesCsv !== undefined) {
284
+ let files = filesCsv.split(",");
285
+ for (let i = 0; i < files.length; i++) {
286
+ // TODO fix. we have "src" in the path we get here
287
+ files[i] = path.join(filePath, "..", files[i]);
288
+ }
289
+ await requireFiles(files);
290
+ return;
291
+ }
292
+ await loadGraphQLDecoratorFiles(filePath);
293
+ }
289
294
  function fileImportsGraphQLDecorators(file) {
290
295
  const contents = fs.readFileSync(file, {
291
296
  encoding: "utf8",
@@ -479,7 +484,7 @@ async function main() {
479
484
  for (const k in fields) {
480
485
  buildClasses(fields[k]);
481
486
  }
482
- console.log(JSON.stringify({
487
+ await (0, stdout_1.writeJSONToStdout)({
483
488
  args,
484
489
  inputs,
485
490
  fields,
@@ -491,7 +496,7 @@ async function main() {
491
496
  unions,
492
497
  files: allFiles,
493
498
  customTypes,
494
- }));
499
+ });
495
500
  }
496
501
  main()
497
502
  .then()
@@ -39,7 +39,8 @@ const { parseArgs } = require("./parse_args");
39
39
  const parse_1 = require("../parse_schema/parse");
40
40
  const ast_1 = require("../tsc/ast");
41
41
  const names_1 = require("../names/names");
42
- function main() {
42
+ const stdout_1 = require("./stdout");
43
+ async function main() {
43
44
  const options = parseArgs(process.argv.slice(2));
44
45
  if (!options.path) {
45
46
  throw new Error("path required");
@@ -80,16 +81,10 @@ function main() {
80
81
  potentialSchemas[(0, names_1.toClassName)(schema)] = s;
81
82
  }
82
83
  // console.log(potentialSchemas);
83
- // NB: do not change this to async/await
84
- // doing so runs it buffer limit on linux (65536 bytes) and we lose data reading in go
85
- (0, parse_1.parseSchema)(potentialSchemas, globalSchema).then((result) => {
86
- console.log(JSON.stringify(result));
87
- });
88
- }
89
- try {
90
- main();
84
+ const result = await (0, parse_1.parseSchema)(potentialSchemas, globalSchema);
85
+ await (0, stdout_1.writeJSONToStdout)(result);
91
86
  }
92
- catch (err) {
87
+ main().catch((err) => {
93
88
  console.error(err);
94
89
  process.exit(1);
95
- }
90
+ });
@@ -0,0 +1 @@
1
+ export declare function writeJSONToStdout(value: unknown): Promise<void>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeJSONToStdout = writeJSONToStdout;
4
+ async function writeJSONToStdout(value) {
5
+ await writeToStdout(JSON.stringify(value));
6
+ }
7
+ async function writeToStdout(payload) {
8
+ // Bun can exit before a large piped stdout write is fully consumed.
9
+ await new Promise((resolve, reject) => {
10
+ process.stdout.write(payload, (err) => {
11
+ if (err) {
12
+ reject(err);
13
+ return;
14
+ }
15
+ resolve();
16
+ });
17
+ });
18
+ }