@sequenceholdings/orm 0.1.3 → 2.1.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.
Files changed (59) hide show
  1. package/README.md +108 -38
  2. package/dist/authoring.cjs +128 -16
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +21 -4
  5. package/dist/authoring.d.ts +21 -4
  6. package/dist/authoring.js +128 -16
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +83 -9
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +47 -1
  11. package/dist/canonical.d.ts +47 -1
  12. package/dist/canonical.js +83 -10
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +816 -134
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +818 -136
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.js.map +1 -1
  20. package/dist/compiler.cjs +488 -96
  21. package/dist/compiler.cjs.map +1 -1
  22. package/dist/compiler.d.cts +34 -2
  23. package/dist/compiler.d.ts +34 -2
  24. package/dist/compiler.js +489 -97
  25. package/dist/compiler.js.map +1 -1
  26. package/dist/index.cjs +420 -71
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +266 -9
  29. package/dist/index.d.ts +266 -9
  30. package/dist/index.js +410 -73
  31. package/dist/index.js.map +1 -1
  32. package/dist/ir.cjs +146 -12
  33. package/dist/ir.cjs.map +1 -1
  34. package/dist/ir.d.cts +161 -5
  35. package/dist/ir.d.ts +161 -5
  36. package/dist/ir.js +144 -13
  37. package/dist/ir.js.map +1 -1
  38. package/dist/{naming-CTvWSRTf.d.ts → naming-DCn94LJ4.d.ts} +15 -1
  39. package/dist/{naming-DRyinU4u.d.cts → naming-DPglwzkB.d.cts} +15 -1
  40. package/dist/predicate-v2.cjs +136 -11
  41. package/dist/predicate-v2.cjs.map +1 -1
  42. package/dist/predicate-v2.d.cts +3 -0
  43. package/dist/predicate-v2.d.ts +3 -0
  44. package/dist/predicate-v2.js +136 -11
  45. package/dist/predicate-v2.js.map +1 -1
  46. package/dist/sdl.cjs +460 -13
  47. package/dist/sdl.cjs.map +1 -1
  48. package/dist/sdl.d.cts +1 -1
  49. package/dist/sdl.d.ts +1 -1
  50. package/dist/sdl.js +459 -14
  51. package/dist/sdl.js.map +1 -1
  52. package/package.json +6 -4
  53. package/src/codegen-gql/preset.cjs +64 -0
  54. package/src/codegen-gql/server-fns.cjs +11 -6
  55. package/templates/orm-namespace/codegen.preset.cjs +17 -0
  56. package/templates/orm-namespace/codegen.ts +1 -1
  57. package/templates/orm-namespace/package.json +3 -0
  58. package/templates/orm-namespace/schema/tables.ts +1 -1
  59. 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.1.3",
4
- "description": "Sequence ORM — YAML-defined OpCo tables compiled to Postgres + RLS, with a typed Data API client",
3
+ "version": "2.1.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.1.1",
92
+ "js-yaml": "^4.3.2",
91
93
  "zod": "^4.1.13",
92
94
  "@sequenceholdings/custom-roles-manifest": "0.1.0"
93
95
  },
@@ -96,7 +98,7 @@
96
98
  "@types/node": "^22.0.0",
97
99
  "tsup": "^8.3.0",
98
100
  "typescript": "^5.3.3",
99
- "vitest": "^4.1.5"
101
+ "vitest": "^4.1.11"
100
102
  },
101
103
  "engines": {
102
104
  "node": ">=20"
@@ -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 = (config && config.typesImportPath) || './types.gen';
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
- `import { executeOperation } from '@sequenceholdings/orm/client';`,
95
- `import { ${Array.from(imports).join(', ')} } from '${typesImportPath}';`,
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();
@@ -14,7 +14,7 @@ const config: CodegenConfig = {
14
14
  documents: ['graphql/**/*.ts'],
15
15
  generates: {
16
16
  './generated/': {
17
- preset: '@sequenceholdings/orm/codegen',
17
+ preset: './codegen.preset.cjs',
18
18
  },
19
19
  },
20
20
  }
@@ -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
@@ -1,4 +1,4 @@
1
- import { defineNamespace } from '@sequenceholdings/orm'
1
+ import { defineNamespace } from '@sequenceholdings/orm/authoring'
2
2
 
3
3
  /**
4
4
  * The namespace config — exactly one per directory.