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 +66 -10
- package/blueprint-types.generated.d.ts +659 -0
- package/blueprint-types.generated.js +57 -0
- package/codegen/generate-seed.d.ts +10 -1
- package/codegen/generate-seed.js +103 -6
- package/codegen/generate-types.d.ts +19 -0
- package/codegen/generate-types.js +373 -0
- package/esm/blueprint-types.generated.d.ts +659 -0
- package/esm/blueprint-types.generated.js +56 -0
- package/esm/codegen/generate-seed.d.ts +10 -1
- package/esm/codegen/generate-seed.js +103 -6
- package/esm/codegen/generate-types.d.ts +19 -0
- package/esm/codegen/generate-types.js +338 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +9 -6
- package/esm/preset.d.ts +0 -23
- package/esm/preset.js +0 -5
- package/preset.d.ts +0 -23
- package/preset.js +0 -8
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*,
|
|
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); //
|
|
14
|
+
console.log(allNodeTypes.length); // 52
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
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 {
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
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
|
|