@keystrokehq/posthog 0.0.1
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 +237 -0
- package/dist/_official/index.d.mts +2 -0
- package/dist/_official/index.mjs +3 -0
- package/dist/_runtime/index.d.mts +7 -0
- package/dist/_runtime/index.mjs +3 -0
- package/dist/actions.d.mts +244 -0
- package/dist/actions.mjs +129 -0
- package/dist/annotations.d.mts +185 -0
- package/dist/annotations.mjs +141 -0
- package/dist/capture.d.mts +177 -0
- package/dist/capture.mjs +241 -0
- package/dist/client.d.mts +51 -0
- package/dist/client.mjs +200 -0
- package/dist/cohorts.d.mts +229 -0
- package/dist/cohorts.mjs +185 -0
- package/dist/connection.d.mts +2 -0
- package/dist/connection.mjs +3 -0
- package/dist/dashboards.d.mts +434 -0
- package/dist/dashboards.mjs +356 -0
- package/dist/decide.d.mts +74 -0
- package/dist/decide.mjs +75 -0
- package/dist/errors.d.mts +58 -0
- package/dist/errors.mjs +120 -0
- package/dist/events-management.d.mts +294 -0
- package/dist/events-management.mjs +242 -0
- package/dist/factory-DYDvHOGb.mjs +8 -0
- package/dist/feature-flags.d.mts +416 -0
- package/dist/feature-flags.mjs +317 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/insights.d.mts +409 -0
- package/dist/insights.mjs +346 -0
- package/dist/integration-CsCBBu4d.d.mts +53 -0
- package/dist/integration-Doy2Dwli.mjs +30 -0
- package/dist/organizations.d.mts +257 -0
- package/dist/organizations.mjs +219 -0
- package/dist/persons.d.mts +369 -0
- package/dist/persons.mjs +345 -0
- package/dist/projects.d.mts +348 -0
- package/dist/projects.mjs +287 -0
- package/dist/schemas.d.mts +351 -0
- package/dist/schemas.mjs +302 -0
- package/dist/session-recordings.d.mts +391 -0
- package/dist/session-recordings.mjs +308 -0
- package/dist/surveys.d.mts +287 -0
- package/dist/surveys.mjs +208 -0
- package/dist/triggers.d.mts +115 -0
- package/dist/triggers.mjs +330 -0
- package/dist/webhook-management.d.mts +188 -0
- package/dist/webhook-management.mjs +152 -0
- package/package.json +147 -0
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/schemas.ts
|
|
4
|
+
/**
|
|
5
|
+
* posthog/schemas.ts
|
|
6
|
+
*
|
|
7
|
+
* Shared Zod schemas and inferred types for PostHog resources.
|
|
8
|
+
* Types are inferred from schemas, never duplicated.
|
|
9
|
+
*
|
|
10
|
+
* In Zod v4 objects already allow unknown keys, so provider-opaque
|
|
11
|
+
* properties parse naturally without needing `.passthrough()`.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* PostHog's standard cursor-paginated list envelope: `next`/`previous` are
|
|
15
|
+
* absolute URLs, `count` is the total, and `results` carries the page.
|
|
16
|
+
*/
|
|
17
|
+
const paginatedResponseSchema = (itemSchema) => z.object({
|
|
18
|
+
next: z.string().nullable(),
|
|
19
|
+
previous: z.string().nullable(),
|
|
20
|
+
count: z.number().int(),
|
|
21
|
+
results: z.array(itemSchema)
|
|
22
|
+
});
|
|
23
|
+
/** Optional project id override parameter used by most management operations. */
|
|
24
|
+
const projectIdInputShape = { projectId: z.union([z.string(), z.number().int()]).optional() };
|
|
25
|
+
/** `properties` bag — provider-opaque; we intentionally parse as unknown. */
|
|
26
|
+
const propertiesBagSchema = z.record(z.string(), z.unknown());
|
|
27
|
+
const personSchema = z.object({
|
|
28
|
+
id: z.union([z.number().int(), z.string()]).optional(),
|
|
29
|
+
uuid: z.string().optional(),
|
|
30
|
+
distinct_ids: z.array(z.string()).optional(),
|
|
31
|
+
properties: propertiesBagSchema.optional(),
|
|
32
|
+
name: z.string().nullable().optional(),
|
|
33
|
+
created_at: z.string().optional(),
|
|
34
|
+
is_identified: z.boolean().optional()
|
|
35
|
+
});
|
|
36
|
+
const cohortSchema = z.object({
|
|
37
|
+
id: z.number().int().optional(),
|
|
38
|
+
name: z.string().optional(),
|
|
39
|
+
description: z.string().nullable().optional(),
|
|
40
|
+
groups: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
41
|
+
is_static: z.boolean().optional(),
|
|
42
|
+
is_calculating: z.boolean().optional(),
|
|
43
|
+
count: z.number().int().nullable().optional(),
|
|
44
|
+
created_at: z.string().optional(),
|
|
45
|
+
deleted: z.boolean().optional()
|
|
46
|
+
});
|
|
47
|
+
const featureFlagFiltersSchema = z.object({
|
|
48
|
+
groups: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
49
|
+
multivariate: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
50
|
+
payloads: z.record(z.string(), z.unknown()).optional()
|
|
51
|
+
});
|
|
52
|
+
const featureFlagSchema = z.object({
|
|
53
|
+
id: z.number().int().optional(),
|
|
54
|
+
key: z.string(),
|
|
55
|
+
name: z.string().optional(),
|
|
56
|
+
filters: featureFlagFiltersSchema.optional(),
|
|
57
|
+
deleted: z.boolean().optional(),
|
|
58
|
+
active: z.boolean().optional(),
|
|
59
|
+
created_at: z.string().optional(),
|
|
60
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
61
|
+
ensure_experience_continuity: z.boolean().optional(),
|
|
62
|
+
rollout_percentage: z.number().nullable().optional(),
|
|
63
|
+
version: z.number().int().optional()
|
|
64
|
+
});
|
|
65
|
+
const featureFlagRoleAccessSchema = z.object({
|
|
66
|
+
id: z.number().int().optional(),
|
|
67
|
+
feature_flag: z.number().int().optional(),
|
|
68
|
+
role: z.number().int().optional(),
|
|
69
|
+
added_at: z.string().optional()
|
|
70
|
+
});
|
|
71
|
+
const experimentSchema = z.object({
|
|
72
|
+
id: z.number().int().optional(),
|
|
73
|
+
name: z.string().optional(),
|
|
74
|
+
description: z.string().nullable().optional(),
|
|
75
|
+
start_date: z.string().nullable().optional(),
|
|
76
|
+
end_date: z.string().nullable().optional(),
|
|
77
|
+
feature_flag_key: z.string().optional(),
|
|
78
|
+
parameters: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
79
|
+
filters: z.record(z.string(), z.unknown()).optional(),
|
|
80
|
+
archived: z.boolean().optional(),
|
|
81
|
+
created_at: z.string().optional()
|
|
82
|
+
});
|
|
83
|
+
const insightSchema = z.object({
|
|
84
|
+
id: z.number().int().optional(),
|
|
85
|
+
short_id: z.string().optional(),
|
|
86
|
+
name: z.string().nullable().optional(),
|
|
87
|
+
description: z.string().nullable().optional(),
|
|
88
|
+
filters: z.record(z.string(), z.unknown()).optional(),
|
|
89
|
+
query: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
90
|
+
result: z.unknown().optional(),
|
|
91
|
+
last_refresh: z.string().nullable().optional(),
|
|
92
|
+
favorited: z.boolean().optional(),
|
|
93
|
+
saved: z.boolean().optional(),
|
|
94
|
+
created_at: z.string().optional(),
|
|
95
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
96
|
+
deleted: z.boolean().optional(),
|
|
97
|
+
dashboards: z.array(z.number().int()).optional(),
|
|
98
|
+
tags: z.array(z.string()).optional()
|
|
99
|
+
});
|
|
100
|
+
const dashboardSchema = z.object({
|
|
101
|
+
id: z.number().int().optional(),
|
|
102
|
+
name: z.string().optional(),
|
|
103
|
+
description: z.string().nullable().optional(),
|
|
104
|
+
pinned: z.boolean().optional(),
|
|
105
|
+
created_at: z.string().optional(),
|
|
106
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
107
|
+
deleted: z.boolean().optional(),
|
|
108
|
+
tags: z.array(z.string()).optional(),
|
|
109
|
+
tiles: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
110
|
+
filters: z.record(z.string(), z.unknown()).optional()
|
|
111
|
+
});
|
|
112
|
+
const dashboardTemplateSchema = z.object({
|
|
113
|
+
id: z.string().optional(),
|
|
114
|
+
template_name: z.string().optional(),
|
|
115
|
+
dashboard_description: z.string().nullable().optional(),
|
|
116
|
+
dashboard_filters: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
117
|
+
tags: z.array(z.string()).optional(),
|
|
118
|
+
tiles: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
119
|
+
variables: z.array(z.record(z.string(), z.unknown())).nullable().optional(),
|
|
120
|
+
deleted: z.boolean().optional()
|
|
121
|
+
});
|
|
122
|
+
const dashboardCollaboratorSchema = z.object({
|
|
123
|
+
id: z.number().int().optional(),
|
|
124
|
+
dashboard_id: z.number().int().optional(),
|
|
125
|
+
user_uuid: z.string().optional(),
|
|
126
|
+
access_level: z.enum(["can_view", "can_edit"]).optional(),
|
|
127
|
+
added_at: z.string().optional()
|
|
128
|
+
});
|
|
129
|
+
const sharingConfigurationSchema = z.object({
|
|
130
|
+
enabled: z.boolean().optional(),
|
|
131
|
+
access_token: z.string().nullable().optional(),
|
|
132
|
+
created_at: z.string().nullable().optional()
|
|
133
|
+
});
|
|
134
|
+
const annotationSchema = z.object({
|
|
135
|
+
id: z.number().int().optional(),
|
|
136
|
+
content: z.string().optional(),
|
|
137
|
+
date_marker: z.string().optional(),
|
|
138
|
+
creation_type: z.string().optional(),
|
|
139
|
+
dashboard_item: z.number().int().nullable().optional(),
|
|
140
|
+
insight_short_id: z.string().nullable().optional(),
|
|
141
|
+
insight_name: z.string().nullable().optional(),
|
|
142
|
+
created_at: z.string().optional(),
|
|
143
|
+
updated_at: z.string().optional(),
|
|
144
|
+
scope: z.enum([
|
|
145
|
+
"dashboard_item",
|
|
146
|
+
"project",
|
|
147
|
+
"organization"
|
|
148
|
+
]).optional(),
|
|
149
|
+
deleted: z.boolean().optional()
|
|
150
|
+
});
|
|
151
|
+
const sessionRecordingSchema = z.object({
|
|
152
|
+
id: z.string().optional(),
|
|
153
|
+
distinct_id: z.string().optional(),
|
|
154
|
+
viewed: z.boolean().optional(),
|
|
155
|
+
recording_duration: z.number().optional(),
|
|
156
|
+
start_time: z.string().optional(),
|
|
157
|
+
end_time: z.string().optional(),
|
|
158
|
+
click_count: z.number().int().nullable().optional(),
|
|
159
|
+
keypress_count: z.number().int().nullable().optional(),
|
|
160
|
+
mouse_activity_count: z.number().int().nullable().optional(),
|
|
161
|
+
person: personSchema.nullable().optional()
|
|
162
|
+
});
|
|
163
|
+
const sessionRecordingPlaylistSchema = z.object({
|
|
164
|
+
id: z.number().int().optional(),
|
|
165
|
+
short_id: z.string().optional(),
|
|
166
|
+
name: z.string().nullable().optional(),
|
|
167
|
+
description: z.string().nullable().optional(),
|
|
168
|
+
pinned: z.boolean().optional(),
|
|
169
|
+
deleted: z.boolean().optional(),
|
|
170
|
+
filters: z.record(z.string(), z.unknown()).optional(),
|
|
171
|
+
created_at: z.string().optional(),
|
|
172
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional()
|
|
173
|
+
});
|
|
174
|
+
const surveySchema = z.object({
|
|
175
|
+
id: z.string().optional(),
|
|
176
|
+
name: z.string().optional(),
|
|
177
|
+
description: z.string().nullable().optional(),
|
|
178
|
+
type: z.enum([
|
|
179
|
+
"popover",
|
|
180
|
+
"api",
|
|
181
|
+
"widget",
|
|
182
|
+
"button",
|
|
183
|
+
"full_screen",
|
|
184
|
+
"email"
|
|
185
|
+
]).optional(),
|
|
186
|
+
questions: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
187
|
+
conditions: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
188
|
+
appearance: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
189
|
+
targeting_flag: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
190
|
+
start_date: z.string().nullable().optional(),
|
|
191
|
+
end_date: z.string().nullable().optional(),
|
|
192
|
+
responses_limit: z.number().int().nullable().optional(),
|
|
193
|
+
archived: z.boolean().optional(),
|
|
194
|
+
created_at: z.string().optional(),
|
|
195
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional()
|
|
196
|
+
});
|
|
197
|
+
const actionStepSchema = z.object({
|
|
198
|
+
event: z.string().nullable().optional(),
|
|
199
|
+
url: z.string().nullable().optional(),
|
|
200
|
+
url_matching: z.enum([
|
|
201
|
+
"contains",
|
|
202
|
+
"regex",
|
|
203
|
+
"exact"
|
|
204
|
+
]).nullable().optional(),
|
|
205
|
+
text: z.string().nullable().optional(),
|
|
206
|
+
href: z.string().nullable().optional(),
|
|
207
|
+
selector: z.string().nullable().optional(),
|
|
208
|
+
properties: z.array(z.record(z.string(), z.unknown())).nullable().optional()
|
|
209
|
+
});
|
|
210
|
+
const actionSchema = z.object({
|
|
211
|
+
id: z.number().int().optional(),
|
|
212
|
+
name: z.string().nullable().optional(),
|
|
213
|
+
description: z.string().nullable().optional(),
|
|
214
|
+
post_to_slack: z.boolean().optional(),
|
|
215
|
+
slack_message_format: z.string().nullable().optional(),
|
|
216
|
+
steps: z.array(actionStepSchema).optional(),
|
|
217
|
+
created_at: z.string().optional(),
|
|
218
|
+
created_by: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
219
|
+
deleted: z.boolean().optional(),
|
|
220
|
+
is_calculating: z.boolean().optional()
|
|
221
|
+
});
|
|
222
|
+
const analyticsEventSchema = z.object({
|
|
223
|
+
id: z.string().optional(),
|
|
224
|
+
uuid: z.string().optional(),
|
|
225
|
+
distinct_id: z.string().optional(),
|
|
226
|
+
event: z.string().optional(),
|
|
227
|
+
properties: propertiesBagSchema.optional(),
|
|
228
|
+
timestamp: z.string().optional(),
|
|
229
|
+
person: personSchema.nullable().optional(),
|
|
230
|
+
elements: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
231
|
+
elements_chain: z.string().nullable().optional()
|
|
232
|
+
});
|
|
233
|
+
const eventDefinitionSchema = z.object({
|
|
234
|
+
id: z.string().optional(),
|
|
235
|
+
name: z.string().optional(),
|
|
236
|
+
description: z.string().nullable().optional(),
|
|
237
|
+
tags: z.array(z.string()).optional(),
|
|
238
|
+
owner: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
239
|
+
verified: z.boolean().optional(),
|
|
240
|
+
verified_at: z.string().nullable().optional(),
|
|
241
|
+
created_at: z.string().optional()
|
|
242
|
+
});
|
|
243
|
+
const projectSchema = z.object({
|
|
244
|
+
id: z.number().int().optional(),
|
|
245
|
+
uuid: z.string().optional(),
|
|
246
|
+
organization: z.string().optional(),
|
|
247
|
+
name: z.string().optional(),
|
|
248
|
+
api_token: z.string().optional(),
|
|
249
|
+
created_at: z.string().optional(),
|
|
250
|
+
app_urls: z.array(z.string()).optional(),
|
|
251
|
+
slack_incoming_webhook: z.string().nullable().optional(),
|
|
252
|
+
anonymize_ips: z.boolean().optional(),
|
|
253
|
+
completed_snippet_onboarding: z.boolean().optional(),
|
|
254
|
+
test_account_filters: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
255
|
+
is_demo: z.boolean().optional(),
|
|
256
|
+
timezone: z.string().optional(),
|
|
257
|
+
access_control: z.boolean().optional()
|
|
258
|
+
});
|
|
259
|
+
const projectMemberSchema = z.object({
|
|
260
|
+
id: z.number().int().optional(),
|
|
261
|
+
user: z.record(z.string(), z.unknown()).optional(),
|
|
262
|
+
level: z.number().int().optional(),
|
|
263
|
+
parent_level: z.number().int().nullable().optional(),
|
|
264
|
+
joined_at: z.string().optional(),
|
|
265
|
+
updated_at: z.string().optional()
|
|
266
|
+
});
|
|
267
|
+
const organizationSchema = z.object({
|
|
268
|
+
id: z.string().optional(),
|
|
269
|
+
name: z.string().optional(),
|
|
270
|
+
slug: z.string().optional(),
|
|
271
|
+
created_at: z.string().optional(),
|
|
272
|
+
updated_at: z.string().optional(),
|
|
273
|
+
membership_level: z.number().int().nullable().optional(),
|
|
274
|
+
plugins_access_level: z.number().int().optional(),
|
|
275
|
+
teams: z.array(z.record(z.string(), z.unknown())).optional()
|
|
276
|
+
});
|
|
277
|
+
const captureResponseSchema = z.object({ status: z.union([
|
|
278
|
+
z.literal(1),
|
|
279
|
+
z.literal("ok"),
|
|
280
|
+
z.number().int(),
|
|
281
|
+
z.string()
|
|
282
|
+
]).optional() });
|
|
283
|
+
const decideResponseSchema = z.object({
|
|
284
|
+
config: z.record(z.string(), z.unknown()).optional(),
|
|
285
|
+
featureFlags: z.record(z.string(), z.union([
|
|
286
|
+
z.boolean(),
|
|
287
|
+
z.string(),
|
|
288
|
+
z.number()
|
|
289
|
+
])).optional(),
|
|
290
|
+
featureFlagPayloads: z.record(z.string(), z.unknown()).optional(),
|
|
291
|
+
errorsWhileComputingFlags: z.boolean().optional(),
|
|
292
|
+
toolbarParams: z.record(z.string(), z.unknown()).optional(),
|
|
293
|
+
sessionRecording: z.union([z.boolean(), z.record(z.string(), z.unknown())]).optional()
|
|
294
|
+
});
|
|
295
|
+
const localEvaluationResponseSchema = z.object({
|
|
296
|
+
flags: z.array(featureFlagSchema).optional(),
|
|
297
|
+
group_type_mapping: z.record(z.string(), z.unknown()).optional(),
|
|
298
|
+
cohorts: z.record(z.string(), z.unknown()).optional()
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
export { actionSchema, actionStepSchema, analyticsEventSchema, annotationSchema, captureResponseSchema, cohortSchema, dashboardCollaboratorSchema, dashboardSchema, dashboardTemplateSchema, decideResponseSchema, eventDefinitionSchema, experimentSchema, featureFlagFiltersSchema, featureFlagRoleAccessSchema, featureFlagSchema, insightSchema, localEvaluationResponseSchema, organizationSchema, paginatedResponseSchema, personSchema, projectIdInputShape, projectMemberSchema, projectSchema, propertiesBagSchema, sessionRecordingPlaylistSchema, sessionRecordingSchema, sharingConfigurationSchema, surveySchema };
|