@quadrokit/client 0.2.6 → 0.2.7

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 +1 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/generate/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAgTxF,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxF"}
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/generate/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsC,WAAW,EAAE,MAAM,mBAAmB,CAAA;AA8TxF,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBxF"}
@@ -104,8 +104,12 @@ function emitInterface(dc, _byName) {
104
104
  lines.push('}');
105
105
  return lines.join('\n');
106
106
  }
107
+ /** Include dataclasses unless explicitly not exposed (`exposed === false`). Omitted `exposed` is treated as true. */
108
+ function exposedDataClasses(catalog) {
109
+ return catalog.dataClasses?.filter((d) => d.exposed !== false) ?? [];
110
+ }
107
111
  function emitTypes(catalog) {
108
- const classes = catalog.dataClasses?.filter((d) => d.exposed) ?? [];
112
+ const classes = exposedDataClasses(catalog);
109
113
  const byName = new Map(classes.map((c) => [c.name, c]));
110
114
  const interfaces = classes.map((c) => emitInterface(c, byName));
111
115
  const pathTypes = classes.map((c) => {
@@ -114,10 +118,18 @@ function emitTypes(catalog) {
114
118
  const body = paths.length ? paths.map((p) => `'${p}'`).join('\n | ') : 'never';
115
119
  return `export type ${name} =\n | ${body};`;
116
120
  });
117
- return `/* eslint-disable */\n/* Auto-generated by @quadrokit/client — do not edit */\n\n${interfaces.join('\n\n')}\n\n${pathTypes.join('\n\n')}\n`;
121
+ const header = `/* eslint-disable */\n/* Auto-generated by @quadrokit/client — do not edit */\n`;
122
+ if (classes.length === 0) {
123
+ const raw = catalog.dataClasses?.length ?? 0;
124
+ const note = raw > 0
125
+ ? `\n/**\n * No entity types: all ${raw} data class(es) in the catalog have exposed: false.\n * Enable REST exposure for tables in 4D, then run quadrokit-client generate again.\n */\n`
126
+ : `\n/**\n * No entity types: the catalog has no dataClasses (or an empty list).\n */\n`;
127
+ return `${header}${note}\n`;
128
+ }
129
+ return `${header}\n${interfaces.join('\n\n')}\n\n${pathTypes.join('\n\n')}\n`;
118
130
  }
119
131
  function emitClient(catalog) {
120
- const classes = catalog.dataClasses?.filter((d) => d.exposed) ?? [];
132
+ const classes = exposedDataClasses(catalog);
121
133
  const dbName = catalog.__NAME ?? 'default';
122
134
  const hasAuthentify = catalog.methods?.some((m) => m.name === 'authentify' && m.applyTo === 'dataStore');
123
135
  const keyNamesRecord = Object.fromEntries(classes.map((x) => [x.name, keyNames(x)]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quadrokit/client",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Typed 4D REST client and catalog code generator for QuadroKit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "generate:fixture": "bun run src/cli.ts generate --url file://../../assets/catalog.json --out ../../.quadrokit/generated-demo"
30
30
  },
31
31
  "dependencies": {
32
- "@quadrokit/shared": "^0.2.6",
32
+ "@quadrokit/shared": "^0.2.7",
33
33
  "undici": "^6.21.0"
34
34
  },
35
35
  "peerDependencies": {