node-type-registry 0.3.1 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # node-type-registry
2
2
 
3
- Node type definitions for the Constructive blueprint system. Single source of truth for all Authz*, Data*, Field*, Relation*, View*, and Table* node types.
3
+ Node type definitions for the Constructive blueprint system. Single source of truth for all Authz*, Data*, Relation*, View*, and Table* node types.
4
4
 
5
5
  ## Usage
6
6
 
@@ -11,22 +11,78 @@ import { allNodeTypes, AuthzDirectOwner, DataId } from 'node-type-registry';
11
11
  console.log(AuthzDirectOwner.parameter_schema);
12
12
 
13
13
  // Get all node types as a flat array
14
- console.log(allNodeTypes.length); // 50
14
+ console.log(allNodeTypes.length); // 52
15
15
  ```
16
16
 
17
- ## Preset (opt-in blueprint types)
17
+ ## Blueprint Types (generated)
18
+
19
+ The package exports TypeScript types that match the JSONB shape expected by `construct_blueprint()`. These provide client-side autocomplete and type safety when building blueprint definitions — the GraphQL API itself accepts plain JSONB.
18
20
 
19
21
  ```typescript
20
- import { NodeTypeRegistryPreset } from 'node-type-registry/preset';
22
+ import type {
23
+ BlueprintDefinition,
24
+ BlueprintTable,
25
+ BlueprintNode,
26
+ BlueprintRelation,
27
+ BlueprintField,
28
+ BlueprintIndex,
29
+ } from 'node-type-registry';
30
+
31
+ const definition: BlueprintDefinition = {
32
+ tables: [
33
+ {
34
+ ref: 'tasks',
35
+ table_name: 'tasks',
36
+ nodes: [
37
+ 'DataId',
38
+ 'DataTimestamps',
39
+ { $type: 'DataDirectOwner', data: { include_id: false } },
40
+ ],
41
+ fields: [
42
+ { name: 'title', type: 'text', is_not_null: true },
43
+ { name: 'description', type: 'text' },
44
+ ],
45
+ policies: [{ $type: 'AuthzDirectOwner' }],
46
+ },
47
+ ],
48
+ relations: [
49
+ {
50
+ $type: 'RelationBelongsTo',
51
+ source_ref: 'tasks',
52
+ target_ref: 'projects',
53
+ delete_action: 'c',
54
+ },
55
+ ],
56
+ };
57
+ ```
58
+
59
+ ### Regenerating types
21
60
 
22
- const sdl = await buildSchemaSDL({
23
- database: dbConfig.database,
24
- schemas,
25
- graphile: { extends: [NodeTypeRegistryPreset] },
26
- });
61
+ When node type definitions are added or modified, regenerate with:
62
+
63
+ ```bash
64
+ cd graphile/node-type-registry && pnpm generate:types
27
65
  ```
28
66
 
29
- This preset generates `@oneOf` typed GraphQL input types (`BlueprintDefinitionInput`, etc.) from the TS node type definitions. It is **not** included in `ConstructivePreset` — it must be explicitly added by consumers that need blueprint types.
67
+ This produces `src/blueprint-types.generated.ts` from the TS node type source of truth.
68
+
69
+ ## Codegen: SQL seed
70
+
71
+ Generate SQL seed scripts for `node_type_registry` table:
72
+
73
+ ```bash
74
+ cd graphile/node-type-registry && pnpm generate:seed --pgpm ../../constructive-db/packages/metaschema
75
+ ```
76
+
77
+ ## Preset (deprecated)
78
+
79
+ > **Note:** The `NodeTypeRegistryPreset` is no longer the recommended approach.
80
+ > Use the generated TypeScript types instead (see above). The preset remains
81
+ > available for backward compatibility but will be removed in a future version.
82
+
83
+ ```typescript
84
+ import { NodeTypeRegistryPreset } from 'node-type-registry/preset';
85
+ ```
30
86
 
31
87
  ---
32
88