@keystrokehq/segment 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.
Files changed (74) hide show
  1. package/README.md +232 -0
  2. package/dist/_official/index.d.mts +2 -0
  3. package/dist/_official/index.mjs +3 -0
  4. package/dist/_runtime/index.d.mts +1 -0
  5. package/dist/_runtime/index.mjs +1 -0
  6. package/dist/audiences.d.mts +282 -0
  7. package/dist/audiences.mjs +205 -0
  8. package/dist/client.d.mts +90 -0
  9. package/dist/client.mjs +337 -0
  10. package/dist/common-CdGiJbjq.mjs +56 -0
  11. package/dist/computed-traits.d.mts +215 -0
  12. package/dist/computed-traits.mjs +149 -0
  13. package/dist/connection.d.mts +2 -0
  14. package/dist/connection.mjs +3 -0
  15. package/dist/crud-SWa_79Hg.mjs +140 -0
  16. package/dist/deletion-suppression.d.mts +191 -0
  17. package/dist/deletion-suppression.mjs +103 -0
  18. package/dist/delivery-overview.d.mts +79 -0
  19. package/dist/delivery-overview.mjs +54 -0
  20. package/dist/destination-filters.d.mts +190 -0
  21. package/dist/destination-filters.mjs +115 -0
  22. package/dist/destinations.d.mts +473 -0
  23. package/dist/destinations.mjs +257 -0
  24. package/dist/edge-functions.d.mts +168 -0
  25. package/dist/edge-functions.mjs +72 -0
  26. package/dist/errors-4FGnrowW.mjs +27 -0
  27. package/dist/events-catalog.d.mts +111 -0
  28. package/dist/events-catalog.mjs +65 -0
  29. package/dist/events.d.mts +167 -0
  30. package/dist/events.mjs +134 -0
  31. package/dist/factory-CvfKfzMq.mjs +8 -0
  32. package/dist/functions.d.mts +347 -0
  33. package/dist/functions.mjs +180 -0
  34. package/dist/iam-groups.d.mts +284 -0
  35. package/dist/iam-groups.mjs +144 -0
  36. package/dist/iam-users.d.mts +205 -0
  37. package/dist/iam-users.mjs +91 -0
  38. package/dist/index.d.mts +1 -0
  39. package/dist/index.mjs +1 -0
  40. package/dist/integration-B5zYasBZ.mjs +25 -0
  41. package/dist/integration-D2yRaKFR.d.mts +67 -0
  42. package/dist/labels.d.mts +100 -0
  43. package/dist/labels.mjs +58 -0
  44. package/dist/monitoring.d.mts +182 -0
  45. package/dist/monitoring.mjs +88 -0
  46. package/dist/profiles-sync.d.mts +127 -0
  47. package/dist/profiles-sync.mjs +89 -0
  48. package/dist/profiles.d.mts +197 -0
  49. package/dist/profiles.mjs +137 -0
  50. package/dist/reverse-etl.d.mts +448 -0
  51. package/dist/reverse-etl.mjs +228 -0
  52. package/dist/roles.d.mts +48 -0
  53. package/dist/roles.mjs +25 -0
  54. package/dist/schemas/index.d.mts +57 -0
  55. package/dist/schemas/index.mjs +3 -0
  56. package/dist/sources.d.mts +560 -0
  57. package/dist/sources.mjs +259 -0
  58. package/dist/tracking-plans.d.mts +351 -0
  59. package/dist/tracking-plans.mjs +160 -0
  60. package/dist/tracking.d.mts +499 -0
  61. package/dist/tracking.mjs +255 -0
  62. package/dist/transformations.d.mts +188 -0
  63. package/dist/transformations.mjs +83 -0
  64. package/dist/triggers.d.mts +54 -0
  65. package/dist/triggers.mjs +341 -0
  66. package/dist/usage.d.mts +70 -0
  67. package/dist/usage.mjs +55 -0
  68. package/dist/verification.d.mts +17 -0
  69. package/dist/verification.mjs +51 -0
  70. package/dist/warehouses.d.mts +341 -0
  71. package/dist/warehouses.mjs +176 -0
  72. package/dist/workspaces.d.mts +95 -0
  73. package/dist/workspaces.mjs +67 -0
  74. package/package.json +188 -0
@@ -0,0 +1,255 @@
1
+ import { createSegmentClient } from "./client.mjs";
2
+ import { t as segmentOperation } from "./factory-CvfKfzMq.mjs";
3
+ import { z } from "zod";
4
+
5
+ //#region src/tracking.ts
6
+ /**
7
+ * segment/tracking.ts
8
+ *
9
+ * Tracking API operations: `identify`, `track`, `page`, `screen`, `group`,
10
+ * `alias`, `batch`, `import`. Every call routes through
11
+ * `client.tracking.send` (or `.batch` for the bulk envelope), which:
12
+ *
13
+ * - resolves the per-source write key from `SEGMENT_WRITE_KEYS_JSON`
14
+ * (when `sourceId` is provided) or `SEGMENT_DEFAULT_WRITE_KEY`;
15
+ * - enforces the 32 KB-per-event and 500 KB-per-batch hard limits Segment
16
+ * documents at
17
+ * https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/.
18
+ *
19
+ * `import` is sugar: Segment's public HTTP API does not document a
20
+ * `/v1/import` endpoint (historical imports are sent as backdated `track` or
21
+ * `batch` calls). We expose the action so authors keep the intent-based id
22
+ * but implement it as `POST /v1/track` with a required `timestamp` and
23
+ * populated `sentAt`.
24
+ */
25
+ const contextSchema = z.object({
26
+ active: z.boolean().optional(),
27
+ app: z.record(z.string(), z.unknown()).optional(),
28
+ campaign: z.record(z.string(), z.unknown()).optional(),
29
+ device: z.record(z.string(), z.unknown()).optional(),
30
+ ip: z.string().optional(),
31
+ library: z.record(z.string(), z.unknown()).optional(),
32
+ locale: z.string().optional(),
33
+ location: z.record(z.string(), z.unknown()).optional(),
34
+ network: z.record(z.string(), z.unknown()).optional(),
35
+ os: z.record(z.string(), z.unknown()).optional(),
36
+ page: z.record(z.string(), z.unknown()).optional(),
37
+ referrer: z.record(z.string(), z.unknown()).optional(),
38
+ screen: z.record(z.string(), z.unknown()).optional(),
39
+ timezone: z.string().optional(),
40
+ userAgent: z.string().optional()
41
+ }).catchall(z.unknown());
42
+ const integrationsSchema = z.record(z.string(), z.unknown());
43
+ const idFieldsSchema = z.object({
44
+ userId: z.string().min(1).optional(),
45
+ anonymousId: z.string().min(1).optional(),
46
+ messageId: z.string().min(1).optional(),
47
+ timestamp: z.iso.datetime({ offset: true }).optional()
48
+ }).refine((v) => Boolean(v.userId) || Boolean(v.anonymousId), { message: "identify/track/… require either userId or anonymousId." });
49
+ const commonEnvelopeSchema = z.object({
50
+ context: contextSchema.optional(),
51
+ integrations: integrationsSchema.optional(),
52
+ sourceId: z.string().min(1).optional()
53
+ });
54
+ const sendResponseSchema = z.object({
55
+ sent: z.boolean(),
56
+ method: z.enum([
57
+ "identify",
58
+ "track",
59
+ "page",
60
+ "screen",
61
+ "group",
62
+ "alias"
63
+ ])
64
+ });
65
+ function toPayload(value) {
66
+ const out = {};
67
+ for (const [k, v] of Object.entries(value)) {
68
+ if (v === void 0) continue;
69
+ out[k] = v;
70
+ }
71
+ return out;
72
+ }
73
+ const identifyInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({ traits: z.record(z.string(), z.unknown()).optional() }));
74
+ const identify = segmentOperation({
75
+ id: "segment.tracking.identify",
76
+ name: "Identify user",
77
+ description: "Associate a user with an identity and set/update traits.",
78
+ input: identifyInputSchema,
79
+ output: sendResponseSchema,
80
+ needsApproval: true,
81
+ run: async (input, credentials) => {
82
+ const client = createSegmentClient(credentials);
83
+ const { sourceId, ...rest } = input;
84
+ await client.tracking.send("identify", toPayload(rest), { sourceId });
85
+ return {
86
+ sent: true,
87
+ method: "identify"
88
+ };
89
+ }
90
+ });
91
+ const trackInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({
92
+ event: z.string().min(1),
93
+ properties: z.record(z.string(), z.unknown()).optional()
94
+ }));
95
+ const track = segmentOperation({
96
+ id: "segment.tracking.track",
97
+ name: "Track event",
98
+ description: "Record an arbitrary event for a user or anonymous profile.",
99
+ input: trackInputSchema,
100
+ output: sendResponseSchema,
101
+ needsApproval: true,
102
+ run: async (input, credentials) => {
103
+ const client = createSegmentClient(credentials);
104
+ const { sourceId, ...rest } = input;
105
+ await client.tracking.send("track", toPayload(rest), { sourceId });
106
+ return {
107
+ sent: true,
108
+ method: "track"
109
+ };
110
+ }
111
+ });
112
+ const pageInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({
113
+ name: z.string().min(1).optional(),
114
+ category: z.string().min(1).optional(),
115
+ properties: z.record(z.string(), z.unknown()).optional()
116
+ }));
117
+ const page = segmentOperation({
118
+ id: "segment.tracking.page",
119
+ name: "Page view",
120
+ description: "Record a web page view.",
121
+ input: pageInputSchema,
122
+ output: sendResponseSchema,
123
+ needsApproval: true,
124
+ run: async (input, credentials) => {
125
+ const client = createSegmentClient(credentials);
126
+ const { sourceId, ...rest } = input;
127
+ await client.tracking.send("page", toPayload(rest), { sourceId });
128
+ return {
129
+ sent: true,
130
+ method: "page"
131
+ };
132
+ }
133
+ });
134
+ const screenInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({
135
+ name: z.string().min(1).optional(),
136
+ category: z.string().min(1).optional(),
137
+ properties: z.record(z.string(), z.unknown()).optional()
138
+ }));
139
+ const screen = segmentOperation({
140
+ id: "segment.tracking.screen",
141
+ name: "Mobile screen view",
142
+ description: "Record a mobile app screen view.",
143
+ input: screenInputSchema,
144
+ output: sendResponseSchema,
145
+ needsApproval: true,
146
+ run: async (input, credentials) => {
147
+ const client = createSegmentClient(credentials);
148
+ const { sourceId, ...rest } = input;
149
+ await client.tracking.send("screen", toPayload(rest), { sourceId });
150
+ return {
151
+ sent: true,
152
+ method: "screen"
153
+ };
154
+ }
155
+ });
156
+ const groupInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({
157
+ groupId: z.string().min(1),
158
+ traits: z.record(z.string(), z.unknown()).optional()
159
+ }));
160
+ const group = segmentOperation({
161
+ id: "segment.tracking.group",
162
+ name: "Group user",
163
+ description: "Associate a user with a group (account, org, team) and set group traits.",
164
+ input: groupInputSchema,
165
+ output: sendResponseSchema,
166
+ needsApproval: true,
167
+ run: async (input, credentials) => {
168
+ const client = createSegmentClient(credentials);
169
+ const { sourceId, ...rest } = input;
170
+ await client.tracking.send("group", toPayload(rest), { sourceId });
171
+ return {
172
+ sent: true,
173
+ method: "group"
174
+ };
175
+ }
176
+ });
177
+ const aliasInputSchema = commonEnvelopeSchema.and(z.object({
178
+ userId: z.string().min(1),
179
+ previousId: z.string().min(1),
180
+ messageId: z.string().min(1).optional(),
181
+ timestamp: z.iso.datetime({ offset: true }).optional()
182
+ }));
183
+ const alias = segmentOperation({
184
+ id: "segment.tracking.alias",
185
+ name: "Alias user",
186
+ description: "Merge two user identities (previousId → userId). Note: many downstream destinations ignore alias calls; primarily used for warehouse identity resolution.",
187
+ input: aliasInputSchema,
188
+ output: sendResponseSchema,
189
+ needsApproval: true,
190
+ run: async (input, credentials) => {
191
+ const client = createSegmentClient(credentials);
192
+ const { sourceId, ...rest } = input;
193
+ await client.tracking.send("alias", toPayload(rest), { sourceId });
194
+ return {
195
+ sent: true,
196
+ method: "alias"
197
+ };
198
+ }
199
+ });
200
+ const batchEventSchema = z.object({ type: z.enum([
201
+ "identify",
202
+ "track",
203
+ "page",
204
+ "screen",
205
+ "group",
206
+ "alias"
207
+ ]) }).catchall(z.unknown());
208
+ const batchInputSchema = commonEnvelopeSchema.and(z.object({ events: z.array(batchEventSchema).min(1) }));
209
+ const batchOutputSchema = z.object({
210
+ chunksSent: z.number().int().nonnegative(),
211
+ rejected: z.array(batchEventSchema)
212
+ });
213
+ const batch = segmentOperation({
214
+ id: "segment.tracking.batch",
215
+ name: "Batch events",
216
+ description: "Send many tracking events in a single request (automatically split into multiple calls to respect Segment’s 500 KB-per-batch and 32 KB-per-event limits).",
217
+ input: batchInputSchema,
218
+ output: batchOutputSchema,
219
+ needsApproval: true,
220
+ run: async (input, credentials) => {
221
+ const result = await createSegmentClient(credentials).tracking.batch(input.events, { sourceId: input.sourceId });
222
+ return {
223
+ chunksSent: result.chunksSent,
224
+ rejected: [...result.rejected]
225
+ };
226
+ }
227
+ });
228
+ const importInputSchema = idFieldsSchema.and(commonEnvelopeSchema).and(z.object({
229
+ event: z.string().min(1),
230
+ properties: z.record(z.string(), z.unknown()).optional(),
231
+ timestamp: z.iso.datetime({ offset: true })
232
+ }));
233
+ const importEvent = segmentOperation({
234
+ id: "segment.tracking.import",
235
+ name: "Historical import",
236
+ description: "Send a backdated historical event. Segment has no dedicated import endpoint; we send a `track` call with the required `timestamp` and the current time as `sentAt`. Only destinations that accept historical data (warehouses, Mixpanel, Amplitude) will backfill.",
237
+ input: importInputSchema,
238
+ output: sendResponseSchema,
239
+ needsApproval: true,
240
+ run: async (input, credentials) => {
241
+ const client = createSegmentClient(credentials);
242
+ const { sourceId, ...rest } = input;
243
+ await client.tracking.send("track", toPayload({
244
+ ...rest,
245
+ sentAt: (/* @__PURE__ */ new Date()).toISOString()
246
+ }), { sourceId });
247
+ return {
248
+ sent: true,
249
+ method: "track"
250
+ };
251
+ }
252
+ });
253
+
254
+ //#endregion
255
+ export { alias, batch, group, identify, importEvent, page, screen, track };
@@ -0,0 +1,188 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
3
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
4
+
5
+ //#region src/transformations.d.ts
6
+ declare const transformationSchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ name: z.ZodOptional<z.ZodString>;
9
+ sourceId: z.ZodOptional<z.ZodString>;
10
+ destinationId: z.ZodOptional<z.ZodString>;
11
+ enabled: z.ZodOptional<z.ZodBoolean>;
12
+ if: z.ZodOptional<z.ZodString>;
13
+ newEventName: z.ZodOptional<z.ZodString>;
14
+ propertyRenames: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
15
+ propertyValueTransformations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
16
+ }, z.core.$catchall<z.ZodUnknown>>;
17
+ declare const listTransformations: _keystrokehq_core0.Operation<z.ZodIntersection<z.ZodObject<{
18
+ pageSize: z.ZodOptional<z.ZodNumber>;
19
+ pageToken: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
21
+ items: z.ZodArray<z.ZodObject<{
22
+ id: z.ZodString;
23
+ name: z.ZodOptional<z.ZodString>;
24
+ sourceId: z.ZodOptional<z.ZodString>;
25
+ destinationId: z.ZodOptional<z.ZodString>;
26
+ enabled: z.ZodOptional<z.ZodBoolean>;
27
+ if: z.ZodOptional<z.ZodString>;
28
+ newEventName: z.ZodOptional<z.ZodString>;
29
+ propertyRenames: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
30
+ propertyValueTransformations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
31
+ }, z.core.$catchall<z.ZodUnknown>>>;
32
+ nextPageToken: z.ZodOptional<z.ZodString>;
33
+ totalEntries: z.ZodOptional<z.ZodNumber>;
34
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
35
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
36
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
37
+ us: "us";
38
+ eu: "eu";
39
+ }>>;
40
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
41
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
42
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
43
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
44
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
46
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
47
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
48
+ us: "us";
49
+ eu: "eu";
50
+ }>>;
51
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
52
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
53
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
54
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
55
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
56
+ }, z.core.$strip>>[] | undefined>], undefined>;
57
+ declare const getTransformation: _keystrokehq_core0.Operation<z.ZodObject<{
58
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ id: z.ZodString;
61
+ name: z.ZodOptional<z.ZodString>;
62
+ sourceId: z.ZodOptional<z.ZodString>;
63
+ destinationId: z.ZodOptional<z.ZodString>;
64
+ enabled: z.ZodOptional<z.ZodBoolean>;
65
+ if: z.ZodOptional<z.ZodString>;
66
+ newEventName: z.ZodOptional<z.ZodString>;
67
+ propertyRenames: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
68
+ propertyValueTransformations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
69
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
70
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
71
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
72
+ us: "us";
73
+ eu: "eu";
74
+ }>>;
75
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
76
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
77
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
78
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
79
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
80
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
81
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
82
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
83
+ us: "us";
84
+ eu: "eu";
85
+ }>>;
86
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
87
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
88
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
89
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
90
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>>[] | undefined>], undefined>;
92
+ declare const createTransformation: _keystrokehq_core0.Operation<z.ZodObject<{
93
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ id: z.ZodString;
96
+ name: z.ZodOptional<z.ZodString>;
97
+ sourceId: z.ZodOptional<z.ZodString>;
98
+ destinationId: z.ZodOptional<z.ZodString>;
99
+ enabled: z.ZodOptional<z.ZodBoolean>;
100
+ if: z.ZodOptional<z.ZodString>;
101
+ newEventName: z.ZodOptional<z.ZodString>;
102
+ propertyRenames: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
103
+ propertyValueTransformations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
104
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
105
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
106
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
107
+ us: "us";
108
+ eu: "eu";
109
+ }>>;
110
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
111
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
112
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
113
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
114
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
115
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
116
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
117
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
118
+ us: "us";
119
+ eu: "eu";
120
+ }>>;
121
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
122
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
123
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
124
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
125
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
126
+ }, z.core.$strip>>[] | undefined>], undefined>;
127
+ declare const updateTransformation: _keystrokehq_core0.Operation<z.ZodObject<{
128
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ id: z.ZodString;
131
+ name: z.ZodOptional<z.ZodString>;
132
+ sourceId: z.ZodOptional<z.ZodString>;
133
+ destinationId: z.ZodOptional<z.ZodString>;
134
+ enabled: z.ZodOptional<z.ZodBoolean>;
135
+ if: z.ZodOptional<z.ZodString>;
136
+ newEventName: z.ZodOptional<z.ZodString>;
137
+ propertyRenames: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
138
+ propertyValueTransformations: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
139
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
140
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
141
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
142
+ us: "us";
143
+ eu: "eu";
144
+ }>>;
145
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
146
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
147
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
148
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
149
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
151
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
152
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
153
+ us: "us";
154
+ eu: "eu";
155
+ }>>;
156
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
157
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
158
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
159
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
160
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
161
+ }, z.core.$strip>>[] | undefined>], undefined>;
162
+ declare const deleteTransformation: _keystrokehq_core0.Operation<z.ZodObject<{
163
+ [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
164
+ }, z.core.$strip>, z.ZodObject<{}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
165
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
166
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
167
+ us: "us";
168
+ eu: "eu";
169
+ }>>;
170
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
171
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
172
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
173
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
174
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
175
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
176
+ SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
177
+ SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
178
+ us: "us";
179
+ eu: "eu";
180
+ }>>;
181
+ SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
182
+ SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
183
+ SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
184
+ SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
185
+ SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
186
+ }, z.core.$strip>>[] | undefined>], undefined>;
187
+ //#endregion
188
+ export { createTransformation, deleteTransformation, getTransformation, listTransformations, transformationSchema, updateTransformation };
@@ -0,0 +1,83 @@
1
+ import { a as segmentLooseObjectSchema, n as segmentIdSchema } from "./common-CdGiJbjq.mjs";
2
+ import { n as crudList, r as crudMutate, t as crudGet } from "./crud-SWa_79Hg.mjs";
3
+ import { z } from "zod";
4
+
5
+ //#region src/transformations.ts
6
+ /**
7
+ * segment/transformations.ts — source/destination transformations. 5 actions
8
+ * (PLAN § 6.11).
9
+ */
10
+ const transformationSchema = segmentLooseObjectSchema({
11
+ id: segmentIdSchema,
12
+ name: z.string().optional(),
13
+ sourceId: z.string().optional(),
14
+ destinationId: z.string().optional(),
15
+ enabled: z.boolean().optional(),
16
+ if: z.string().optional(),
17
+ newEventName: z.string().optional(),
18
+ propertyRenames: z.array(z.record(z.string(), z.unknown())).optional(),
19
+ propertyValueTransformations: z.array(z.record(z.string(), z.unknown())).optional()
20
+ });
21
+ const listTransformations = crudList({
22
+ id: "segment.transformations.list",
23
+ name: "List transformations",
24
+ description: "List source/destination transformations.",
25
+ path: "/transformations",
26
+ itemsKey: "transformations",
27
+ item: transformationSchema
28
+ });
29
+ const getTransformation = crudGet({
30
+ id: "segment.transformations.get",
31
+ name: "Get transformation",
32
+ description: "Fetch a transformation by id.",
33
+ path: "/transformations/{id}",
34
+ output: transformationSchema,
35
+ unwrapKey: "transformation"
36
+ });
37
+ const createTransformation = crudMutate({
38
+ id: "segment.transformations.create",
39
+ name: "Create transformation",
40
+ description: "Create a source/destination transformation.",
41
+ method: "POST",
42
+ path: "/transformations",
43
+ bodyShape: {
44
+ name: z.string().min(1),
45
+ sourceId: z.string().optional(),
46
+ destinationId: z.string().optional(),
47
+ if: z.string().optional(),
48
+ newEventName: z.string().optional(),
49
+ propertyRenames: z.array(z.record(z.string(), z.unknown())).optional(),
50
+ propertyValueTransformations: z.array(z.record(z.string(), z.unknown())).optional(),
51
+ enabled: z.boolean().optional()
52
+ },
53
+ output: transformationSchema,
54
+ unwrapKey: "transformation"
55
+ });
56
+ const updateTransformation = crudMutate({
57
+ id: "segment.transformations.update",
58
+ name: "Update transformation",
59
+ description: "Patch a transformation.",
60
+ method: "PATCH",
61
+ path: "/transformations/{id}",
62
+ bodyShape: {
63
+ name: z.string().optional(),
64
+ if: z.string().optional(),
65
+ newEventName: z.string().optional(),
66
+ propertyRenames: z.array(z.record(z.string(), z.unknown())).optional(),
67
+ propertyValueTransformations: z.array(z.record(z.string(), z.unknown())).optional(),
68
+ enabled: z.boolean().optional()
69
+ },
70
+ output: transformationSchema,
71
+ unwrapKey: "transformation"
72
+ });
73
+ const deleteTransformation = crudMutate({
74
+ id: "segment.transformations.delete",
75
+ name: "Delete transformation",
76
+ description: "Delete a transformation.",
77
+ method: "DELETE",
78
+ path: "/transformations/{id}",
79
+ output: z.object({}).catchall(z.unknown())
80
+ });
81
+
82
+ //#endregion
83
+ export { createTransformation, deleteTransformation, getTransformation, listTransformations, transformationSchema, updateTransformation };
@@ -0,0 +1,54 @@
1
+ import { r as segment } from "./integration-D2yRaKFR.mjs";
2
+ import { SegmentAudienceEvent, SegmentAudienceSyncEvent, SegmentComputedTraitEvent, SegmentDeletionRegulationEvent, SegmentDestinationCreatedEvent, SegmentFunctionVersionEvent, SegmentMonitoringEvent, SegmentReverseEtlRunEvent, SegmentSourceCreatedEvent, SegmentTrackingPlanViolationEvent, segmentAudienceWebhookEnvelopeSchema, segmentMonitoringAlertEnvelopeSchema } from "./events.mjs";
3
+ import { z } from "zod";
4
+ import { IntegrationTriggerBindingOptions } from "@keystrokehq/integration-authoring";
5
+ import { BoundTrigger, WebhookRequest } from "@keystrokehq/core";
6
+ import { PollingTriggerManifest, WebhookTriggerManifest } from "@keystrokehq/core/trigger";
7
+
8
+ //#region src/triggers.d.ts
9
+ type SegmentCredentialSets = readonly [typeof segment];
10
+ type SegmentWebhookBindingOptions<TPayload, TOutput = TPayload> = IntegrationTriggerBindingOptions<TPayload, TOutput, WebhookRequest>;
11
+ type SegmentWebhookBinding<TPayload> = <TOutput = TPayload>(options?: SegmentWebhookBindingOptions<TPayload, TOutput>) => BoundTrigger<z.output<typeof segmentAudienceWebhookEnvelopeSchema> | z.output<typeof segmentMonitoringAlertEnvelopeSchema>, SegmentCredentialSets, WebhookTriggerManifest, TOutput, WebhookRequest>;
12
+ declare const webhooks: Readonly<{
13
+ audienceEntered: SegmentWebhookBinding<SegmentAudienceEvent>;
14
+ audienceExited: SegmentWebhookBinding<SegmentAudienceEvent>;
15
+ computedTraitsUpdated: SegmentWebhookBinding<SegmentComputedTraitEvent>;
16
+ functionsInvocationFailed: SegmentWebhookBinding<SegmentMonitoringEvent>;
17
+ deliveryFailureSpike: SegmentWebhookBinding<SegmentMonitoringEvent>;
18
+ }>;
19
+ type SegmentPollingBindingOptions<TEvent, TOutput = TEvent> = IntegrationTriggerBindingOptions<TEvent, TOutput> & {
20
+ readonly schedule?: string;
21
+ };
22
+ type SegmentPollingBoundTrigger<TEvent, TOutput = TEvent> = BoundTrigger<TEvent, SegmentCredentialSets, PollingTriggerManifest, TOutput>;
23
+ interface AudienceSyncPollParams {
24
+ readonly spaceId: string;
25
+ readonly audienceId: string;
26
+ }
27
+ declare function audienceSyncCompleted<TOutput = SegmentAudienceSyncEvent>(params: AudienceSyncPollParams, options?: SegmentPollingBindingOptions<SegmentAudienceSyncEvent, TOutput>): SegmentPollingBoundTrigger<SegmentAudienceSyncEvent, TOutput>;
28
+ interface ReverseEtlRunPollParams {
29
+ readonly modelId: string;
30
+ }
31
+ declare function reverseEtlRunSucceeded<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
32
+ declare function reverseEtlRunFailed<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
33
+ declare function reverseEtlRunStarted<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
34
+ interface FunctionVersionPollParams {
35
+ readonly functionId: string;
36
+ }
37
+ declare function functionsDeploymentCompleted<TOutput = SegmentFunctionVersionEvent>(params: FunctionVersionPollParams, options?: SegmentPollingBindingOptions<SegmentFunctionVersionEvent, TOutput>): SegmentPollingBoundTrigger<SegmentFunctionVersionEvent, TOutput>;
38
+ declare function trackingPlanViolationDetected<TOutput = SegmentTrackingPlanViolationEvent>(options?: SegmentPollingBindingOptions<SegmentTrackingPlanViolationEvent, TOutput>): SegmentPollingBoundTrigger<SegmentTrackingPlanViolationEvent, TOutput>;
39
+ declare function sourceCreated<TOutput = SegmentSourceCreatedEvent>(options?: SegmentPollingBindingOptions<SegmentSourceCreatedEvent, TOutput>): SegmentPollingBoundTrigger<SegmentSourceCreatedEvent, TOutput>;
40
+ declare function destinationCreated<TOutput = SegmentDestinationCreatedEvent>(options?: SegmentPollingBindingOptions<SegmentDestinationCreatedEvent, TOutput>): SegmentPollingBoundTrigger<SegmentDestinationCreatedEvent, TOutput>;
41
+ declare function deletionRegulationCompleted<TOutput = SegmentDeletionRegulationEvent>(options?: SegmentPollingBindingOptions<SegmentDeletionRegulationEvent, TOutput>): SegmentPollingBoundTrigger<SegmentDeletionRegulationEvent, TOutput>;
42
+ declare const polling: Readonly<{
43
+ audienceSyncCompleted: typeof audienceSyncCompleted;
44
+ reverseEtlRunSucceeded: typeof reverseEtlRunSucceeded;
45
+ reverseEtlRunFailed: typeof reverseEtlRunFailed;
46
+ reverseEtlRunStarted: typeof reverseEtlRunStarted;
47
+ functionsDeploymentCompleted: typeof functionsDeploymentCompleted;
48
+ trackingPlanViolationDetected: typeof trackingPlanViolationDetected;
49
+ sourceCreated: typeof sourceCreated;
50
+ destinationCreated: typeof destinationCreated;
51
+ deletionRegulationCompleted: typeof deletionRegulationCompleted;
52
+ }>;
53
+ //#endregion
54
+ export { AudienceSyncPollParams, FunctionVersionPollParams, ReverseEtlRunPollParams, audienceSyncCompleted, deletionRegulationCompleted, destinationCreated, functionsDeploymentCompleted, polling, reverseEtlRunFailed, reverseEtlRunStarted, reverseEtlRunSucceeded, sourceCreated, trackingPlanViolationDetected, webhooks };