@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/README.md +75 -1
- package/dist/authoring.cjs +9 -0
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +6 -0
- package/dist/authoring.d.ts +6 -0
- package/dist/authoring.js +9 -0
- package/dist/authoring.js.map +1 -1
- package/dist/cli.cjs +89 -29
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +89 -29
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -1
- package/dist/client.d.ts +4 -1
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +68 -29
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.js +68 -29
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +82 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +81 -5
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +19 -3
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +13 -6
- package/dist/ir.d.ts +13 -6
- package/dist/ir.js +18 -4
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +24 -2
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +4 -0
- package/dist/predicate-v2.d.ts +4 -0
- package/dist/predicate-v2.js +24 -2
- package/dist/predicate-v2.js.map +1 -1
- package/dist/sdl.cjs +16 -2
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.js +16 -2
- package/dist/sdl.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen-gql/preset.cjs +45 -8
- package/templates/orm-namespace/codegen.ts +5 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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]:
|
|
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,
|
|
78
|
+
plugins: outputPlugins({ plugin: CLIENT_PLUGIN, pluginConfig: {}, types }),
|
|
43
79
|
pluginMap,
|
|
44
80
|
schema: options.schema,
|
|
45
|
-
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,
|
|
87
|
+
plugins: outputPlugins({ plugin: SERVER_PLUGIN, pluginConfig: { typesImportPath: false }, types }),
|
|
52
88
|
pluginMap,
|
|
53
89
|
schema: options.schema,
|
|
54
|
-
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',
|