@sequenceholdings/orm 2.6.2 → 2.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequenceholdings/orm",
3
- "version": "2.6.2",
3
+ "version": "2.7.1",
4
4
  "description": "Sequence ORM v2 — TypeScript-defined governed tables and persisted GraphQL operations",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,12 +9,46 @@ const serverFnsPlugin = require('./server-fns.cjs');
9
9
  const CLIENT_PLUGIN = '@sequenceholdings/orm/codegen/apollo-hooks';
10
10
  const SERVER_PLUGIN = '@sequenceholdings/orm/codegen/server-fns';
11
11
 
12
- function outputPlugins({ plugin, config }) {
12
+ /**
13
+ * graphql-codegen maps an unmapped custom scalar to `any`. Native repository
14
+ * lint rejects that (`@typescript-eslint/no-explicit-any`) in generated/client.ts
15
+ * and generated/server.ts. These six scalars are the ORM SDL's custom set;
16
+ * `defaultScalarType` covers any later scalar the same way. A consumer
17
+ * `config.scalars` entry replaces one scalar (lossless numeric/bigint use
18
+ * `string`) and cannot turn the fallback back into `any`.
19
+ */
20
+ const CUSTOM_SCALAR_TYPES = {
21
+ bigint: 'unknown',
22
+ date: 'unknown',
23
+ jsonb: 'unknown',
24
+ numeric: 'unknown',
25
+ timestamptz: 'unknown',
26
+ uuid: 'unknown',
27
+ };
28
+
29
+ function plainObject(value) {
30
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
31
+ }
32
+
33
+ function lintCleanScalarConfig(config) {
34
+ const consumerScalars = plainObject(config?.scalars) ? config.scalars : {};
35
+ return {
36
+ defaultScalarType: 'unknown',
37
+ scalars: { ...CUSTOM_SCALAR_TYPES, ...consumerScalars },
38
+ };
39
+ }
40
+
41
+ function sectionConfig(config) {
42
+ const base = plainObject(config) ? config : {};
43
+ return { ...base, ...lintCleanScalarConfig(base) };
44
+ }
45
+
46
+ function outputPlugins({ plugin, pluginConfig, types }) {
13
47
  return [
14
- { typescript: {} },
15
- { 'typescript-operations': {} },
48
+ { typescript: types },
49
+ { 'typescript-operations': types },
16
50
  { 'typed-document-node': {} },
17
- { [plugin]: config },
51
+ { [plugin]: pluginConfig },
18
52
  ];
19
53
  }
20
54
 
@@ -35,23 +69,25 @@ function createPreset({ loadPlugin } = {}) {
35
69
  [CLIENT_PLUGIN]: apolloHooksPlugin,
36
70
  [SERVER_PLUGIN]: serverFnsPlugin,
37
71
  };
72
+ const config = sectionConfig(options.config);
73
+ const types = lintCleanScalarConfig(options.config);
38
74
 
39
75
  return [
40
76
  {
41
77
  filename: `${options.baseOutputDir}client.ts`,
42
- plugins: outputPlugins({ plugin: CLIENT_PLUGIN, config: {} }),
78
+ plugins: outputPlugins({ plugin: CLIENT_PLUGIN, pluginConfig: {}, types }),
43
79
  pluginMap,
44
80
  schema: options.schema,
45
- config: options.config,
81
+ config,
46
82
  documents: options.documents,
47
83
  documentTransforms: options.documentTransforms,
48
84
  },
49
85
  {
50
86
  filename: `${options.baseOutputDir}server.ts`,
51
- plugins: outputPlugins({ plugin: SERVER_PLUGIN, config: { typesImportPath: false } }),
87
+ plugins: outputPlugins({ plugin: SERVER_PLUGIN, pluginConfig: { typesImportPath: false }, types }),
52
88
  pluginMap,
53
89
  schema: options.schema,
54
- config: options.config,
90
+ config,
55
91
  documents: options.documents,
56
92
  documentTransforms: options.documentTransforms,
57
93
  },
@@ -62,3 +98,4 @@ function createPreset({ loadPlugin } = {}) {
62
98
 
63
99
  module.exports = createPreset();
64
100
  module.exports.createPreset = createPreset;
101
+ module.exports.lintCleanScalarConfig = lintCleanScalarConfig;
@@ -9,6 +9,11 @@ import preset from './codegen.preset.cjs'
9
9
  *
10
10
  * schema.graphql and the generated output are committed: reviews see the API
11
11
  * surface change alongside the schema change that caused it.
12
+ *
13
+ * The preset types custom scalars as `unknown` (native lint rejects `any`).
14
+ * Override one scalar via `config.scalars` on the `./generated/` output — for
15
+ * lossless numeric/bigint transport, set those two to `string` — then
16
+ * regenerate with `seq-studio orm generate`.
12
17
  */
13
18
  const config: CodegenConfig = {
14
19
  schema: './schema.graphql',