@sequenceholdings/orm 0.1.3 → 2.0.0
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 +53 -38
- package/dist/authoring.cjs +6 -1
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +2 -2
- package/dist/authoring.d.ts +2 -2
- package/dist/authoring.js +6 -1
- package/dist/authoring.js.map +1 -1
- package/dist/cli.cjs +96 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +96 -3
- package/dist/cli.js.map +1 -1
- package/dist/compiler.cjs +6 -0
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.js +6 -0
- package/dist/compiler.js.map +1 -1
- package/dist/index.cjs +6 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/predicate-v2.cjs +6 -0
- package/dist/predicate-v2.cjs.map +1 -1
- package/dist/predicate-v2.d.cts +3 -0
- package/dist/predicate-v2.d.ts +3 -0
- package/dist/predicate-v2.js +6 -0
- package/dist/predicate-v2.js.map +1 -1
- package/package.json +5 -3
- package/src/codegen-gql/preset.cjs +64 -0
- package/src/codegen-gql/server-fns.cjs +11 -6
- package/templates/orm-namespace/codegen.preset.cjs +17 -0
- package/templates/orm-namespace/codegen.ts +1 -1
- package/templates/orm-namespace/package.json +3 -0
- package/templates/orm-namespace/schema/tables.ts +1 -1
- package/templates/orm-namespace/sequence.config.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/orm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Sequence ORM —
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Sequence ORM v2 — TypeScript-defined governed tables and persisted GraphQL operations",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -72,12 +72,14 @@
|
|
|
72
72
|
"import": "./dist/drizzle.js",
|
|
73
73
|
"require": "./dist/drizzle.cjs"
|
|
74
74
|
},
|
|
75
|
+
"./codegen": "./src/codegen-gql/preset.cjs",
|
|
75
76
|
"./codegen/apollo-hooks": "./src/codegen-gql/apollo-hooks.cjs",
|
|
76
77
|
"./codegen/server-fns": "./src/codegen-gql/server-fns.cjs"
|
|
77
78
|
},
|
|
78
79
|
"files": [
|
|
79
80
|
"dist",
|
|
80
81
|
"src/codegen-gql/apollo-hooks.cjs",
|
|
82
|
+
"src/codegen-gql/preset.cjs",
|
|
81
83
|
"src/codegen-gql/server-fns.cjs",
|
|
82
84
|
"templates",
|
|
83
85
|
"README.md"
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"jiti": "^2.4.2",
|
|
88
90
|
"drizzle-kit": "^0.31.9",
|
|
89
91
|
"drizzle-orm": "^0.45.2",
|
|
90
|
-
"js-yaml": "^4.
|
|
92
|
+
"js-yaml": "^4.3.1",
|
|
91
93
|
"zod": "^4.1.13",
|
|
92
94
|
"@sequenceholdings/custom-roles-manifest": "0.1.0"
|
|
93
95
|
},
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createRequire } = require('node:module');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
const apolloHooksPlugin = require('./apollo-hooks.cjs');
|
|
7
|
+
const serverFnsPlugin = require('./server-fns.cjs');
|
|
8
|
+
|
|
9
|
+
const CLIENT_PLUGIN = '@sequenceholdings/orm/codegen/apollo-hooks';
|
|
10
|
+
const SERVER_PLUGIN = '@sequenceholdings/orm/codegen/server-fns';
|
|
11
|
+
|
|
12
|
+
function outputPlugins({ plugin, config }) {
|
|
13
|
+
return [
|
|
14
|
+
{ typescript: {} },
|
|
15
|
+
{ 'typescript-operations': {} },
|
|
16
|
+
{ 'typed-document-node': {} },
|
|
17
|
+
{ [plugin]: config },
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function consumerRequireFrom(options) {
|
|
22
|
+
const cwd = options?.config?.cwd ?? process.cwd();
|
|
23
|
+
return createRequire(path.join(cwd, 'package.json'));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function createPreset({ loadPlugin } = {}) {
|
|
27
|
+
return {
|
|
28
|
+
buildGeneratesSection: async (options) => {
|
|
29
|
+
const resolvePlugin = loadPlugin ?? ((name) => consumerRequireFrom(options)(name));
|
|
30
|
+
const pluginMap = {
|
|
31
|
+
...options.pluginMap,
|
|
32
|
+
typescript: resolvePlugin('@graphql-codegen/typescript'),
|
|
33
|
+
'typescript-operations': resolvePlugin('@graphql-codegen/typescript-operations'),
|
|
34
|
+
'typed-document-node': resolvePlugin('@graphql-codegen/typed-document-node'),
|
|
35
|
+
[CLIENT_PLUGIN]: apolloHooksPlugin,
|
|
36
|
+
[SERVER_PLUGIN]: serverFnsPlugin,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
filename: `${options.baseOutputDir}client.ts`,
|
|
42
|
+
plugins: outputPlugins({ plugin: CLIENT_PLUGIN, config: {} }),
|
|
43
|
+
pluginMap,
|
|
44
|
+
schema: options.schema,
|
|
45
|
+
config: options.config,
|
|
46
|
+
documents: options.documents,
|
|
47
|
+
documentTransforms: options.documentTransforms,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
filename: `${options.baseOutputDir}server.ts`,
|
|
51
|
+
plugins: outputPlugins({ plugin: SERVER_PLUGIN, config: { typesImportPath: false } }),
|
|
52
|
+
pluginMap,
|
|
53
|
+
schema: options.schema,
|
|
54
|
+
config: options.config,
|
|
55
|
+
documents: options.documents,
|
|
56
|
+
documentTransforms: options.documentTransforms,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = createPreset();
|
|
64
|
+
module.exports.createPreset = createPreset;
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* config:
|
|
17
17
|
* typesImportPath — module the `<Name><Kind>Variables` types are imported
|
|
18
18
|
* from (default './types.gen'). Point it at the file the `typescript` +
|
|
19
|
-
* `typescript-operations` plugins write.
|
|
19
|
+
* `typescript-operations` plugins write. Set false when those plugins run
|
|
20
|
+
* in the same output file.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
function getResultFieldName(operation) {
|
|
@@ -60,7 +61,9 @@ function capitalize(str) {
|
|
|
60
61
|
|
|
61
62
|
module.exports = {
|
|
62
63
|
plugin: (_schema, documents, config) => {
|
|
63
|
-
const typesImportPath =
|
|
64
|
+
const typesImportPath = config?.typesImportPath === false
|
|
65
|
+
? false
|
|
66
|
+
: (config?.typesImportPath || './types.gen');
|
|
64
67
|
const imports = new Set();
|
|
65
68
|
const functions = documents
|
|
66
69
|
.flatMap(({ document }) => {
|
|
@@ -90,10 +93,12 @@ module.exports = {
|
|
|
90
93
|
.filter(Boolean);
|
|
91
94
|
|
|
92
95
|
if (functions.length) {
|
|
93
|
-
const importStatements = [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
const importStatements = [`import { executeOperation } from '@sequenceholdings/orm/client';`];
|
|
97
|
+
if (typesImportPath) {
|
|
98
|
+
importStatements.push(
|
|
99
|
+
`import { ${Array.from(imports).join(', ')} } from '${typesImportPath}';`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
97
102
|
return [...importStatements, ...functions].join('\n\n');
|
|
98
103
|
}
|
|
99
104
|
return '';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createRequire } = require('node:module');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Consumer-local graphql-codegen preset shim. The ORM package ships the preset
|
|
8
|
+
* implementation, but graphql-codegen plugins must resolve from the scaffold's
|
|
9
|
+
* devDependencies (pnpm's strict layout does not hoist them into the ORM pkg).
|
|
10
|
+
*/
|
|
11
|
+
const consumerRequire = createRequire(path.join(__dirname, 'package.json'));
|
|
12
|
+
const ormCodegenDir = path.dirname(
|
|
13
|
+
consumerRequire.resolve('@sequenceholdings/orm/codegen/apollo-hooks'),
|
|
14
|
+
);
|
|
15
|
+
const { createPreset } = require(path.join(ormCodegenDir, 'preset.cjs'));
|
|
16
|
+
|
|
17
|
+
module.exports = createPreset();
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@graphql-codegen/cli": "^5.0.7",
|
|
19
|
+
"@graphql-codegen/typed-document-node": "^5.1.1",
|
|
20
|
+
"@graphql-codegen/typescript": "^4.1.6",
|
|
21
|
+
"@graphql-codegen/typescript-operations": "^4.6.1",
|
|
19
22
|
"typescript": "^5.6.0"
|
|
20
23
|
},
|
|
21
24
|
"engines": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineEnum, defineTable, t, toMany, toOne, toPlatformUser } from '@sequenceholdings/orm'
|
|
1
|
+
import { defineEnum, defineTable, t, toMany, toOne, toPlatformUser } from '@sequenceholdings/orm/authoring'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Tables are TypeScript, but they SERIALIZE to data — the server never runs
|