@spectro/protocol 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +14 -2
- package/dist/schemas/common.schema.json +149 -0
- package/dist/schemas/custom.schema.json +10 -0
- package/dist/schemas/envelope.schema.json +25 -0
- package/dist/schemas/error.schema.json +42 -0
- package/dist/schemas/event.schema.json +67 -0
- package/dist/schemas/interaction.schema.json +28 -0
- package/dist/schemas/network.schema.json +37 -0
- package/dist/schemas/page.schema.json +12 -0
- package/dist/schemas/performance.schema.json +18 -0
- package/dist/schemas/session.schema.json +11 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/schemas.d.ts +8 -0
- package/dist/src/schemas.d.ts.map +1 -0
- package/dist/src/schemas.js +24 -0
- package/dist/src/schemas.js.map +1 -0
- package/dist/src/types.d.ts +170 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +8 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/validation.d.ts +18 -0
- package/dist/src/validation.d.ts.map +1 -0
- package/dist/src/validation.js +109 -0
- package/dist/src/validation.js.map +1 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Spectro contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @spectro/protocol
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Spectro Protocol V1 JSON Schemas, TypeScript types, serialization limits and strict validators. The common event envelope and event-specific payloads are shared by SDKs and server services.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { validateEnvelope, protocolSchemas } from '@spectro/protocol';
|
|
7
|
+
|
|
8
|
+
const result = validateEnvelope({ version: 1, sentAt: Date.now(), items: [] });
|
|
9
|
+
console.log(result.success);
|
|
10
|
+
console.log(protocolSchemas.event.$id);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Original JSON Schemas are also exported through `@spectro/protocol/schemas/*.json`. Package release versions are independent of event and envelope protocol versions. The package is ESM; Node consumers need a runtime that supports JSON import attributes (Node 22.12+).
|
|
14
|
+
|
|
15
|
+
MIT, including this package's original schemas. See LICENSE. Platform services outside this package are not covered by this license.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/common.schema.json",
|
|
4
|
+
"$defs": {
|
|
5
|
+
"uuidV7": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
8
|
+
},
|
|
9
|
+
"jsonValue": {
|
|
10
|
+
"oneOf": [
|
|
11
|
+
{ "type": "string", "maxLength": 2048 },
|
|
12
|
+
{ "type": "number" },
|
|
13
|
+
{ "type": "boolean" },
|
|
14
|
+
{ "type": "null" },
|
|
15
|
+
{
|
|
16
|
+
"type": "array",
|
|
17
|
+
"maxItems": 100,
|
|
18
|
+
"items": { "$ref": "#/$defs/jsonValue" }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "object",
|
|
22
|
+
"maxProperties": 100,
|
|
23
|
+
"propertyNames": { "maxLength": 128 },
|
|
24
|
+
"additionalProperties": { "$ref": "#/$defs/jsonValue" }
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"jsonObject": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"maxProperties": 100,
|
|
31
|
+
"propertyNames": { "maxLength": 128 },
|
|
32
|
+
"additionalProperties": { "$ref": "#/$defs/jsonValue" }
|
|
33
|
+
},
|
|
34
|
+
"sdkContext": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"additionalProperties": false,
|
|
37
|
+
"required": ["name", "version"],
|
|
38
|
+
"properties": {
|
|
39
|
+
"name": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
40
|
+
"version": { "type": "string", "minLength": 1, "maxLength": 64 }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"projectContext": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"required": ["id"],
|
|
47
|
+
"properties": {
|
|
48
|
+
"id": { "type": "string", "pattern": "^prj_[A-Za-z0-9_-]{1,120}$" }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"sessionContext": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"additionalProperties": false,
|
|
54
|
+
"required": ["id"],
|
|
55
|
+
"properties": {
|
|
56
|
+
"id": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
57
|
+
"startedAt": { "type": "integer", "minimum": 0 }
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"userContext": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"required": ["anonymousId"],
|
|
64
|
+
"properties": {
|
|
65
|
+
"id": { "type": "string", "minLength": 1, "maxLength": 256 },
|
|
66
|
+
"anonymousId": { "type": "string", "minLength": 1, "maxLength": 256 },
|
|
67
|
+
"traits": { "$ref": "#/$defs/jsonObject" }
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"pageContext": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"additionalProperties": false,
|
|
73
|
+
"required": ["id", "url", "path"],
|
|
74
|
+
"properties": {
|
|
75
|
+
"id": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
76
|
+
"url": { "type": "string", "minLength": 1, "maxLength": 2048 },
|
|
77
|
+
"path": { "type": "string", "minLength": 1, "maxLength": 2048 },
|
|
78
|
+
"title": { "type": "string", "maxLength": 512 },
|
|
79
|
+
"referrer": { "type": "string", "maxLength": 2048 }
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"deviceContext": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"additionalProperties": false,
|
|
85
|
+
"properties": {
|
|
86
|
+
"type": { "type": "string", "enum": ["desktop", "mobile", "tablet", "unknown"] },
|
|
87
|
+
"model": { "type": "string", "maxLength": 128 }
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"browserContext": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": false,
|
|
93
|
+
"properties": {
|
|
94
|
+
"name": { "type": "string", "maxLength": 128 },
|
|
95
|
+
"version": { "type": "string", "maxLength": 64 }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"osContext": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"properties": {
|
|
102
|
+
"name": { "type": "string", "maxLength": 128 },
|
|
103
|
+
"version": { "type": "string", "maxLength": 64 }
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"releaseContext": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"additionalProperties": false,
|
|
109
|
+
"required": ["version"],
|
|
110
|
+
"properties": {
|
|
111
|
+
"version": { "type": "string", "minLength": 1, "maxLength": 128 }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"traceContext": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"additionalProperties": false,
|
|
117
|
+
"properties": {
|
|
118
|
+
"traceId": { "type": "string", "maxLength": 64 },
|
|
119
|
+
"spanId": { "type": "string", "maxLength": 32 },
|
|
120
|
+
"parentSpanId": { "type": "string", "maxLength": 32 }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"tags": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"maxProperties": 50,
|
|
126
|
+
"propertyNames": { "pattern": "^[A-Za-z][A-Za-z0-9_.-]{0,63}$" },
|
|
127
|
+
"additionalProperties": { "type": "string", "maxLength": 256 }
|
|
128
|
+
},
|
|
129
|
+
"eventContext": {
|
|
130
|
+
"type": "object",
|
|
131
|
+
"additionalProperties": false,
|
|
132
|
+
"required": ["sdk", "project", "environment"],
|
|
133
|
+
"properties": {
|
|
134
|
+
"sdk": { "$ref": "#/$defs/sdkContext" },
|
|
135
|
+
"project": { "$ref": "#/$defs/projectContext" },
|
|
136
|
+
"environment": { "type": "string", "minLength": 1, "maxLength": 64 },
|
|
137
|
+
"session": { "$ref": "#/$defs/sessionContext" },
|
|
138
|
+
"user": { "$ref": "#/$defs/userContext" },
|
|
139
|
+
"page": { "$ref": "#/$defs/pageContext" },
|
|
140
|
+
"device": { "$ref": "#/$defs/deviceContext" },
|
|
141
|
+
"browser": { "$ref": "#/$defs/browserContext" },
|
|
142
|
+
"os": { "$ref": "#/$defs/osContext" },
|
|
143
|
+
"release": { "$ref": "#/$defs/releaseContext" },
|
|
144
|
+
"trace": { "$ref": "#/$defs/traceContext" },
|
|
145
|
+
"tags": { "$ref": "#/$defs/tags" }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/custom.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["properties"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"properties": { "$ref": "https://spectro.dev/schemas/common.schema.json#/$defs/jsonObject" }
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/envelope.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["version", "sentAt", "items"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"version": { "const": 1 },
|
|
9
|
+
"sentAt": { "type": "integer", "minimum": 0 },
|
|
10
|
+
"items": {
|
|
11
|
+
"type": "array",
|
|
12
|
+
"minItems": 1,
|
|
13
|
+
"maxItems": 100,
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"additionalProperties": false,
|
|
17
|
+
"required": ["type", "payload"],
|
|
18
|
+
"properties": {
|
|
19
|
+
"type": { "const": "event" },
|
|
20
|
+
"payload": { "$ref": "https://spectro.dev/schemas/event.schema.json" }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/error.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["mechanism", "message", "handled"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"mechanism": { "type": "string", "enum": ["runtime", "promise", "resource", "manual"] },
|
|
9
|
+
"name": { "type": "string", "maxLength": 256 },
|
|
10
|
+
"message": { "type": "string", "minLength": 1, "maxLength": 2048 },
|
|
11
|
+
"handled": { "type": "boolean" },
|
|
12
|
+
"fingerprint": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"maxItems": 10,
|
|
15
|
+
"items": { "type": "string", "maxLength": 256 }
|
|
16
|
+
},
|
|
17
|
+
"stack": {
|
|
18
|
+
"type": "array",
|
|
19
|
+
"maxItems": 50,
|
|
20
|
+
"items": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"properties": {
|
|
24
|
+
"filename": { "type": "string", "maxLength": 2048 },
|
|
25
|
+
"function": { "type": "string", "maxLength": 512 },
|
|
26
|
+
"line": { "type": "integer", "minimum": 0 },
|
|
27
|
+
"column": { "type": "integer", "minimum": 0 },
|
|
28
|
+
"inApp": { "type": "boolean" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"source": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"properties": {
|
|
36
|
+
"url": { "type": "string", "maxLength": 2048 },
|
|
37
|
+
"line": { "type": "integer", "minimum": 0 },
|
|
38
|
+
"column": { "type": "integer", "minimum": 0 }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/event.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["id", "type", "name", "version", "timestamp", "context", "payload"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"id": { "$ref": "https://spectro.dev/schemas/common.schema.json#/$defs/uuidV7" },
|
|
9
|
+
"type": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"enum": ["session", "page", "error", "performance", "network", "interaction", "custom"]
|
|
12
|
+
},
|
|
13
|
+
"name": { "type": "string", "pattern": "^[a-z][a-z0-9_]{0,63}$" },
|
|
14
|
+
"version": { "const": 1 },
|
|
15
|
+
"timestamp": { "type": "integer", "minimum": 0 },
|
|
16
|
+
"context": { "$ref": "https://spectro.dev/schemas/common.schema.json#/$defs/eventContext" },
|
|
17
|
+
"payload": { "type": "object" }
|
|
18
|
+
},
|
|
19
|
+
"allOf": [
|
|
20
|
+
{
|
|
21
|
+
"if": { "properties": { "type": { "const": "session" } }, "required": ["type"] },
|
|
22
|
+
"then": {
|
|
23
|
+
"properties": { "payload": { "$ref": "https://spectro.dev/schemas/session.schema.json" } }
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"if": { "properties": { "type": { "const": "page" } }, "required": ["type"] },
|
|
28
|
+
"then": {
|
|
29
|
+
"properties": { "payload": { "$ref": "https://spectro.dev/schemas/page.schema.json" } }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"if": { "properties": { "type": { "const": "error" } }, "required": ["type"] },
|
|
34
|
+
"then": {
|
|
35
|
+
"properties": { "payload": { "$ref": "https://spectro.dev/schemas/error.schema.json" } }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"if": { "properties": { "type": { "const": "performance" } }, "required": ["type"] },
|
|
40
|
+
"then": {
|
|
41
|
+
"properties": {
|
|
42
|
+
"payload": { "$ref": "https://spectro.dev/schemas/performance.schema.json" }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"if": { "properties": { "type": { "const": "network" } }, "required": ["type"] },
|
|
48
|
+
"then": {
|
|
49
|
+
"properties": { "payload": { "$ref": "https://spectro.dev/schemas/network.schema.json" } }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"if": { "properties": { "type": { "const": "interaction" } }, "required": ["type"] },
|
|
54
|
+
"then": {
|
|
55
|
+
"properties": {
|
|
56
|
+
"payload": { "$ref": "https://spectro.dev/schemas/interaction.schema.json" }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"if": { "properties": { "type": { "const": "custom" } }, "required": ["type"] },
|
|
62
|
+
"then": {
|
|
63
|
+
"properties": { "payload": { "$ref": "https://spectro.dev/schemas/custom.schema.json" } }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/interaction.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"properties": {
|
|
7
|
+
"target": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"tag": { "type": "string", "maxLength": 64 },
|
|
12
|
+
"id": { "type": "string", "maxLength": 128 },
|
|
13
|
+
"role": { "type": "string", "maxLength": 64 },
|
|
14
|
+
"selector": { "type": "string", "maxLength": 512 },
|
|
15
|
+
"monitorId": { "type": "string", "maxLength": 128 }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"coordinates": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"required": ["x", "y"],
|
|
22
|
+
"properties": {
|
|
23
|
+
"x": { "type": "number" },
|
|
24
|
+
"y": { "type": "number" }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/network.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["request", "timing", "initiator", "success"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"request": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"required": ["method", "url"],
|
|
12
|
+
"properties": {
|
|
13
|
+
"method": { "type": "string", "pattern": "^[A-Z]+$", "maxLength": 16 },
|
|
14
|
+
"url": { "type": "string", "minLength": 1, "maxLength": 2048 }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"response": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"required": ["status"],
|
|
21
|
+
"properties": {
|
|
22
|
+
"status": { "type": "integer", "minimum": 0, "maximum": 599 }
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"timing": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"additionalProperties": false,
|
|
28
|
+
"required": ["start", "duration"],
|
|
29
|
+
"properties": {
|
|
30
|
+
"start": { "type": "number", "minimum": 0 },
|
|
31
|
+
"duration": { "type": "number", "minimum": 0 }
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"initiator": { "type": "string", "enum": ["fetch", "xhr", "resource"] },
|
|
35
|
+
"success": { "type": "boolean" }
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/page.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["action"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"action": { "type": "string", "enum": ["view", "route_change", "leave"] },
|
|
9
|
+
"from": { "type": "string", "maxLength": 2048 },
|
|
10
|
+
"to": { "type": "string", "maxLength": 2048 }
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/performance.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["metric", "value", "unit"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"metric": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"enum": ["lcp", "inp", "cls", "fcp", "ttfb", "long_task", "navigation", "resource_timing"]
|
|
11
|
+
},
|
|
12
|
+
"value": { "type": "number", "minimum": 0 },
|
|
13
|
+
"unit": { "type": "string", "enum": ["ms", "score"] },
|
|
14
|
+
"rating": { "type": "string", "enum": ["good", "needs_improvement", "poor"] },
|
|
15
|
+
"navigationType": { "type": "string", "maxLength": 64 },
|
|
16
|
+
"attribution": { "$ref": "https://spectro.dev/schemas/common.schema.json#/$defs/jsonObject" }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://spectro.dev/schemas/session.schema.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": ["action"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"action": { "type": "string", "enum": ["start", "end"] },
|
|
9
|
+
"duration": { "type": "number", "minimum": 0 }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type ProtocolSchemaValue = string | number | boolean | null | readonly ProtocolSchemaValue[] | ProtocolSchemaDocument;
|
|
2
|
+
export interface ProtocolSchemaDocument {
|
|
3
|
+
readonly [key: string]: ProtocolSchemaValue;
|
|
4
|
+
}
|
|
5
|
+
export type ProtocolSchemaName = 'common' | 'custom' | 'envelope' | 'error' | 'event' | 'interaction' | 'network' | 'page' | 'performance' | 'session';
|
|
6
|
+
/** Original bundled Draft 2020-12 documents. Their $id values are identifiers, not fetch URLs. */
|
|
7
|
+
export declare const protocolSchemas: Readonly<Record<ProtocolSchemaName, ProtocolSchemaDocument>>;
|
|
8
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,mBAAmB,EAAE,GAC9B,sBAAsB,CAAC;AAE3B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;CAC7C;AAED,MAAM,MAAM,kBAAkB,GAC1B,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,OAAO,GACP,OAAO,GACP,aAAa,GACb,SAAS,GACT,MAAM,GACN,aAAa,GACb,SAAS,CAAC;AAEd,kGAAkG;AAClG,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAWxF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import common from '../schemas/common.schema.json' with { type: 'json' };
|
|
2
|
+
import custom from '../schemas/custom.schema.json' with { type: 'json' };
|
|
3
|
+
import envelope from '../schemas/envelope.schema.json' with { type: 'json' };
|
|
4
|
+
import error from '../schemas/error.schema.json' with { type: 'json' };
|
|
5
|
+
import event from '../schemas/event.schema.json' with { type: 'json' };
|
|
6
|
+
import interaction from '../schemas/interaction.schema.json' with { type: 'json' };
|
|
7
|
+
import network from '../schemas/network.schema.json' with { type: 'json' };
|
|
8
|
+
import page from '../schemas/page.schema.json' with { type: 'json' };
|
|
9
|
+
import performance from '../schemas/performance.schema.json' with { type: 'json' };
|
|
10
|
+
import session from '../schemas/session.schema.json' with { type: 'json' };
|
|
11
|
+
/** Original bundled Draft 2020-12 documents. Their $id values are identifiers, not fetch URLs. */
|
|
12
|
+
export const protocolSchemas = {
|
|
13
|
+
common,
|
|
14
|
+
custom,
|
|
15
|
+
envelope,
|
|
16
|
+
error,
|
|
17
|
+
event,
|
|
18
|
+
interaction,
|
|
19
|
+
network,
|
|
20
|
+
page,
|
|
21
|
+
performance,
|
|
22
|
+
session,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzE,OAAO,MAAM,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzE,OAAO,QAAQ,MAAM,iCAAiC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7E,OAAO,KAAK,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvE,OAAO,KAAK,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvE,OAAO,WAAW,MAAM,oCAAoC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnF,OAAO,OAAO,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3E,OAAO,IAAI,MAAM,6BAA6B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrE,OAAO,WAAW,MAAM,oCAAoC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnF,OAAO,OAAO,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AA0B3E,kGAAkG;AAClG,MAAM,CAAC,MAAM,eAAe,GAAiE;IAC3F,MAAM;IACN,MAAM;IACN,QAAQ;IACR,KAAK;IACL,KAAK;IACL,WAAW;IACX,OAAO;IACP,IAAI;IACJ,WAAW;IACX,OAAO;CACR,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export declare const EVENT_VERSION: 1;
|
|
2
|
+
export declare const ENVELOPE_VERSION: 1;
|
|
3
|
+
export declare const EVENT_NAME_PATTERN: RegExp;
|
|
4
|
+
export declare const MAX_EVENT_BYTES: number;
|
|
5
|
+
export declare const MAX_ENVELOPE_BYTES: number;
|
|
6
|
+
export declare const MAX_JSON_DEPTH = 5;
|
|
7
|
+
export declare const MAX_ENVELOPE_STRUCTURE_DEPTH = 16;
|
|
8
|
+
export type JSONPrimitive = string | number | boolean | null;
|
|
9
|
+
export type JSONValue = JSONPrimitive | JSONValue[] | {
|
|
10
|
+
[key: string]: JSONValue;
|
|
11
|
+
};
|
|
12
|
+
export type JSONObject = {
|
|
13
|
+
[key: string]: JSONValue;
|
|
14
|
+
};
|
|
15
|
+
export type EventType = 'session' | 'page' | 'error' | 'performance' | 'network' | 'interaction' | 'custom';
|
|
16
|
+
export interface SDKContext {
|
|
17
|
+
name: string;
|
|
18
|
+
version: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ProjectContext {
|
|
21
|
+
id: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SessionContext {
|
|
24
|
+
id: string;
|
|
25
|
+
startedAt?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface UserContext {
|
|
28
|
+
id?: string;
|
|
29
|
+
anonymousId: string;
|
|
30
|
+
traits?: JSONObject;
|
|
31
|
+
}
|
|
32
|
+
export interface PageContext {
|
|
33
|
+
id: string;
|
|
34
|
+
url: string;
|
|
35
|
+
path: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
referrer?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DeviceContext {
|
|
40
|
+
type?: 'desktop' | 'mobile' | 'tablet' | 'unknown';
|
|
41
|
+
model?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface BrowserContext {
|
|
44
|
+
name?: string;
|
|
45
|
+
version?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface OSContext {
|
|
48
|
+
name?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ReleaseContext {
|
|
52
|
+
version: string;
|
|
53
|
+
}
|
|
54
|
+
export interface TraceContext {
|
|
55
|
+
traceId?: string;
|
|
56
|
+
spanId?: string;
|
|
57
|
+
parentSpanId?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface EventContext {
|
|
60
|
+
sdk: SDKContext;
|
|
61
|
+
project: ProjectContext;
|
|
62
|
+
environment: string;
|
|
63
|
+
session?: SessionContext;
|
|
64
|
+
user?: UserContext;
|
|
65
|
+
page?: PageContext;
|
|
66
|
+
device?: DeviceContext;
|
|
67
|
+
browser?: BrowserContext;
|
|
68
|
+
os?: OSContext;
|
|
69
|
+
release?: ReleaseContext;
|
|
70
|
+
trace?: TraceContext;
|
|
71
|
+
tags?: Record<string, string>;
|
|
72
|
+
}
|
|
73
|
+
export interface StackFrame {
|
|
74
|
+
filename?: string;
|
|
75
|
+
function?: string;
|
|
76
|
+
line?: number;
|
|
77
|
+
column?: number;
|
|
78
|
+
inApp?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface ErrorPayload {
|
|
81
|
+
mechanism: 'runtime' | 'promise' | 'resource' | 'manual';
|
|
82
|
+
name?: string;
|
|
83
|
+
message: string;
|
|
84
|
+
stack?: StackFrame[];
|
|
85
|
+
fingerprint?: string[];
|
|
86
|
+
handled: boolean;
|
|
87
|
+
source?: {
|
|
88
|
+
url?: string;
|
|
89
|
+
line?: number;
|
|
90
|
+
column?: number;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface PerformancePayload {
|
|
94
|
+
metric: 'lcp' | 'inp' | 'cls' | 'fcp' | 'ttfb' | 'long_task' | 'navigation' | 'resource_timing';
|
|
95
|
+
value: number;
|
|
96
|
+
unit: 'ms' | 'score';
|
|
97
|
+
rating?: 'good' | 'needs_improvement' | 'poor';
|
|
98
|
+
navigationType?: string;
|
|
99
|
+
attribution?: JSONObject;
|
|
100
|
+
}
|
|
101
|
+
export interface NetworkPayload {
|
|
102
|
+
request: {
|
|
103
|
+
method: string;
|
|
104
|
+
url: string;
|
|
105
|
+
};
|
|
106
|
+
response?: {
|
|
107
|
+
status: number;
|
|
108
|
+
};
|
|
109
|
+
timing: {
|
|
110
|
+
start: number;
|
|
111
|
+
duration: number;
|
|
112
|
+
};
|
|
113
|
+
initiator: 'fetch' | 'xhr' | 'resource';
|
|
114
|
+
success: boolean;
|
|
115
|
+
}
|
|
116
|
+
export interface InteractionPayload {
|
|
117
|
+
target?: {
|
|
118
|
+
tag?: string;
|
|
119
|
+
id?: string;
|
|
120
|
+
role?: string;
|
|
121
|
+
selector?: string;
|
|
122
|
+
monitorId?: string;
|
|
123
|
+
};
|
|
124
|
+
coordinates?: {
|
|
125
|
+
x: number;
|
|
126
|
+
y: number;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface CustomEventPayload {
|
|
130
|
+
properties: JSONObject;
|
|
131
|
+
}
|
|
132
|
+
export interface SessionPayload {
|
|
133
|
+
action: 'start' | 'end';
|
|
134
|
+
duration?: number;
|
|
135
|
+
}
|
|
136
|
+
export interface PagePayload {
|
|
137
|
+
action: 'view' | 'route_change' | 'leave';
|
|
138
|
+
from?: string;
|
|
139
|
+
to?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface EventPayloadByType {
|
|
142
|
+
session: SessionPayload;
|
|
143
|
+
page: PagePayload;
|
|
144
|
+
error: ErrorPayload;
|
|
145
|
+
performance: PerformancePayload;
|
|
146
|
+
network: NetworkPayload;
|
|
147
|
+
interaction: InteractionPayload;
|
|
148
|
+
custom: CustomEventPayload;
|
|
149
|
+
}
|
|
150
|
+
type SpectroEventOfType<TType extends EventType> = {
|
|
151
|
+
id: string;
|
|
152
|
+
type: TType;
|
|
153
|
+
name: string;
|
|
154
|
+
version: typeof EVENT_VERSION;
|
|
155
|
+
timestamp: number;
|
|
156
|
+
context: EventContext;
|
|
157
|
+
payload: EventPayloadByType[TType];
|
|
158
|
+
};
|
|
159
|
+
export type SpectroEvent<TType extends EventType = EventType> = TType extends EventType ? SpectroEventOfType<TType> : never;
|
|
160
|
+
export interface EventEnvelopeItem {
|
|
161
|
+
type: 'event';
|
|
162
|
+
payload: SpectroEvent;
|
|
163
|
+
}
|
|
164
|
+
export interface Envelope {
|
|
165
|
+
version: typeof ENVELOPE_VERSION;
|
|
166
|
+
sentAt: number;
|
|
167
|
+
items: EventEnvelopeItem[];
|
|
168
|
+
}
|
|
169
|
+
export {};
|
|
170
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,EAAG,CAAU,CAAC;AACxC,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAC3C,eAAO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OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,gBAAgB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const EVENT_VERSION = 1;
|
|
2
|
+
export const ENVELOPE_VERSION = 1;
|
|
3
|
+
export const EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
4
|
+
export const MAX_EVENT_BYTES = 64 * 1024;
|
|
5
|
+
export const MAX_ENVELOPE_BYTES = 1024 * 1024;
|
|
6
|
+
export const MAX_JSON_DEPTH = 5;
|
|
7
|
+
export const MAX_ENVELOPE_STRUCTURE_DEPTH = 16;
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAU,CAAC;AACxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Envelope, SpectroEvent } from './types.js';
|
|
2
|
+
export interface ValidationIssue {
|
|
3
|
+
path: string;
|
|
4
|
+
keyword: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export type ValidationResult<T> = {
|
|
8
|
+
success: true;
|
|
9
|
+
data: T;
|
|
10
|
+
} | {
|
|
11
|
+
success: false;
|
|
12
|
+
issues: ValidationIssue[];
|
|
13
|
+
};
|
|
14
|
+
export declare function validateEvent(input: unknown): ValidationResult<SpectroEvent>;
|
|
15
|
+
export declare function validateEnvelope(input: unknown): ValidationResult<Envelope>;
|
|
16
|
+
export declare function serializedByteLength(value: unknown): number;
|
|
17
|
+
export declare function isJsonDepthWithin(value: unknown, maxDepth: number, depth?: number): boolean;
|
|
18
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGzD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC;AA8DlD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC,YAAY,CAAC,CAU5E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAa3E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CA0BtF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
2
|
+
import commonSchema from '../schemas/common.schema.json' with { type: 'json' };
|
|
3
|
+
import customSchema from '../schemas/custom.schema.json' with { type: 'json' };
|
|
4
|
+
import envelopeSchema from '../schemas/envelope.schema.json' with { type: 'json' };
|
|
5
|
+
import errorSchema from '../schemas/error.schema.json' with { type: 'json' };
|
|
6
|
+
import eventSchema from '../schemas/event.schema.json' with { type: 'json' };
|
|
7
|
+
import interactionSchema from '../schemas/interaction.schema.json' with { type: 'json' };
|
|
8
|
+
import networkSchema from '../schemas/network.schema.json' with { type: 'json' };
|
|
9
|
+
import pageSchema from '../schemas/page.schema.json' with { type: 'json' };
|
|
10
|
+
import performanceSchema from '../schemas/performance.schema.json' with { type: 'json' };
|
|
11
|
+
import sessionSchema from '../schemas/session.schema.json' with { type: 'json' };
|
|
12
|
+
import { MAX_ENVELOPE_STRUCTURE_DEPTH, MAX_JSON_DEPTH } from './types.js';
|
|
13
|
+
const ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
14
|
+
for (const schema of [
|
|
15
|
+
commonSchema,
|
|
16
|
+
customSchema,
|
|
17
|
+
errorSchema,
|
|
18
|
+
performanceSchema,
|
|
19
|
+
networkSchema,
|
|
20
|
+
interactionSchema,
|
|
21
|
+
sessionSchema,
|
|
22
|
+
pageSchema,
|
|
23
|
+
eventSchema,
|
|
24
|
+
envelopeSchema,
|
|
25
|
+
]) {
|
|
26
|
+
ajv.addSchema(schema);
|
|
27
|
+
}
|
|
28
|
+
const eventValidator = ajv.getSchema(eventSchema.$id);
|
|
29
|
+
const envelopeValidator = ajv.getSchema(envelopeSchema.$id);
|
|
30
|
+
function toIssues(errors) {
|
|
31
|
+
return (errors ?? []).map((error) => ({
|
|
32
|
+
path: error.instancePath || '/',
|
|
33
|
+
keyword: error.keyword,
|
|
34
|
+
message: error.message ?? 'is invalid',
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
function runValidation(validator, input) {
|
|
38
|
+
if (validator(input)) {
|
|
39
|
+
return { success: true, data: input };
|
|
40
|
+
}
|
|
41
|
+
return { success: false, issues: toIssues(validator.errors) };
|
|
42
|
+
}
|
|
43
|
+
function maxDepthIssue(message) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
issues: [{ path: '/', keyword: 'maxDepth', message }],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function recursiveJsonFieldsAreBounded(event) {
|
|
50
|
+
if (event.context.user?.traits && !isJsonDepthWithin(event.context.user.traits, MAX_JSON_DEPTH)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (event.type === 'custom' && !isJsonDepthWithin(event.payload.properties, MAX_JSON_DEPTH)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (event.type === 'performance' &&
|
|
57
|
+
event.payload.attribution &&
|
|
58
|
+
!isJsonDepthWithin(event.payload.attribution, MAX_JSON_DEPTH)) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
export function validateEvent(input) {
|
|
64
|
+
if (!isJsonDepthWithin(input, MAX_ENVELOPE_STRUCTURE_DEPTH)) {
|
|
65
|
+
return maxDepthIssue('exceeds the maximum structural depth');
|
|
66
|
+
}
|
|
67
|
+
const result = runValidation(eventValidator, input);
|
|
68
|
+
if (result.success && !recursiveJsonFieldsAreBounded(result.data)) {
|
|
69
|
+
return maxDepthIssue(`contains a recursive JSON field deeper than ${MAX_JSON_DEPTH}`);
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
export function validateEnvelope(input) {
|
|
74
|
+
if (!isJsonDepthWithin(input, MAX_ENVELOPE_STRUCTURE_DEPTH)) {
|
|
75
|
+
return maxDepthIssue('exceeds the maximum structural depth');
|
|
76
|
+
}
|
|
77
|
+
const result = runValidation(envelopeValidator, input);
|
|
78
|
+
if (result.success &&
|
|
79
|
+
result.data.items.some((item) => !recursiveJsonFieldsAreBounded(item.payload))) {
|
|
80
|
+
return maxDepthIssue(`contains a recursive JSON field deeper than ${MAX_JSON_DEPTH}`);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
export function serializedByteLength(value) {
|
|
85
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
86
|
+
}
|
|
87
|
+
export function isJsonDepthWithin(value, maxDepth, depth = 0) {
|
|
88
|
+
const pending = [{ depth, value }];
|
|
89
|
+
const seen = new WeakSet();
|
|
90
|
+
while (pending.length > 0) {
|
|
91
|
+
const current = pending.pop();
|
|
92
|
+
if (!current || current.value === null || typeof current.value !== 'object') {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (seen.has(current.value)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
seen.add(current.value);
|
|
99
|
+
const children = Object.values(current.value);
|
|
100
|
+
if (current.depth >= maxDepth && children.length > 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
for (const child of children) {
|
|
104
|
+
pending.push({ depth: current.depth + 1, value: child });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,kBAAkB,CAAC;AAEpF,OAAO,YAAY,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/E,OAAO,YAAY,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/E,OAAO,cAAc,MAAM,iCAAiC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACnF,OAAO,WAAW,MAAM,8BAA8B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7E,OAAO,WAAW,MAAM,8B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,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5E,SAAS;QACX,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExB,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,OAAO,CAAC,KAAK,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectro/protocol",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"homepage": "https://github.com/spectro-hq/spectro/tree/main/packages/protocol",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/spectro-hq/spectro.git",
|
|
9
|
+
"directory": "packages/protocol"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/**/*.test.*",
|
|
14
|
+
"!dist/.tsbuildinfo"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/src/index.d.ts",
|
|
21
|
+
"import": "./dist/src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./schemas/*": "./dist/schemas/*"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"registry": "https://registry.npmjs.org/",
|
|
28
|
+
"tag": "alpha"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"ajv": "^8.17.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^7.0.2",
|
|
35
|
+
"vitest": "^5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -b",
|
|
39
|
+
"check": "tsc -b --pretty false && tsc -p tsconfig.check.json --pretty false",
|
|
40
|
+
"test": "vitest run --exclude 'dist/**'"
|
|
41
|
+
}
|
|
6
42
|
}
|