@highstate/library 0.9.16 → 0.9.18

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/src/network.ts CHANGED
@@ -1,48 +1,48 @@
1
- import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
1
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
2
 
3
- export const endpointVisibilitySchema = Type.StringEnum([
3
+ export const endpointVisibilitySchema = z.enum([
4
4
  "public", // Reachable from the public internet
5
5
  "external", // Reachable from outside the system boundary, but not public
6
6
  "internal", // Reachable only from within the system or cluster
7
7
  ])
8
8
 
9
- export const endpointFilterSchema = Type.Array(endpointVisibilitySchema)
9
+ export const endpointFilterSchema = endpointVisibilitySchema.array()
10
10
 
11
11
  export const l3EndpointEntity = defineEntity({
12
12
  type: "network.l3-endpoint",
13
13
 
14
- schema: Type.Intersect([
15
- Type.Object({
14
+ schema: z.intersection(
15
+ z.object({
16
16
  visibility: endpointVisibilitySchema,
17
- metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
17
+ metadata: z.record(z.string(), z.unknown()).optional(),
18
18
  }),
19
- Type.Union([
20
- Type.Object({
21
- type: Type.Literal("hostname"),
19
+ z.union([
20
+ z.object({
21
+ type: z.literal("hostname"),
22
22
 
23
23
  /**
24
24
  * The hostname of the endpoint in the format of a domain name.
25
25
  */
26
- hostname: Type.String(),
26
+ hostname: z.string(),
27
27
  }),
28
- Type.Object({
29
- type: Type.Literal("ipv4"),
28
+ z.object({
29
+ type: z.literal("ipv4"),
30
30
 
31
31
  /**
32
32
  * The IPv4 address of the endpoint.
33
33
  */
34
- address: Type.String(),
34
+ address: z.string(),
35
35
  }),
36
- Type.Object({
37
- type: Type.Literal("ipv6"),
36
+ z.object({
37
+ type: z.literal("ipv6"),
38
38
 
39
39
  /**
40
40
  * The IPv6 address of the endpoint.
41
41
  */
42
- address: Type.String(),
42
+ address: z.string(),
43
43
  }),
44
44
  ]),
45
- ]),
45
+ ),
46
46
 
47
47
  meta: {
48
48
  color: "#4CAF50",
@@ -50,17 +50,17 @@ export const l3EndpointEntity = defineEntity({
50
50
  },
51
51
  })
52
52
 
53
- export const l4ProtocolSchema = Type.StringEnum(["tcp", "udp"])
53
+ export const l4ProtocolSchema = z.enum(["tcp", "udp"])
54
54
 
55
- export const l4PortInfoSchema = Type.Object({
56
- port: Type.Number(),
55
+ export const l4PortInfoSchema = z.object({
56
+ port: z.number(),
57
57
  protocol: l4ProtocolSchema,
58
58
  })
59
59
 
60
60
  export const l4EndpointEntity = defineEntity({
61
61
  type: "network.l4-endpoint",
62
62
 
63
- schema: Type.Intersect([l3EndpointEntity.schema, l4PortInfoSchema]),
63
+ schema: z.intersection(l3EndpointEntity.schema, l4PortInfoSchema),
64
64
 
65
65
  meta: {
66
66
  color: "#2196F3",
@@ -68,11 +68,11 @@ export const l4EndpointEntity = defineEntity({
68
68
  },
69
69
  })
70
70
 
71
- export const l7AppInfoSchema = Type.Object({
71
+ export const l7AppInfoSchema = z.object({
72
72
  /**
73
73
  * The name of the application protocol used by the endpoint.
74
74
  */
75
- appProtocol: Type.String(),
75
+ appProtocol: z.string(),
76
76
 
77
77
  /**
78
78
  * The resource path of the application endpoint, including query parameters.
@@ -80,13 +80,13 @@ export const l7AppInfoSchema = Type.Object({
80
80
  *
81
81
  * Example: `api/v1/resource?query=value`, `database?param=value`, `user/repo.git`.
82
82
  */
83
- resource: Type.Optional(Type.String()),
83
+ resource: z.string().optional(),
84
84
  })
85
85
 
86
86
  export const l7EndpointEntity = defineEntity({
87
87
  type: "network.l7-endpoint",
88
88
 
89
- schema: Type.Intersect([l4EndpointEntity.schema, l7AppInfoSchema]),
89
+ schema: z.intersection(l4EndpointEntity.schema, l7AppInfoSchema),
90
90
 
91
91
  meta: {
92
92
  color: "#FF9800",
@@ -104,12 +104,12 @@ export const l3Endpoint = defineUnit({
104
104
  *
105
105
  * May be a domain name or an IP address.
106
106
  */
107
- endpoint: Type.String(),
107
+ endpoint: z.string(),
108
108
 
109
109
  /**
110
110
  * The visibility of the endpoint.
111
111
  */
112
- visibility: Type.Default(endpointVisibilitySchema, "public"),
112
+ visibility: endpointVisibilitySchema.default("public"),
113
113
  },
114
114
 
115
115
  outputs: {
@@ -117,10 +117,10 @@ export const l3Endpoint = defineUnit({
117
117
  },
118
118
 
119
119
  meta: {
120
- displayName: "L3 Endpoint",
120
+ title: "L3 Endpoint",
121
121
  description: "An L3 endpoint for some service. May be a domain name or an IP address.",
122
- primaryIcon: "mdi:network-outline",
123
- primaryIconColor: "#4CAF50",
122
+ icon: "mdi:network-outline",
123
+ iconColor: "#4CAF50",
124
124
  defaultNamePrefix: "endpoint",
125
125
  category: "Network",
126
126
  },
@@ -146,12 +146,12 @@ export const l4Endpoint = defineUnit({
146
146
  * - `tcp://endpoint:port`
147
147
  * - `udp://endpoint:port`
148
148
  */
149
- endpoint: Type.String(),
149
+ endpoint: z.string(),
150
150
 
151
151
  /**
152
152
  * The visibility of the endpoint.
153
153
  */
154
- visibility: Type.Default(endpointVisibilitySchema, "public"),
154
+ visibility: endpointVisibilitySchema.default("public"),
155
155
  },
156
156
 
157
157
  outputs: {
@@ -159,10 +159,10 @@ export const l4Endpoint = defineUnit({
159
159
  },
160
160
 
161
161
  meta: {
162
- displayName: "L4 Endpoint",
162
+ title: "L4 Endpoint",
163
163
  description: "An L4 endpoint for some service. Extends an L3 endpoint with a port.",
164
- primaryIcon: "mdi:network-outline",
165
- primaryIconColor: "#2196F3",
164
+ icon: "mdi:network-outline",
165
+ iconColor: "#2196F3",
166
166
  defaultNamePrefix: "endpoint",
167
167
  category: "Network",
168
168
  },
@@ -180,7 +180,7 @@ export const l4Endpoint = defineUnit({
180
180
  * - `external`: Reachable from outside the system boundary (e.g., LAN, VPC), but not public.
181
181
  * - `internal`: Reachable only from within the application or infrastructure boundary (e.g., within a cluster).
182
182
  */
183
- export type EndpointVisibility = Static<typeof endpointVisibilitySchema>
183
+ export type EndpointVisibility = z.infer<typeof endpointVisibilitySchema>
184
184
 
185
185
  /**
186
186
  * The list of endpoint visibility levels used to filter endpoints.
@@ -190,14 +190,14 @@ export type EndpointVisibility = Static<typeof endpointVisibilitySchema>
190
190
  * - Otherwise, if any external endpoints exist, all external endpoints are selected.
191
191
  * - If neither exist, all internal endpoints are selected.
192
192
  */
193
- export type EndpointFilter = Static<typeof endpointFilterSchema>
194
-
195
- export type L3Endpoint = Static<typeof l3EndpointEntity.schema>
196
- export type L4Endpoint = Static<typeof l4EndpointEntity.schema>
197
- export type L4Protocol = Static<typeof l4ProtocolSchema>
198
- export type L4PortInfo = Static<typeof l4PortInfoSchema>
199
- export type L7Endpoint = Static<typeof l7EndpointEntity.schema>
200
- export type L7AppInfo = Static<typeof l7AppInfoSchema>
193
+ export type EndpointFilter = z.infer<typeof endpointFilterSchema>
194
+
195
+ export type L3Endpoint = z.infer<typeof l3EndpointEntity.schema>
196
+ export type L4Endpoint = z.infer<typeof l4EndpointEntity.schema>
197
+ export type L4Protocol = z.infer<typeof l4ProtocolSchema>
198
+ export type L4PortInfo = z.infer<typeof l4PortInfoSchema>
199
+ export type L7Endpoint = z.infer<typeof l7EndpointEntity.schema>
200
+ export type L7AppInfo = z.infer<typeof l7AppInfoSchema>
201
201
 
202
202
  /**
203
203
  * The L3 or L4 endpoint for some service.
package/src/nixos.ts CHANGED
@@ -1,33 +1,7 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { fileEntity, folderEntity } from "./files"
3
3
  import { serverEntity } from "./common"
4
4
 
5
- // export const moduleEntity = defineEntity({
6
- // type: "nixos.module",
7
-
8
- // schema: Type.Object({
9
- // /**
10
- // * The folder containing the NixOS module files.
11
- // *
12
- // * @schema
13
- // */
14
- // folder: folderEntity.schema,
15
-
16
- // /**
17
- // * The name of the module file entrypoint to use when importing this module.
18
- // *
19
- // * @schema
20
- // */
21
- // entrypoint: Type.String(),
22
- // }),
23
-
24
- // meta: {
25
- // displayName: "NixOS Module",
26
- // description: "The NixOS module reference.",
27
- // color: "#5277c3",
28
- // },
29
- // })
30
-
31
5
  export const inlineModule = defineUnit({
32
6
  type: "nixos.inline-module",
33
7
 
@@ -37,14 +11,14 @@ export const inlineModule = defineUnit({
37
11
  *
38
12
  * If not provided, the name will be the name of the unit.
39
13
  */
40
- moduleName: Type.Optional(Type.String()),
14
+ moduleName: z.string().optional(),
41
15
 
42
16
  /**
43
17
  * The code of the NixOS module.
44
18
  *
45
19
  * In this code you can reference other modules and files by their names.
46
20
  */
47
- code: Type.String({ language: "nix" }),
21
+ code: z.string().meta({ language: "nix" }),
48
22
  },
49
23
 
50
24
  inputs: {
@@ -65,10 +39,10 @@ export const inlineModule = defineUnit({
65
39
  },
66
40
 
67
41
  meta: {
68
- displayName: "NixOS Inline Module",
42
+ title: "NixOS Inline Module",
69
43
  description: "Creates a NixOS module from inline code.",
70
- primaryIcon: "simple-icons:nixos",
71
- primaryIconColor: "#7ebae4",
44
+ icon: "simple-icons:nixos",
45
+ iconColor: "#7ebae4",
72
46
  secondaryIcon: "mdi:file-code",
73
47
  category: "NixOS",
74
48
  },
@@ -79,34 +53,6 @@ export const inlineModule = defineUnit({
79
53
  },
80
54
  })
81
55
 
82
- // export const flakeEntity = defineEntity({
83
- // type: "nixos.flake",
84
-
85
- // schema: Type.Object({
86
- // /**
87
- // * The git repository where the flake is stored.
88
- // *
89
- // * @schema
90
- // */
91
- // repository: repositoryEntity.schema,
92
-
93
- // /**
94
- // * The relative path to the folder containing the flake.nix file.
95
- // *
96
- // * If not provided, the root of the repository will be used.
97
- // *
98
- // * @schema
99
- // */
100
- // flakePath: Type.Optional(Type.String()),
101
- // }),
102
-
103
- // meta: {
104
- // displayName: "NixOS Flake",
105
- // description: "The NixOS flake reference.",
106
- // color: "#5277c3",
107
- // },
108
- // })
109
-
110
56
  export const inlineFlake = defineUnit({
111
57
  type: "nixos.inline-flake",
112
58
 
@@ -116,14 +62,14 @@ export const inlineFlake = defineUnit({
116
62
  *
117
63
  * If not provided, the name will be the name of the unit.
118
64
  */
119
- flakeName: Type.Optional(Type.String()),
65
+ flakeName: z.string().optional(),
120
66
 
121
67
  /**
122
68
  * The code of the `flake.nix` file.
123
69
  *
124
70
  * In this code you can reference other flakes, modules, files, and folders by their names.
125
71
  */
126
- code: Type.String({ language: "nix" }),
72
+ code: z.string().meta({ language: "nix" }),
127
73
  },
128
74
 
129
75
  inputs: {
@@ -144,10 +90,10 @@ export const inlineFlake = defineUnit({
144
90
  },
145
91
 
146
92
  meta: {
147
- displayName: "NixOS Inline Flake",
93
+ title: "NixOS Inline Flake",
148
94
  description: "Creates a NixOS flake from inline code.",
149
- primaryIcon: "simple-icons:nixos",
150
- primaryIconColor: "#7ebae4",
95
+ icon: "simple-icons:nixos",
96
+ iconColor: "#7ebae4",
151
97
  secondaryIcon: "mdi:file-code",
152
98
  category: "NixOS",
153
99
  },
@@ -162,7 +108,7 @@ export const system = defineUnit({
162
108
  type: "nixos.system",
163
109
 
164
110
  args: {
165
- system: Type.Optional(Type.String()),
111
+ system: z.string().optional(),
166
112
  },
167
113
 
168
114
  inputs: {
@@ -175,10 +121,10 @@ export const system = defineUnit({
175
121
  },
176
122
 
177
123
  meta: {
178
- displayName: "NixOS System",
124
+ title: "NixOS System",
179
125
  description: "Creates a NixOS system on top of any server.",
180
- primaryIcon: "simple-icons:nixos",
181
- primaryIconColor: "#7ebae4",
126
+ icon: "simple-icons:nixos",
127
+ iconColor: "#7ebae4",
182
128
  secondaryIcon: "codicon:vm",
183
129
  category: "NixOS",
184
130
  },
@@ -6,9 +6,9 @@ export const deobfuscator = defineUnit({
6
6
  ...deobfuscatorSpec,
7
7
 
8
8
  meta: {
9
- displayName: "Phantun Deobfuscator",
9
+ title: "Phantun Deobfuscator",
10
10
  description: "The Phantun Deobfuscator deployed on Kubernetes.",
11
- primaryIcon: "mdi:network-outline",
11
+ icon: "mdi:network-outline",
12
12
  secondaryIcon: "mdi:hide",
13
13
  category: "Obfuscators",
14
14
  },
@@ -24,9 +24,9 @@ export const obfuscator = defineUnit({
24
24
  ...obfuscatorSpec,
25
25
 
26
26
  meta: {
27
- displayName: "Phantun Obfuscator",
27
+ title: "Phantun Obfuscator",
28
28
  description: "The Phantun Obfuscator deployed on Kubernetes.",
29
- primaryIcon: "mdi:network-outline",
29
+ icon: "mdi:network-outline",
30
30
  secondaryIcon: "mdi:hide",
31
31
  category: "Obfuscators",
32
32
  },
@@ -1,4 +1,4 @@
1
- import { $args, $inputs, $outputs, Type, type Static, type TObject } from "@highstate/contract"
1
+ import { $args, $inputs, $outputs, z } from "@highstate/contract"
2
2
  import { clusterEntity } from "../k8s"
3
3
  import { l4EndpointEntity } from "../network"
4
4
 
@@ -9,21 +9,21 @@ export const deobfuscatorSpec = {
9
9
  *
10
10
  * By default, calculated as `deobfs-{type}-{name}`.
11
11
  */
12
- appName: Type.Optional(Type.String()),
12
+ appName: z.string().optional(),
13
13
 
14
14
  /**
15
15
  * The L4 endpoint to forward deobfuscated traffic to.
16
16
  *
17
17
  * Will take precedence over the `targetEndpoint` input.
18
18
  */
19
- targetEndpoints: Type.Default(Type.Array(Type.String()), []),
19
+ targetEndpoints: z.string().array().default([]),
20
20
 
21
21
  /**
22
22
  * Whether to expose the deobfuscator service by "NodePort" or "LoadBalancer".
23
23
  *
24
24
  * By default, the service is not exposed and only accessible from within the cluster.
25
25
  */
26
- external: Type.Default(Type.Boolean(), false),
26
+ external: z.boolean().default(false),
27
27
  }),
28
28
 
29
29
  inputs: $inputs({
@@ -63,21 +63,21 @@ export const obfuscatorSpec = {
63
63
  *
64
64
  * By default, calculated as `obfs-{type}-{name}`.
65
65
  */
66
- appName: Type.Optional(Type.String()),
66
+ appName: z.string().optional(),
67
67
 
68
68
  /**
69
69
  * The endpoint of the deobfuscator to pass obfuscated traffic to.
70
70
  *
71
71
  * Will take precedence over the `endpoint` input.
72
72
  */
73
- endpoints: Type.Default(Type.Array(Type.String()), []),
73
+ endpoints: z.string().array().default([]),
74
74
 
75
75
  /**
76
76
  * Whether to expose the obfuscator service by "NodePort" or "LoadBalancer".
77
77
  *
78
78
  * By default, the service is not exposed and only accessible from within the cluster.
79
79
  */
80
- external: Type.Default(Type.Boolean(), false),
80
+ external: z.boolean().default(false),
81
81
  }),
82
82
 
83
83
  inputs: $inputs({
@@ -109,5 +109,5 @@ export const obfuscatorSpec = {
109
109
  }),
110
110
  }
111
111
 
112
- export type DeobfuscatorArgs = Static<TObject<(typeof deobfuscatorSpec)["args"]>>
113
- export type ObfuscatorArgs = Static<TObject<(typeof obfuscatorSpec)["args"]>>
112
+ export type DeobfuscatorArgs = z.infer<typeof deobfuscatorSpec.args>
113
+ export type ObfuscatorArgs = z.infer<typeof obfuscatorSpec.args>