@toolproof-npm/schema 0.1.12

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 ADDED
@@ -0,0 +1,58 @@
1
+ # @toolproof-npm/schema
2
+
3
+ JSON schemas and TypeScript types for ToolProof.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @toolproof-npm/schema
9
+ # or
10
+ npm install @toolproof-npm/schema
11
+ # or
12
+ yarn add @toolproof-npm/schema
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Import Schemas and Types
18
+
19
+ ```typescript
20
+ import { /* schemas and types */ } from '@toolproof-npm/schema';
21
+ ```
22
+
23
+ ## Features
24
+
25
+ - JSON Schema definitions with $defs subschemas
26
+ - Generated TypeScript types from JSON schemas
27
+ - Runtime schema validation support
28
+ - Extractors for non-JSON resource types
29
+ - Schema bundling utilities
30
+
31
+ ## Development
32
+
33
+ ### Generate Types
34
+
35
+ ```bash
36
+ pnpm run generateTypes
37
+ ```
38
+
39
+ ### Build
40
+
41
+ ```bash
42
+ pnpm run build
43
+ ```
44
+
45
+ ### Update (Clean build + generate types)
46
+
47
+ ```bash
48
+ pnpm run update
49
+ ```
50
+
51
+ ## Requirements
52
+
53
+ - Node.js 16+
54
+ - TypeScript 4.5+ (for TypeScript projects)
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ const Job = {
2
+ identity: 'identity',
3
+ name: 'name',
4
+ description: 'description',
5
+ uri: 'uri',
6
+ roles: {
7
+ inputMap: {
8
+ 'ROLE-1234': {
9
+ typeId: 'TYPE-1234',
10
+ name: 'name',
11
+ description: 'description'
12
+ }
13
+ },
14
+ outputMap: {
15
+ 'ROLE-5678': {
16
+ typeId: 'TYPE-5678',
17
+ name: 'name',
18
+ description: 'description'
19
+ }
20
+ }
21
+ }
22
+ };
23
+ const jobAlpha = {
24
+ identity: 'identity',
25
+ name: 'name',
26
+ description: 'description',
27
+ uri: 'uri',
28
+ roles: {
29
+ inputMap: {
30
+ 'data-input': {
31
+ typeId: 'typeId',
32
+ name: 'name',
33
+ description: 'description'
34
+ }
35
+ },
36
+ outputMap: {
37
+ 'data-output': {
38
+ typeId: 'typeId',
39
+ name: 'name',
40
+ description: 'description'
41
+ }
42
+ }
43
+ }
44
+ };
45
+ const jobBeta = {
46
+ identity: 'identity',
47
+ name: 'name',
48
+ description: 'description',
49
+ uri: 'uri',
50
+ roles: {
51
+ inputMap: {
52
+ 'data-input': {
53
+ typeId: 'typeId',
54
+ name: 'name',
55
+ description: 'description'
56
+ }
57
+ },
58
+ /* outputMap: {
59
+ 'data-output': {
60
+ typeId: 'typeId',
61
+ name: 'name',
62
+ description: 'description'
63
+ }
64
+ } */
65
+ }
66
+ };
67
+ // This checks (no error expected); we're providing all required fields
68
+ const resourceDataJobAlpha = {
69
+ id: 'RESOURCE-1',
70
+ typeId: 'TYPE-ID',
71
+ creationContext: {
72
+ roleId: 'ROLE-ID',
73
+ executionId: 'EXECUTION-ID',
74
+ },
75
+ kind: 'realized',
76
+ timestamp: 'timestamp',
77
+ path: 'path',
78
+ extractedData: jobAlpha
79
+ };
80
+ // @ts-expect-error Missing path property
81
+ // This SHOULD fail (missing path) once ResourceData_Job enforces Path strictly.
82
+ const resourceDataJobAlpha2 = {
83
+ id: 'RESOURCE-3',
84
+ typeId: 'TYPE-ID',
85
+ creationContext: {
86
+ roleId: 'ROLE-ID',
87
+ executionId: 'EXECUTION-ID',
88
+ },
89
+ kind: 'realized',
90
+ timestamp: 'timestamp',
91
+ // path: 'path',
92
+ extractedData: jobAlpha
93
+ };
94
+ // @ts-expect-error Missing extractedData property
95
+ // This should fail; we're missing extractedData
96
+ const resourceDataJobAlpha3 = {
97
+ id: 'RESOURCE-2',
98
+ typeId: 'TYPE-ID',
99
+ creationContext: {
100
+ roleId: 'ROLE-ID',
101
+ executionId: 'EXECUTION-ID',
102
+ },
103
+ kind: 'realized',
104
+ timestamp: 'timestamp',
105
+ path: 'path',
106
+ // extractedData: jobAlpha
107
+ };
108
+ // This SHOULD fail (missing roles.outputMap) once Job's roles is strictly enforced.
109
+ const resourceDataJobBeta = {
110
+ id: 'RESOURCE-4',
111
+ typeId: 'TYPE-ID',
112
+ creationContext: {
113
+ roleId: 'ROLE-ID',
114
+ executionId: 'EXECUTION-ID',
115
+ },
116
+ kind: 'realized',
117
+ timestamp: 'timestamp',
118
+ path: 'path',
119
+ // @ts-expect-error Missing outputMap inside roles (Job requires outputMap)
120
+ extractedData: jobBeta
121
+ };
122
+ export {};
@@ -0,0 +1,97 @@
1
+ // Auto-generated strict composite type. Do not edit.
2
+ export type ResourceData_Job = ResourceDataMetaBase & {
3
+ extractedData: Job;
4
+ };
5
+ export type ResourceDataMetaBase = ResourceBase &
6
+ ResourceKind & {
7
+ kind: "realized";
8
+ } & Path &
9
+ Timestamp;
10
+ export type ResourceBase = Identifiable & {
11
+ id: string;
12
+ } & {
13
+ typeId: string;
14
+ } & CreationContext;
15
+ export type Job = Documented &
16
+ RolesOuter &
17
+ Uri & {
18
+ identity: string;
19
+ };
20
+ /**
21
+ * This interface was referenced by `undefined`'s JSON-Schema
22
+ * via the `definition` "Documented".
23
+ */
24
+ export type Documented = Name & Description;
25
+ /**
26
+ * This interface was referenced by `undefined`'s JSON-Schema
27
+ * via the `definition` "RoleLiteral".
28
+ */
29
+ export type RoleLiteral = {
30
+ /**
31
+ * This interface was referenced by `undefined`'s JSON-Schema
32
+ * via the `definition` "TypeId".
33
+ */
34
+ typeId: string;
35
+ } & Documented;
36
+
37
+ export interface Identifiable {
38
+ }
39
+ export interface CreationContext {
40
+ creationContext: ResourceSocket;
41
+ }
42
+ export interface ResourceSocket {
43
+ executionId: string;
44
+ roleId: string;
45
+ }
46
+ export interface ResourceKind {
47
+ kind: "potential-input" | "potential-output" | "realized";
48
+ }
49
+ export interface Path {
50
+ path: string;
51
+ }
52
+ export interface Timestamp {
53
+ timestamp: string;
54
+ }
55
+ /**
56
+ * This interface was referenced by `undefined`'s JSON-Schema
57
+ * via the `definition` "Name".
58
+ */
59
+ export interface Name {
60
+ name: string;
61
+ }
62
+ /**
63
+ * This interface was referenced by `undefined`'s JSON-Schema
64
+ * via the `definition` "Description".
65
+ */
66
+ export interface Description {
67
+ description: string;
68
+ }
69
+ /**
70
+ * This interface was referenced by `undefined`'s JSON-Schema
71
+ * via the `definition` "RolesOuter".
72
+ */
73
+ export interface RolesOuter {
74
+ roles: RolesInner;
75
+ }
76
+ /**
77
+ * This interface was referenced by `undefined`'s JSON-Schema
78
+ * via the `definition` "RolesInner".
79
+ */
80
+ export interface RolesInner {
81
+ inputMap: RoleMap;
82
+ outputMap: RoleMap;
83
+ }
84
+ /**
85
+ * This interface was referenced by `undefined`'s JSON-Schema
86
+ * via the `definition` "RoleMap".
87
+ */
88
+ export interface RoleMap {
89
+ [k: string]: RoleLiteral;
90
+ }
91
+ /**
92
+ * This interface was referenced by `undefined`'s JSON-Schema
93
+ * via the `definition` "Uri".
94
+ */
95
+ export interface Uri {
96
+ uri: string;
97
+ }
@@ -0,0 +1 @@
1
+ export {}