@sequenceholdings/orm 0.1.2 → 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 +49 -24
- package/dist/authoring.cjs +1072 -60
- package/dist/authoring.cjs.map +1 -1
- package/dist/authoring.d.cts +291 -26
- package/dist/authoring.d.ts +291 -26
- package/dist/authoring.js +1062 -61
- package/dist/authoring.js.map +1 -1
- package/dist/canonical.cjs +415 -9
- package/dist/canonical.cjs.map +1 -1
- package/dist/canonical.d.cts +235 -1
- package/dist/canonical.d.ts +235 -1
- package/dist/canonical.js +411 -10
- package/dist/canonical.js.map +1 -1
- package/dist/cli.cjs +1860 -228
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1861 -229
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js.map +1 -1
- package/dist/compiler.cjs +512 -54
- package/dist/compiler.cjs.map +1 -1
- package/dist/compiler.d.cts +39 -231
- package/dist/compiler.d.ts +39 -231
- package/dist/compiler.js +510 -55
- package/dist/compiler.js.map +1 -1
- package/dist/drizzle.cjs +14 -0
- package/dist/drizzle.cjs.map +1 -0
- package/dist/drizzle.d.cts +1 -0
- package/dist/drizzle.d.ts +1 -0
- package/dist/drizzle.js +3 -0
- package/dist/drizzle.js.map +1 -0
- package/dist/dynamic-input.cjs +391 -0
- package/dist/dynamic-input.cjs.map +1 -0
- package/dist/dynamic-input.d.cts +111 -0
- package/dist/dynamic-input.d.ts +111 -0
- package/dist/dynamic-input.js +380 -0
- package/dist/dynamic-input.js.map +1 -0
- package/dist/index.cjs +2229 -220
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -9
- package/dist/index.d.ts +125 -9
- package/dist/index.js +2205 -221
- package/dist/index.js.map +1 -1
- package/dist/ir.cjs +249 -14
- package/dist/ir.cjs.map +1 -1
- package/dist/ir.d.cts +20 -80
- package/dist/ir.d.ts +20 -80
- package/dist/ir.js +249 -14
- package/dist/ir.js.map +1 -1
- package/dist/predicate-v2.cjs +1099 -0
- package/dist/predicate-v2.cjs.map +1 -0
- package/dist/predicate-v2.d.cts +142 -0
- package/dist/predicate-v2.d.ts +142 -0
- package/dist/predicate-v2.js +1089 -0
- package/dist/predicate-v2.js.map +1 -0
- package/dist/sdl.cjs +344 -55
- package/dist/sdl.cjs.map +1 -1
- package/dist/sdl.d.cts +1 -3
- package/dist/sdl.d.ts +1 -3
- package/dist/sdl.js +344 -55
- package/dist/sdl.js.map +1 -1
- package/package.json +20 -3
- package/src/codegen-gql/preset.cjs +64 -0
- package/src/codegen-gql/server-fns.cjs +11 -6
- package/templates/orm-namespace/CLAUDE.md +6 -5
- 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
|
@@ -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 '';
|
|
@@ -29,11 +29,12 @@ applies it. Your app never talks to Postgres — it calls the data plane with
|
|
|
29
29
|
GraphQL document in `graphql/`, compiled at push time. For genuinely exotic
|
|
30
30
|
multi-statement writes, declare a table `action` — parameterized, gated,
|
|
31
31
|
audited.
|
|
32
|
-
- **Every table needs
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
- **Every table needs row policies.** At minimum declare `read` plus either a
|
|
33
|
+
legacy `write` policy or split `insert` / `update` policies when create and
|
|
34
|
+
resolve are different actors. Policies are the row security boundary and are
|
|
35
|
+
compiled into every operation touching the table. There is no "no policy"
|
|
36
|
+
fallback — an unrestricted table must say so explicitly (`allow: true`
|
|
37
|
+
variant or a `true` policy) so the decision is reviewable.
|
|
37
38
|
- **Exactly one `defineNamespace`** (in `sequence.config.ts`), and every
|
|
38
39
|
table module must call `defineTable` at import time — the CLI collects
|
|
39
40
|
registrations by importing your files.
|
|
@@ -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
|