@opensoha/contracts 0.1.19 → 0.1.21

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.
Files changed (62) hide show
  1. package/auth/catalog_generated.go +2 -2
  2. package/auth/permission-catalog.json +81 -1
  3. package/compat/json-schema-ecosystem-0.1.0.json +1 -1
  4. package/compat/openapi-loose-boundaries-0.1.0.json +1 -1
  5. package/fixtures/json-schema/network-ingest-event/invalid/proxy-runtime-negative-total.json +19 -0
  6. package/fixtures/json-schema/network-ingest-event/valid/proxy-runtime-sample.json +20 -0
  7. package/fixtures/json-schema/proxy-runtime/invalid/v2ray-connection-snapshot.json +10 -0
  8. package/fixtures/json-schema/proxy-runtime/valid/mihomo-observation.json +16 -0
  9. package/fixtures/openapi/AgentPrometheusQueryRequest/invalid/basic.json +5 -0
  10. package/fixtures/openapi/AgentPrometheusQueryRequest/invalid/missing-range-fields.json +5 -0
  11. package/fixtures/openapi/AgentPrometheusQueryRequest/invalid/zero-start.json +8 -0
  12. package/fixtures/openapi/AgentPrometheusQueryRequest/valid/basic.json +8 -0
  13. package/fixtures/openapi/AgentPrometheusQueryRequest/valid/instant.json +5 -0
  14. package/fixtures/openapi/ClusterAgentUpgradeInput/invalid/image.json +1 -0
  15. package/fixtures/openapi/ClusterAgentUpgradeInput/invalid/missing.json +1 -0
  16. package/fixtures/openapi/ClusterAgentUpgradeInput/invalid/mutable-tag.json +1 -0
  17. package/fixtures/openapi/ClusterAgentUpgradeInput/valid/stable.json +1 -0
  18. package/fixtures/openapi/ClusterAgentUpgradeInput/valid/unprefixed.json +1 -0
  19. package/fixtures/openapi/KubernetesAgentCustomResourceRule/invalid/basic.json +9 -0
  20. package/fixtures/openapi/KubernetesAgentCustomResourceRule/valid/basic.json +14 -0
  21. package/fixtures/openapi/KubernetesAgentCustomResourceRule/valid/dns-names.json +1 -0
  22. package/fixtures/openapi/KubernetesClusterRegistrationRequest/invalid/basic.json +4 -0
  23. package/fixtures/openapi/KubernetesClusterRegistrationRequest/valid/basic.json +6 -0
  24. package/fixtures/openapi/KubernetesConfigMapDataInput/invalid/basic.json +5 -0
  25. package/fixtures/openapi/KubernetesConfigMapDataInput/valid/basic.json +8 -0
  26. package/fixtures/openapi/KubernetesCronJobSuspendInput/invalid/basic.json +3 -0
  27. package/fixtures/openapi/KubernetesCronJobSuspendInput/valid/basic.json +3 -0
  28. package/fixtures/openapi/KubernetesCustomResourceAccess/invalid/basic.json +5 -0
  29. package/fixtures/openapi/KubernetesCustomResourceAccess/valid/basic.json +6 -0
  30. package/fixtures/openapi/KubernetesCustomResourceDefinition/invalid/empty-uid.json +1 -0
  31. package/fixtures/openapi/KubernetesCustomResourceDefinition/valid/deleting-definition.json +1 -0
  32. package/fixtures/openapi/KubernetesNamespaceCreateInput/invalid/basic.json +1 -0
  33. package/fixtures/openapi/KubernetesNamespaceCreateInput/valid/basic.json +1 -0
  34. package/fixtures/openapi/KubernetesNodeDrainInput/invalid/basic.json +3 -0
  35. package/fixtures/openapi/KubernetesNodeDrainInput/valid/basic.json +3 -0
  36. package/fixtures/openapi/KubernetesNodeSchedulabilityInput/invalid/basic.json +1 -0
  37. package/fixtures/openapi/KubernetesNodeSchedulabilityInput/valid/basic.json +3 -0
  38. package/fixtures/openapi/KubernetesResourceUpdatePlanRequest/valid/range-kind.json +5 -0
  39. package/fixtures/openapi/KubernetesResourceYaml/valid/range-kind.json +5 -0
  40. package/fixtures/openapi/KubernetesSecretDataInput/invalid/basic.json +5 -0
  41. package/fixtures/openapi/KubernetesSecretDataInput/valid/basic.json +5 -0
  42. package/fixtures/openapi/NetworkProxyConfigurationInput/invalid/empty-content.json +1 -0
  43. package/fixtures/openapi/NetworkProxyConfigurationInput/valid/enabled.json +1 -0
  44. package/fixtures/openapi/NetworkProxyInstanceInput/invalid/unknown-engine.json +1 -0
  45. package/fixtures/openapi/NetworkProxyInstanceInput/valid/mihomo.json +1 -0
  46. package/gen/go/sohaapi/client.go +1 -1
  47. package/gen/go/sohaapi/client_test.go +25 -0
  48. package/gen/go/sohaapi/types.go +122 -24
  49. package/gen/ts/sohaapi/index.ts +266 -1
  50. package/go.mod +4 -4
  51. package/go.sum +4 -4
  52. package/network/README.md +12 -0
  53. package/network/network-ingest-event.schema.json +21 -3
  54. package/network/network-runtime-protocol.schema.json +2 -2
  55. package/network/proxy-runtime.schema.json +113 -0
  56. package/network/schema.go +7 -0
  57. package/openapi/soha-api.json +938 -4
  58. package/openapi/soha-api.yaml +389 -3
  59. package/openapi/spec_generated.go +3 -3
  60. package/package.json +2 -1
  61. package/resource/agent_access.go +23 -0
  62. package/resource/models.go +2 -0
@@ -10,7 +10,7 @@
10
10
  "schemaVersion": { "const": "network-ingest/v1alpha1" },
11
11
  "batchId": { "$ref": "#/$defs/Identifier" },
12
12
  "producerId": { "$ref": "#/$defs/Identifier" },
13
- "producerKind": { "enum": ["endpoint", "gateway", "freeradius", "network-control"] },
13
+ "producerKind": { "enum": ["endpoint", "gateway", "freeradius", "network-control", "proxy"] },
14
14
  "sentAt": { "type": "string", "format": "date-time" },
15
15
  "events": {
16
16
  "type": "array",
@@ -207,7 +207,8 @@
207
207
  "radius.accounting",
208
208
  "network.flow.aggregate",
209
209
  "network.connection.summary",
210
- "proxy.flow.aggregate"
210
+ "proxy.flow.aggregate",
211
+ "proxy.runtime.sample"
211
212
  ]
212
213
  },
213
214
  "sequence": { "type": "integer", "minimum": 0 },
@@ -221,7 +222,8 @@
221
222
  { "$ref": "#/$defs/RadiusAccounting" },
222
223
  { "$ref": "#/$defs/FlowAggregate" },
223
224
  { "$ref": "#/$defs/ConnectionSummary" },
224
- { "$ref": "#/$defs/ProxyFlowAggregate" }
225
+ { "$ref": "#/$defs/ProxyFlowAggregate" },
226
+ { "$ref": "#/$defs/ProxyRuntimeSample" }
225
227
  ]
226
228
  }
227
229
  },
@@ -302,6 +304,10 @@
302
304
  {
303
305
  "if": { "properties": { "type": { "const": "proxy.flow.aggregate" } }, "required": ["type"] },
304
306
  "then": { "properties": { "payload": { "$ref": "#/$defs/ProxyFlowAggregate" } } }
307
+ },
308
+ {
309
+ "if": { "properties": { "type": { "const": "proxy.runtime.sample" } }, "required": ["type"] },
310
+ "then": { "properties": { "payload": { "$ref": "#/$defs/ProxyRuntimeSample" } } }
305
311
  }
306
312
  ]
307
313
  },
@@ -410,6 +416,18 @@
410
416
  "downloadBytes": { "type": "integer", "minimum": 0, "maximum": 9223372036854775807 },
411
417
  "activeConnections": { "type": "integer", "minimum": 0, "maximum": 1000000 }
412
418
  }
419
+ },
420
+ "ProxyRuntimeSample": {
421
+ "type": "object",
422
+ "additionalProperties": false,
423
+ "required": ["engine", "uptimeSeconds", "uploadTotal", "downloadTotal"],
424
+ "properties": {
425
+ "engine": { "enum": ["mihomo", "sing-box", "v2ray"] },
426
+ "uptimeSeconds": { "type": "integer", "minimum": 0 },
427
+ "uploadTotal": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
428
+ "downloadTotal": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
429
+ "activeConnections": { "type": "integer", "minimum": 0, "maximum": 1000000 }
430
+ }
413
431
  }
414
432
  }
415
433
  }
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "producerId": { "$ref": "#/$defs/Identifier" },
44
44
  "runtimeId": { "$ref": "#/$defs/Identifier" },
45
- "runtimeKind": { "enum": ["endpoint", "gateway", "nas"] },
45
+ "runtimeKind": { "enum": ["endpoint", "gateway", "nas", "proxy"] },
46
46
  "occurredAt": { "type": "string", "format": "date-time" },
47
47
  "expiresAt": { "type": "string", "format": "date-time" },
48
48
  "payload": {
@@ -712,7 +712,7 @@
712
712
  "minItems": 1,
713
713
  "maxItems": 32,
714
714
  "uniqueItems": true,
715
- "items": { "enum": ["wireguard", "mihomo", "route-coordinator", "dns-coordinator", "managed-vpn-v1", "vpn-probe-v1", "vpn-metrics-v1"] }
715
+ "items": { "enum": ["wireguard", "mihomo", "route-coordinator", "dns-coordinator", "managed-vpn-v1", "vpn-probe-v1", "vpn-metrics-v1", "proxy-runtime-v1"] }
716
716
  }
717
717
  },
718
718
  "allOf": [{
@@ -0,0 +1,113 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://contracts.opensoha.dev/network/proxy-runtime.schema.json",
4
+ "title": "OpenSoha Proxy Runtime Message",
5
+ "description": "Messages on the authenticated proxy runtime channel. Configuration content is delivered only to the enrolled runtime and is never returned by management reads.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "runtimeId", "messageType", "occurredAt", "payload"],
9
+ "properties": {
10
+ "schemaVersion": { "const": "proxy-runtime/v1alpha1" },
11
+ "runtimeId": { "$ref": "#/$defs/Identifier" },
12
+ "messageType": { "enum": ["configuration.desired", "configuration.applied", "observation", "connections.snapshot", "connection.close.request", "connection.close.result"] },
13
+ "occurredAt": { "type": "string", "format": "date-time" },
14
+ "payload": {
15
+ "oneOf": [
16
+ { "$ref": "#/$defs/ConfigurationDesired" },
17
+ { "$ref": "#/$defs/ConfigurationApplied" },
18
+ { "$ref": "#/$defs/Observation" },
19
+ { "$ref": "#/$defs/ConnectionsSnapshot" },
20
+ { "$ref": "#/$defs/ConnectionCloseRequest" },
21
+ { "$ref": "#/$defs/ConnectionCloseResult" }
22
+ ]
23
+ }
24
+ },
25
+ "allOf": [
26
+ { "if": { "properties": { "messageType": { "const": "configuration.desired" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConfigurationDesired" } } } },
27
+ { "if": { "properties": { "messageType": { "const": "configuration.applied" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConfigurationApplied" } } } },
28
+ { "if": { "properties": { "messageType": { "const": "observation" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/Observation" } } } },
29
+ { "if": { "properties": { "messageType": { "const": "connections.snapshot" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionsSnapshot" } } } },
30
+ { "if": { "properties": { "messageType": { "const": "connection.close.request" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionCloseRequest" } } } },
31
+ { "if": { "properties": { "messageType": { "const": "connection.close.result" } }, "required": ["messageType"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/ConnectionCloseResult" } } } }
32
+ ],
33
+ "$defs": {
34
+ "Identifier": { "type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$" },
35
+ "Engine": { "enum": ["mihomo", "sing-box", "v2ray"] },
36
+ "Hash": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
37
+ "ConfigurationDesired": {
38
+ "type": "object", "additionalProperties": false,
39
+ "required": ["revision", "engine", "enabled", "contentHash", "content", "validUntil"],
40
+ "properties": {
41
+ "revision": { "type": "integer", "minimum": 1 },
42
+ "engine": { "$ref": "#/$defs/Engine" },
43
+ "enabled": { "type": "boolean" },
44
+ "contentHash": { "$ref": "#/$defs/Hash" },
45
+ "content": { "type": "string", "minLength": 1, "maxLength": 1048576, "writeOnly": true },
46
+ "validUntil": { "type": "string", "format": "date-time" }
47
+ }
48
+ },
49
+ "ConfigurationApplied": {
50
+ "type": "object", "additionalProperties": false,
51
+ "required": ["revision", "status", "readbackHash"],
52
+ "properties": {
53
+ "revision": { "type": "integer", "minimum": 1 },
54
+ "status": { "enum": ["applied", "rejected", "rolled-back"] },
55
+ "readbackHash": { "$ref": "#/$defs/Hash" },
56
+ "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 }
57
+ }
58
+ },
59
+ "Observation": {
60
+ "type": "object", "additionalProperties": false,
61
+ "required": ["engine", "engineVersion", "health", "capabilities", "uptimeSeconds", "uploadTotal", "downloadTotal"],
62
+ "properties": {
63
+ "engine": { "$ref": "#/$defs/Engine" },
64
+ "engineVersion": { "type": "string", "minLength": 1, "maxLength": 64 },
65
+ "health": { "enum": ["healthy", "degraded", "unhealthy"] },
66
+ "capabilities": { "type": "array", "maxItems": 3, "uniqueItems": true, "items": { "enum": ["traffic", "connections", "close_connection"] } },
67
+ "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 },
68
+ "uptimeSeconds": { "type": "integer", "minimum": 0 },
69
+ "uploadTotal": { "type": "integer", "minimum": 0, "maximum": 9223372036854775807 },
70
+ "downloadTotal": { "type": "integer", "minimum": 0, "maximum": 9223372036854775807 },
71
+ "activeConnections": { "type": "integer", "minimum": 0, "maximum": 1000000 }
72
+ }
73
+ },
74
+ "Connection": {
75
+ "type": "object", "additionalProperties": false,
76
+ "required": ["id", "destination", "network", "uploadBytes", "downloadBytes"],
77
+ "properties": {
78
+ "id": { "$ref": "#/$defs/Identifier" },
79
+ "destination": { "type": "string", "minLength": 1, "maxLength": 253 },
80
+ "network": { "enum": ["tcp", "udp", "other"] },
81
+ "uploadBytes": { "type": "integer", "minimum": 0 },
82
+ "downloadBytes": { "type": "integer", "minimum": 0 },
83
+ "startedAt": { "type": "string", "format": "date-time" }
84
+ }
85
+ },
86
+ "ConnectionsSnapshot": {
87
+ "type": "object", "additionalProperties": false,
88
+ "required": ["engine", "connections"],
89
+ "properties": {
90
+ "engine": { "enum": ["mihomo", "sing-box"] },
91
+ "connections": { "type": "array", "maxItems": 200, "items": { "$ref": "#/$defs/Connection" } }
92
+ }
93
+ },
94
+ "ConnectionCloseRequest": {
95
+ "type": "object", "additionalProperties": false,
96
+ "required": ["commandId", "connectionId", "expiresAt"],
97
+ "properties": {
98
+ "commandId": { "$ref": "#/$defs/Identifier" },
99
+ "connectionId": { "$ref": "#/$defs/Identifier" },
100
+ "expiresAt": { "type": "string", "format": "date-time" }
101
+ }
102
+ },
103
+ "ConnectionCloseResult": {
104
+ "type": "object", "additionalProperties": false,
105
+ "required": ["commandId", "status"],
106
+ "properties": {
107
+ "commandId": { "$ref": "#/$defs/Identifier" },
108
+ "status": { "enum": ["closed", "not-found", "failed"] },
109
+ "reasonCode": { "type": "string", "minLength": 1, "maxLength": 128 }
110
+ }
111
+ }
112
+ }
113
+ }
package/network/schema.go CHANGED
@@ -11,6 +11,9 @@ var (
11
11
 
12
12
  //go:embed network-radius-accounting.schema.json
13
13
  radiusAccountingSchema []byte
14
+
15
+ //go:embed proxy-runtime.schema.json
16
+ proxyRuntimeSchema []byte
14
17
  )
15
18
 
16
19
  func RuntimeProtocolSchema() []byte {
@@ -24,3 +27,7 @@ func IngestEventSchema() []byte {
24
27
  func RadiusAccountingSchema() []byte {
25
28
  return append([]byte(nil), radiusAccountingSchema...)
26
29
  }
30
+
31
+ func ProxyRuntimeSchema() []byte {
32
+ return append([]byte(nil), proxyRuntimeSchema...)
33
+ }