@keystrokehq/segment 0.0.9 → 0.0.16-integration-id-canonicalization.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.
Files changed (80) hide show
  1. package/README.md +52 -173
  2. package/dist/{client.mjs → client-DQfeZzLR.mjs} +28 -3
  3. package/dist/credential-sets/index.d.mts +2 -0
  4. package/dist/credential-sets/index.mjs +3 -0
  5. package/dist/index.d.mts +4 -1
  6. package/dist/index.mjs +5 -1
  7. package/dist/operations/index.d.mts +2 -0
  8. package/dist/operations/index.mjs +3 -0
  9. package/dist/schemas/index.mjs +1 -1
  10. package/dist/segment.credential-set-BTTrkHO7.mjs +33 -0
  11. package/dist/{integration-CeShwMIi.d.mts → segment.credential-set-BgROtI_9.d.mts} +28 -37
  12. package/dist/{triggers.d.mts → triggers/index.d.mts} +72 -6
  13. package/dist/{triggers.mjs → triggers/index.mjs} +136 -7
  14. package/dist/workspace-list-spaces.operation-DKWX3vl5.mjs +5200 -0
  15. package/dist/workspace-list-spaces.operation-QbDIgfRG.d.mts +6548 -0
  16. package/package.json +11 -123
  17. package/dist/_official/index.d.mts +0 -2
  18. package/dist/_official/index.mjs +0 -3
  19. package/dist/_runtime/index.d.mts +0 -1
  20. package/dist/_runtime/index.mjs +0 -1
  21. package/dist/audiences.d.mts +0 -282
  22. package/dist/audiences.mjs +0 -205
  23. package/dist/client.d.mts +0 -90
  24. package/dist/computed-traits.d.mts +0 -215
  25. package/dist/computed-traits.mjs +0 -149
  26. package/dist/connection.d.mts +0 -2
  27. package/dist/connection.mjs +0 -3
  28. package/dist/crud-DV9e4Spi.mjs +0 -140
  29. package/dist/deletion-suppression.d.mts +0 -191
  30. package/dist/deletion-suppression.mjs +0 -103
  31. package/dist/delivery-overview.d.mts +0 -79
  32. package/dist/delivery-overview.mjs +0 -54
  33. package/dist/destination-filters.d.mts +0 -190
  34. package/dist/destination-filters.mjs +0 -115
  35. package/dist/destinations.d.mts +0 -473
  36. package/dist/destinations.mjs +0 -257
  37. package/dist/edge-functions.d.mts +0 -168
  38. package/dist/edge-functions.mjs +0 -72
  39. package/dist/errors-4FGnrowW.mjs +0 -27
  40. package/dist/events-catalog.d.mts +0 -111
  41. package/dist/events-catalog.mjs +0 -65
  42. package/dist/events.d.mts +0 -167
  43. package/dist/events.mjs +0 -134
  44. package/dist/factory-DRwj5eiU.mjs +0 -7
  45. package/dist/functions.d.mts +0 -347
  46. package/dist/functions.mjs +0 -180
  47. package/dist/iam-groups.d.mts +0 -284
  48. package/dist/iam-groups.mjs +0 -144
  49. package/dist/iam-users.d.mts +0 -205
  50. package/dist/iam-users.mjs +0 -91
  51. package/dist/integration-B9FOjHPc.mjs +0 -115
  52. package/dist/labels.d.mts +0 -100
  53. package/dist/labels.mjs +0 -58
  54. package/dist/monitoring.d.mts +0 -182
  55. package/dist/monitoring.mjs +0 -88
  56. package/dist/profiles-sync.d.mts +0 -127
  57. package/dist/profiles-sync.mjs +0 -89
  58. package/dist/profiles.d.mts +0 -197
  59. package/dist/profiles.mjs +0 -137
  60. package/dist/reverse-etl.d.mts +0 -448
  61. package/dist/reverse-etl.mjs +0 -228
  62. package/dist/roles.d.mts +0 -48
  63. package/dist/roles.mjs +0 -25
  64. package/dist/sources.d.mts +0 -560
  65. package/dist/sources.mjs +0 -259
  66. package/dist/tracking-plans.d.mts +0 -351
  67. package/dist/tracking-plans.mjs +0 -160
  68. package/dist/tracking.d.mts +0 -499
  69. package/dist/tracking.mjs +0 -255
  70. package/dist/transformations.d.mts +0 -188
  71. package/dist/transformations.mjs +0 -83
  72. package/dist/usage.d.mts +0 -70
  73. package/dist/usage.mjs +0 -55
  74. package/dist/verification.d.mts +0 -17
  75. package/dist/verification.mjs +0 -51
  76. package/dist/warehouses.d.mts +0 -341
  77. package/dist/warehouses.mjs +0 -176
  78. package/dist/workspaces.d.mts +0 -95
  79. package/dist/workspaces.mjs +0 -67
  80. /package/dist/{common-CdGiJbjq.mjs → common-DUU0airJ.mjs} +0 -0
package/dist/tracking.mjs DELETED
@@ -1,255 +0,0 @@
1
- import { createSegmentClient } from "./client.mjs";
2
- import { t as segmentOperation } from "./factory-DRwj5eiU.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 };
@@ -1,188 +0,0 @@
1
- import * as _keystrokehq_core0 from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
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 };
@@ -1,83 +0,0 @@
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-DV9e4Spi.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 };
package/dist/usage.d.mts DELETED
@@ -1,70 +0,0 @@
1
- import * as _keystrokehq_core0 from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
-
5
- //#region src/usage.d.ts
6
- declare const getDailyPerSourceUsage: _keystrokehq_core0.Operation<z.ZodObject<{
7
- startDate: z.ZodOptional<z.ZodString>;
8
- endDate: z.ZodOptional<z.ZodString>;
9
- sourceId: z.ZodOptional<z.ZodString>;
10
- }, z.core.$strip>, z.ZodObject<{
11
- items: z.ZodArray<z.ZodObject<{
12
- date: z.ZodOptional<z.ZodString>;
13
- sourceId: z.ZodOptional<z.ZodString>;
14
- callCount: z.ZodOptional<z.ZodNumber>;
15
- }, z.core.$catchall<z.ZodUnknown>>>;
16
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
17
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
18
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
19
- us: "us";
20
- eu: "eu";
21
- }>>;
22
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
23
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
24
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
25
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
26
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
28
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
29
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
30
- us: "us";
31
- eu: "eu";
32
- }>>;
33
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
34
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
35
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
36
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
37
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
38
- }, z.core.$strip>>[] | undefined>], undefined>;
39
- declare const getMonthlyWorkspaceUsage: _keystrokehq_core0.Operation<z.ZodObject<{
40
- month: z.ZodOptional<z.ZodString>;
41
- }, z.core.$strip>, z.ZodObject<{
42
- month: z.ZodOptional<z.ZodString>;
43
- mtu: z.ZodOptional<z.ZodNumber>;
44
- events: z.ZodOptional<z.ZodNumber>;
45
- breakdowns: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
46
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"segment", z.ZodObject<{
47
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
48
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
49
- us: "us";
50
- eu: "eu";
51
- }>>;
52
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
53
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
54
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
55
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
56
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
57
- }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
58
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
59
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
60
- us: "us";
61
- eu: "eu";
62
- }>>;
63
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
64
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
65
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
66
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
67
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
68
- }, z.core.$strip>>[] | undefined>], undefined>;
69
- //#endregion
70
- export { getDailyPerSourceUsage, getMonthlyWorkspaceUsage };
package/dist/usage.mjs DELETED
@@ -1,55 +0,0 @@
1
- import { createSegmentClient } from "./client.mjs";
2
- import { a as segmentLooseObjectSchema } from "./common-CdGiJbjq.mjs";
3
- import { t as segmentOperation } from "./factory-DRwj5eiU.mjs";
4
- import { z } from "zod";
5
-
6
- //#region src/usage.ts
7
- /**
8
- * segment/usage.ts — API call usage per source + monthly workspace usage.
9
- * 2 actions (PLAN § 6.22).
10
- */
11
- const dailyEntrySchema = segmentLooseObjectSchema({
12
- date: z.string().optional(),
13
- sourceId: z.string().optional(),
14
- callCount: z.number().optional()
15
- });
16
- const monthlyWorkspaceSchema = segmentLooseObjectSchema({
17
- month: z.string().optional(),
18
- mtu: z.number().optional(),
19
- events: z.number().optional(),
20
- breakdowns: z.array(z.record(z.string(), z.unknown())).optional()
21
- });
22
- const getDailyPerSourceUsage = segmentOperation({
23
- id: "segment.usage.getDailyPerSource",
24
- name: "Get daily per-source usage",
25
- description: "Daily API call counts per source.",
26
- input: z.object({
27
- startDate: z.string().optional(),
28
- endDate: z.string().optional(),
29
- sourceId: z.string().optional()
30
- }),
31
- output: z.object({ items: z.array(dailyEntrySchema) }),
32
- run: async (input, credentials) => {
33
- const rec = await createSegmentClient(credentials).publicApi.request("/usage/sources/daily-api-calls", { query: {
34
- startDate: input.startDate,
35
- endDate: input.endDate,
36
- sourceId: input.sourceId
37
- } });
38
- return { items: (rec.data?.usage ?? rec.usage ?? []).map((entry) => dailyEntrySchema.parse(entry)) };
39
- }
40
- });
41
- const getMonthlyWorkspaceUsage = segmentOperation({
42
- id: "segment.usage.getMonthlyWorkspace",
43
- name: "Get monthly workspace usage",
44
- description: "Monthly MTU and event totals for the workspace.",
45
- input: z.object({ month: z.string().optional() }),
46
- output: monthlyWorkspaceSchema,
47
- run: async (input, credentials) => {
48
- const body = await createSegmentClient(credentials).publicApi.request("/usage/workspace/monthly", { query: { month: input.month } });
49
- const rec = body;
50
- return monthlyWorkspaceSchema.parse(rec.data ?? body);
51
- }
52
- });
53
-
54
- //#endregion
55
- export { getDailyPerSourceUsage, getMonthlyWorkspaceUsage };
@@ -1,17 +0,0 @@
1
- import { WebhookRequest } from "@keystrokehq/core";
2
-
3
- //#region src/verification.d.ts
4
- /** Default header name Segment uses for its webhook signature. */
5
- declare const SEGMENT_SIGNATURE_HEADER = "x-signature";
6
- /** Hex-encoded HMAC-SHA1 of `rawBody` using `secret`. */
7
- declare function buildSegmentWebhookSignature(rawBody: string, secret: string): string;
8
- interface VerifySegmentWebhookOptions {
9
- readonly rawBody: string;
10
- readonly signatureHeader: string | undefined;
11
- readonly secret: string;
12
- }
13
- declare function verifySegmentWebhookRequest(options: VerifySegmentWebhookOptions): boolean;
14
- /** Convenience wrapper for the `WebhookRequest` shape the runtime passes. */
15
- declare function verifySegmentWebhookFromRequest(request: Pick<WebhookRequest, 'headers' | 'rawBody'>, secret: string, signatureHeader?: string): boolean;
16
- //#endregion
17
- export { SEGMENT_SIGNATURE_HEADER, VerifySegmentWebhookOptions, buildSegmentWebhookSignature, verifySegmentWebhookFromRequest, verifySegmentWebhookRequest };