@keystrokehq/segment 0.0.15 → 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 (79) 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/{integration-CliT2xe3.mjs → segment.credential-set-BTTrkHO7.mjs} +16 -9
  11. package/dist/{integration-DWeMeBqQ.d.mts → segment.credential-set-BgROtI_9.d.mts} +28 -27
  12. package/dist/{triggers.d.mts → triggers/index.d.mts} +72 -6
  13. package/dist/{triggers.mjs → triggers/index.mjs} +186 -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 +14 -126
  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 -193
  22. package/dist/audiences.mjs +0 -205
  23. package/dist/client.d.mts +0 -90
  24. package/dist/computed-traits.d.mts +0 -148
  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-DGM2Ekdr.mjs +0 -140
  29. package/dist/deletion-suppression.d.mts +0 -135
  30. package/dist/deletion-suppression.mjs +0 -103
  31. package/dist/delivery-overview.d.mts +0 -56
  32. package/dist/delivery-overview.mjs +0 -54
  33. package/dist/destination-filters.d.mts +0 -134
  34. package/dist/destination-filters.mjs +0 -115
  35. package/dist/destinations.d.mts +0 -318
  36. package/dist/destinations.mjs +0 -257
  37. package/dist/edge-functions.d.mts +0 -112
  38. package/dist/edge-functions.mjs +0 -72
  39. package/dist/errors-4FGnrowW.mjs +0 -27
  40. package/dist/events-catalog.d.mts +0 -77
  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-Dqb49Dfj.mjs +0 -8
  45. package/dist/functions.d.mts +0 -236
  46. package/dist/functions.mjs +0 -180
  47. package/dist/iam-groups.d.mts +0 -184
  48. package/dist/iam-groups.mjs +0 -144
  49. package/dist/iam-users.d.mts +0 -138
  50. package/dist/iam-users.mjs +0 -91
  51. package/dist/labels.d.mts +0 -66
  52. package/dist/labels.mjs +0 -58
  53. package/dist/monitoring.d.mts +0 -126
  54. package/dist/monitoring.mjs +0 -88
  55. package/dist/profiles-sync.d.mts +0 -82
  56. package/dist/profiles-sync.mjs +0 -89
  57. package/dist/profiles.d.mts +0 -130
  58. package/dist/profiles.mjs +0 -137
  59. package/dist/reverse-etl.d.mts +0 -315
  60. package/dist/reverse-etl.mjs +0 -228
  61. package/dist/roles.d.mts +0 -36
  62. package/dist/roles.mjs +0 -25
  63. package/dist/sources.d.mts +0 -383
  64. package/dist/sources.mjs +0 -259
  65. package/dist/tracking-plans.d.mts +0 -229
  66. package/dist/tracking-plans.mjs +0 -160
  67. package/dist/tracking.d.mts +0 -410
  68. package/dist/tracking.mjs +0 -255
  69. package/dist/transformations.d.mts +0 -132
  70. package/dist/transformations.mjs +0 -83
  71. package/dist/usage.d.mts +0 -47
  72. package/dist/usage.mjs +0 -55
  73. package/dist/verification.d.mts +0 -17
  74. package/dist/verification.mjs +0 -51
  75. package/dist/warehouses.d.mts +0 -219
  76. package/dist/warehouses.mjs +0 -176
  77. package/dist/workspaces.d.mts +0 -61
  78. package/dist/workspaces.mjs +0 -67
  79. /package/dist/{common-CdGiJbjq.mjs → common-DUU0airJ.mjs} +0 -0
package/dist/sources.mjs DELETED
@@ -1,259 +0,0 @@
1
- import { t as SegmentApiError } from "./errors-4FGnrowW.mjs";
2
- import { createSegmentClient } from "./client.mjs";
3
- import { a as segmentLooseObjectSchema, n as segmentIdSchema, r as segmentLabelSchema } from "./common-CdGiJbjq.mjs";
4
- import { t as segmentOperation } from "./factory-Dqb49Dfj.mjs";
5
- import { n as crudList, r as crudMutate, t as crudGet } from "./crud-DGM2Ekdr.mjs";
6
- import { z } from "zod";
7
-
8
- //#region src/sources.ts
9
- /**
10
- * segment/sources.ts
11
- *
12
- * Public API source CRUD + write-key management + schema settings + label
13
- * attachment + connected warehouse/destination/tracking-plan views + filters.
14
- *
15
- * 16 actions total (PLAN.md § 6.2). The 5 canonical CRUD actions use the
16
- * package-internal `crud` helpers; the rest are written directly because
17
- * they have resource-shaped inputs/outputs that don't fit the generic CRUD
18
- * pattern.
19
- */
20
- const segmentSourceSchema = segmentLooseObjectSchema({
21
- id: segmentIdSchema,
22
- slug: z.string().optional(),
23
- name: z.string().optional(),
24
- enabled: z.boolean().optional(),
25
- workspaceId: z.string().optional(),
26
- writeKeys: z.array(z.string()).optional(),
27
- labels: z.array(segmentLabelSchema).optional(),
28
- metadata: z.record(z.string(), z.unknown()).optional()
29
- });
30
- const sourceCreateBody = {
31
- slug: z.string().min(1),
32
- name: z.string().min(1).optional(),
33
- enabled: z.boolean().optional(),
34
- metadata: z.record(z.string(), z.unknown()).optional()
35
- };
36
- const sourceUpdateBody = {
37
- name: z.string().optional(),
38
- enabled: z.boolean().optional(),
39
- slug: z.string().optional(),
40
- metadata: z.record(z.string(), z.unknown()).optional()
41
- };
42
- const listSources = crudList({
43
- id: "segment.sources.list",
44
- name: "List sources",
45
- description: "Paginated list of Segment sources in the workspace.",
46
- path: "/sources",
47
- itemsKey: "sources",
48
- item: segmentSourceSchema
49
- });
50
- const getSource = crudGet({
51
- id: "segment.sources.get",
52
- name: "Get source",
53
- description: "Fetch a Segment source by id.",
54
- path: "/sources/{id}",
55
- output: segmentSourceSchema,
56
- unwrapKey: "source"
57
- });
58
- const createSource = crudMutate({
59
- id: "segment.sources.create",
60
- name: "Create source",
61
- description: "Create a new Segment source.",
62
- method: "POST",
63
- path: "/sources",
64
- bodyShape: sourceCreateBody,
65
- output: segmentSourceSchema,
66
- unwrapKey: "source"
67
- });
68
- const updateSource = crudMutate({
69
- id: "segment.sources.update",
70
- name: "Update source",
71
- description: "Patch a Segment source.",
72
- method: "PATCH",
73
- path: "/sources/{id}",
74
- bodyShape: sourceUpdateBody,
75
- output: segmentSourceSchema,
76
- unwrapKey: "source"
77
- });
78
- const deleteSource = crudMutate({
79
- id: "segment.sources.delete",
80
- name: "Delete source",
81
- description: "Delete a Segment source. Irreversible — archive data first.",
82
- method: "DELETE",
83
- path: "/sources/{id}",
84
- output: z.object({ deleted: z.literal(true) }).or(segmentLooseObjectSchema({}))
85
- });
86
- const writeKeyEntrySchema = segmentLooseObjectSchema({
87
- id: z.string().optional(),
88
- value: z.string().optional(),
89
- writeKey: z.string().optional(),
90
- createdAt: z.string().optional(),
91
- lastUsedAt: z.string().optional()
92
- });
93
- const listWriteKeys = segmentOperation({
94
- id: "segment.sources.listWriteKeys",
95
- name: "List write keys",
96
- description: "List every write key registered on a source.",
97
- input: z.object({ id: segmentIdSchema }),
98
- output: z.object({ items: z.array(writeKeyEntrySchema) }),
99
- run: async (input, credentials) => {
100
- const rec = await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}/write-keys`);
101
- return { items: (rec.data?.writeKeys ?? rec.writeKeys ?? []).map((entry) => writeKeyEntrySchema.parse(entry)) };
102
- }
103
- });
104
- const rotateWriteKey = segmentOperation({
105
- id: "segment.sources.rotateWriteKey",
106
- name: "Rotate write key",
107
- description: "Create a new write key for the source. The old key continues to work until explicitly removed.",
108
- input: z.object({ id: segmentIdSchema }),
109
- output: writeKeyEntrySchema,
110
- needsApproval: true,
111
- run: async (input, credentials) => {
112
- const body = await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}/write-keys`, { method: "POST" });
113
- const rec = body;
114
- return writeKeyEntrySchema.parse(rec.data?.writeKey ?? rec.writeKey ?? body);
115
- }
116
- });
117
- const removeWriteKey = segmentOperation({
118
- id: "segment.sources.removeWriteKey",
119
- name: "Remove write key",
120
- description: "Delete a write key from a source. Refuses to delete the last remaining key unless `force: true` is passed.",
121
- input: z.object({
122
- id: segmentIdSchema,
123
- writeKey: z.string().min(1),
124
- force: z.boolean().optional()
125
- }),
126
- output: z.object({ removed: z.literal(true) }),
127
- needsApproval: true,
128
- run: async (input, credentials) => {
129
- const client = createSegmentClient(credentials);
130
- if (!input.force) {
131
- const rec = await client.publicApi.request(`/sources/${encodeURIComponent(input.id)}/write-keys`);
132
- if ((rec.data?.writeKeys ?? rec.writeKeys ?? []).length <= 1) throw new SegmentApiError({
133
- kind: "validation",
134
- message: `Refusing to delete the last remaining write key on source ${input.id}. Pass { force: true } to override.`
135
- });
136
- }
137
- await client.publicApi.request(`/sources/${encodeURIComponent(input.id)}/write-keys/${encodeURIComponent(input.writeKey)}`, { method: "DELETE" });
138
- return { removed: true };
139
- }
140
- });
141
- const schemaSettingsSchema = segmentLooseObjectSchema({
142
- forwardingBlockedEventsTo: z.string().optional(),
143
- forwardingViolationsTo: z.string().optional(),
144
- commonEventOnViolations: z.string().optional(),
145
- identifyEnabled: z.boolean().optional(),
146
- trackEnabled: z.boolean().optional(),
147
- groupEnabled: z.boolean().optional()
148
- });
149
- const listSchemaSettings = segmentOperation({
150
- id: "segment.sources.listSchemaSettings",
151
- name: "List schema settings",
152
- description: "Read tracking schema enforcement settings for a source.",
153
- input: z.object({ id: segmentIdSchema }),
154
- output: schemaSettingsSchema,
155
- run: async (input, credentials) => {
156
- const body = await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}/schema-settings`);
157
- const rec = body;
158
- return schemaSettingsSchema.parse(rec.data ?? body);
159
- }
160
- });
161
- const updateSchemaSettings = segmentOperation({
162
- id: "segment.sources.updateSchemaSettings",
163
- name: "Update schema settings",
164
- description: "Patch tracking schema enforcement settings for a source.",
165
- input: z.object({
166
- id: segmentIdSchema,
167
- forwardingBlockedEventsTo: z.string().optional(),
168
- forwardingViolationsTo: z.string().optional(),
169
- commonEventOnViolations: z.string().optional(),
170
- identifyEnabled: z.boolean().optional(),
171
- trackEnabled: z.boolean().optional(),
172
- groupEnabled: z.boolean().optional()
173
- }),
174
- output: schemaSettingsSchema,
175
- needsApproval: true,
176
- run: async (input, credentials) => {
177
- const client = createSegmentClient(credentials);
178
- const { id, ...body } = input;
179
- const response = await client.publicApi.request(`/sources/${encodeURIComponent(id)}/schema-settings`, {
180
- method: "PATCH",
181
- body
182
- });
183
- const rec = response;
184
- return schemaSettingsSchema.parse(rec.data ?? response);
185
- }
186
- });
187
- const labelInputSchema = z.object({
188
- id: segmentIdSchema,
189
- labels: z.array(segmentLabelSchema).min(1)
190
- });
191
- const addLabels = segmentOperation({
192
- id: "segment.sources.addLabels",
193
- name: "Add labels to source",
194
- description: "Attach one or more labels to a source.",
195
- input: labelInputSchema,
196
- output: z.object({ labels: z.array(segmentLabelSchema) }),
197
- needsApproval: true,
198
- run: async (input, credentials) => {
199
- return { labels: ((await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}/labels`, {
200
- method: "POST",
201
- body: { labels: input.labels }
202
- })).data?.labels ?? input.labels).map((l) => segmentLabelSchema.parse(l)) };
203
- }
204
- });
205
- const removeLabels = segmentOperation({
206
- id: "segment.sources.removeLabels",
207
- name: "Remove labels from source",
208
- description: "Detach one or more labels from a source.",
209
- input: labelInputSchema,
210
- output: z.object({ removed: z.literal(true) }),
211
- needsApproval: true,
212
- run: async (input, credentials) => {
213
- await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}/labels`, {
214
- method: "DELETE",
215
- body: { labels: input.labels }
216
- });
217
- return { removed: true };
218
- }
219
- });
220
- const connectedWarehouseSchema = segmentLooseObjectSchema({
221
- id: segmentIdSchema,
222
- name: z.string().optional(),
223
- enabled: z.boolean().optional()
224
- });
225
- const connectedDestinationSchema = segmentLooseObjectSchema({
226
- id: segmentIdSchema,
227
- name: z.string().optional(),
228
- enabled: z.boolean().optional()
229
- });
230
- const connectedTrackingPlanSchema = segmentLooseObjectSchema({
231
- id: segmentIdSchema,
232
- name: z.string().optional()
233
- });
234
- const destinationFilterSchema = segmentLooseObjectSchema({
235
- id: segmentIdSchema,
236
- if: z.string().optional(),
237
- actions: z.array(z.record(z.string(), z.unknown())).optional(),
238
- enabled: z.boolean().optional()
239
- });
240
- function listRelatedOp(actionId, name, description, pathSuffix, itemsKey, item) {
241
- return segmentOperation({
242
- id: actionId,
243
- name,
244
- description,
245
- input: z.object({ id: segmentIdSchema }),
246
- output: z.object({ items: z.array(item) }),
247
- run: async (input, credentials) => {
248
- const rec = await createSegmentClient(credentials).publicApi.request(`/sources/${encodeURIComponent(input.id)}${pathSuffix}`);
249
- return { items: (rec.data?.[itemsKey] ?? rec[itemsKey] ?? []).map((entry) => item.parse(entry)) };
250
- }
251
- });
252
- }
253
- const listConnectedWarehouses = listRelatedOp("segment.sources.listConnectedWarehouses", "List warehouses connected to source", "Warehouses currently syncing from this source.", "/connected-warehouses", "warehouses", connectedWarehouseSchema);
254
- const listConnectedDestinations = listRelatedOp("segment.sources.listConnectedDestinations", "List destinations connected to source", "Destinations currently receiving data from this source.", "/connected-destinations", "destinations", connectedDestinationSchema);
255
- const listConnectedTrackingPlans = listRelatedOp("segment.sources.listConnectedTrackingPlans", "List tracking plans connected to source", "Tracking plans enforced against this source.", "/tracking-plan-connections", "trackingPlans", connectedTrackingPlanSchema);
256
- const listFilters = listRelatedOp("segment.sources.listFilters", "List destination filters on source", "Destination filter rules attached to this source.", "/destination-filters", "filters", destinationFilterSchema);
257
-
258
- //#endregion
259
- export { addLabels, createSource, deleteSource, getSource, listConnectedDestinations, listConnectedTrackingPlans, listConnectedWarehouses, listFilters, listSchemaSettings, listSources, listWriteKeys, removeLabels, removeWriteKey, rotateWriteKey, segmentSourceSchema, updateSchemaSettings, updateSource };
@@ -1,229 +0,0 @@
1
- import { z } from "zod";
2
- import * as _keystrokehq_core0 from "@keystrokehq/core";
3
-
4
- //#region src/tracking-plans.d.ts
5
- declare const listTrackingPlans: _keystrokehq_core0.Operation<z.ZodIntersection<z.ZodObject<{
6
- pageSize: z.ZodOptional<z.ZodNumber>;
7
- pageToken: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
9
- items: z.ZodArray<z.ZodObject<{
10
- id: z.ZodString;
11
- slug: z.ZodOptional<z.ZodString>;
12
- name: z.ZodOptional<z.ZodString>;
13
- description: z.ZodOptional<z.ZodString>;
14
- type: z.ZodOptional<z.ZodString>;
15
- }, z.core.$catchall<z.ZodUnknown>>>;
16
- nextPageToken: z.ZodOptional<z.ZodString>;
17
- totalEntries: z.ZodOptional<z.ZodNumber>;
18
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
19
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
20
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
21
- us: "us";
22
- eu: "eu";
23
- }>>;
24
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
25
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
26
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
27
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
28
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
29
- }, z.core.$strip>>], undefined>;
30
- declare const getTrackingPlan: _keystrokehq_core0.Operation<z.ZodObject<{
31
- [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
32
- }, z.core.$strip>, z.ZodObject<{
33
- id: z.ZodString;
34
- slug: z.ZodOptional<z.ZodString>;
35
- name: z.ZodOptional<z.ZodString>;
36
- description: z.ZodOptional<z.ZodString>;
37
- type: z.ZodOptional<z.ZodString>;
38
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
39
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
40
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
41
- us: "us";
42
- eu: "eu";
43
- }>>;
44
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
45
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
46
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
47
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
48
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
49
- }, z.core.$strip>>], undefined>;
50
- declare const createTrackingPlan: _keystrokehq_core0.Operation<z.ZodObject<{
51
- [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
52
- }, z.core.$strip>, z.ZodObject<{
53
- id: z.ZodString;
54
- slug: z.ZodOptional<z.ZodString>;
55
- name: z.ZodOptional<z.ZodString>;
56
- description: z.ZodOptional<z.ZodString>;
57
- type: z.ZodOptional<z.ZodString>;
58
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
59
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
60
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
61
- us: "us";
62
- eu: "eu";
63
- }>>;
64
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
65
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
66
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
67
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
68
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
69
- }, z.core.$strip>>], undefined>;
70
- declare const updateTrackingPlan: _keystrokehq_core0.Operation<z.ZodObject<{
71
- [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
72
- }, z.core.$strip>, z.ZodObject<{
73
- id: z.ZodString;
74
- slug: z.ZodOptional<z.ZodString>;
75
- name: z.ZodOptional<z.ZodString>;
76
- description: z.ZodOptional<z.ZodString>;
77
- type: z.ZodOptional<z.ZodString>;
78
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
79
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
80
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
81
- us: "us";
82
- eu: "eu";
83
- }>>;
84
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
85
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
86
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
87
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
88
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
89
- }, z.core.$strip>>], undefined>;
90
- declare const deleteTrackingPlan: _keystrokehq_core0.Operation<z.ZodObject<{
91
- [x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
92
- }, z.core.$strip>, z.ZodObject<{}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
93
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
94
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
95
- us: "us";
96
- eu: "eu";
97
- }>>;
98
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
99
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
100
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
101
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
102
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
103
- }, z.core.$strip>>], undefined>;
104
- declare const listTrackingPlanRules: _keystrokehq_core0.Operation<z.ZodObject<{
105
- id: z.ZodString;
106
- }, z.core.$strip>, z.ZodObject<{
107
- items: z.ZodArray<z.ZodObject<{
108
- key: z.ZodOptional<z.ZodString>;
109
- type: z.ZodOptional<z.ZodString>;
110
- version: z.ZodOptional<z.ZodNumber>;
111
- description: z.ZodOptional<z.ZodString>;
112
- }, z.core.$catchall<z.ZodUnknown>>>;
113
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
114
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
115
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
116
- us: "us";
117
- eu: "eu";
118
- }>>;
119
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
120
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
121
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
122
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
123
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
124
- }, z.core.$strip>>], undefined>;
125
- declare const replaceTrackingPlanRules: _keystrokehq_core0.Operation<z.ZodObject<{
126
- id: z.ZodString;
127
- rules: z.ZodArray<z.ZodObject<{
128
- key: z.ZodOptional<z.ZodString>;
129
- type: z.ZodOptional<z.ZodString>;
130
- version: z.ZodOptional<z.ZodNumber>;
131
- description: z.ZodOptional<z.ZodString>;
132
- }, z.core.$catchall<z.ZodUnknown>>>;
133
- }, z.core.$strip>, z.ZodObject<{
134
- items: z.ZodArray<z.ZodObject<{
135
- key: z.ZodOptional<z.ZodString>;
136
- type: z.ZodOptional<z.ZodString>;
137
- version: z.ZodOptional<z.ZodNumber>;
138
- description: z.ZodOptional<z.ZodString>;
139
- }, z.core.$catchall<z.ZodUnknown>>>;
140
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
141
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
142
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
143
- us: "us";
144
- eu: "eu";
145
- }>>;
146
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
147
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
148
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
149
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
150
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
151
- }, z.core.$strip>>], undefined>;
152
- declare const listTrackingPlanSources: _keystrokehq_core0.Operation<z.ZodObject<{
153
- id: z.ZodString;
154
- }, z.core.$strip>, z.ZodObject<{
155
- items: z.ZodArray<z.ZodObject<{
156
- sourceId: z.ZodString;
157
- trackingPlanId: z.ZodOptional<z.ZodString>;
158
- }, z.core.$catchall<z.ZodUnknown>>>;
159
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
160
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
161
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
162
- us: "us";
163
- eu: "eu";
164
- }>>;
165
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
166
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
167
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
168
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
169
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
170
- }, z.core.$strip>>], undefined>;
171
- declare const connectTrackingPlanSource: _keystrokehq_core0.Operation<z.ZodObject<{
172
- id: z.ZodString;
173
- sourceId: z.ZodString;
174
- }, z.core.$strip>, z.ZodObject<{
175
- sourceId: z.ZodString;
176
- trackingPlanId: z.ZodOptional<z.ZodString>;
177
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
178
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
179
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
180
- us: "us";
181
- eu: "eu";
182
- }>>;
183
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
184
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
185
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
186
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
187
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
188
- }, z.core.$strip>>], undefined>;
189
- declare const disconnectTrackingPlanSource: _keystrokehq_core0.Operation<z.ZodObject<{
190
- id: z.ZodString;
191
- sourceId: z.ZodString;
192
- }, z.core.$strip>, z.ZodObject<{
193
- removed: z.ZodLiteral<true>;
194
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
195
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
196
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
197
- us: "us";
198
- eu: "eu";
199
- }>>;
200
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
201
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
202
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
203
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
204
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
205
- }, z.core.$strip>>], undefined>;
206
- declare const listTrackingPlanViolations: _keystrokehq_core0.Operation<z.ZodObject<{
207
- id: z.ZodString;
208
- }, z.core.$strip>, z.ZodObject<{
209
- items: z.ZodArray<z.ZodObject<{
210
- id: z.ZodString;
211
- eventType: z.ZodOptional<z.ZodString>;
212
- messageId: z.ZodOptional<z.ZodString>;
213
- violationReason: z.ZodOptional<z.ZodString>;
214
- timestamp: z.ZodOptional<z.ZodString>;
215
- }, z.core.$catchall<z.ZodUnknown>>>;
216
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
217
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
218
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
219
- us: "us";
220
- eu: "eu";
221
- }>>;
222
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
223
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
224
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
225
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
226
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
227
- }, z.core.$strip>>], undefined>;
228
- //#endregion
229
- export { connectTrackingPlanSource, createTrackingPlan, deleteTrackingPlan, disconnectTrackingPlanSource, getTrackingPlan, listTrackingPlanRules, listTrackingPlanSources, listTrackingPlanViolations, listTrackingPlans, replaceTrackingPlanRules, updateTrackingPlan };
@@ -1,160 +0,0 @@
1
- import { createSegmentClient } from "./client.mjs";
2
- import { a as segmentLooseObjectSchema, n as segmentIdSchema } from "./common-CdGiJbjq.mjs";
3
- import { t as segmentOperation } from "./factory-Dqb49Dfj.mjs";
4
- import { n as crudList, r as crudMutate, t as crudGet } from "./crud-DGM2Ekdr.mjs";
5
- import { z } from "zod";
6
-
7
- //#region src/tracking-plans.ts
8
- /**
9
- * segment/tracking-plans.ts — tracking plan CRUD + rules + sources +
10
- * violations. 11 actions total (PLAN.md § 6.4).
11
- */
12
- const trackingPlanSchema = segmentLooseObjectSchema({
13
- id: segmentIdSchema,
14
- slug: z.string().optional(),
15
- name: z.string().optional(),
16
- description: z.string().optional(),
17
- type: z.string().optional()
18
- });
19
- const ruleSchema = segmentLooseObjectSchema({
20
- key: z.string().optional(),
21
- type: z.string().optional(),
22
- version: z.number().optional(),
23
- description: z.string().optional()
24
- });
25
- const violationSchema = segmentLooseObjectSchema({
26
- id: segmentIdSchema,
27
- eventType: z.string().optional(),
28
- messageId: z.string().optional(),
29
- violationReason: z.string().optional(),
30
- timestamp: z.string().optional()
31
- });
32
- const connectionSchema = segmentLooseObjectSchema({
33
- sourceId: segmentIdSchema,
34
- trackingPlanId: z.string().optional()
35
- });
36
- const listTrackingPlans = crudList({
37
- id: "segment.trackingPlans.list",
38
- name: "List tracking plans",
39
- description: "Paginated list of tracking plans in the workspace.",
40
- path: "/tracking-plans",
41
- itemsKey: "trackingPlans",
42
- item: trackingPlanSchema
43
- });
44
- const getTrackingPlan = crudGet({
45
- id: "segment.trackingPlans.get",
46
- name: "Get tracking plan",
47
- description: "Fetch a tracking plan by id.",
48
- path: "/tracking-plans/{id}",
49
- output: trackingPlanSchema,
50
- unwrapKey: "trackingPlan"
51
- });
52
- const createTrackingPlan = crudMutate({
53
- id: "segment.trackingPlans.create",
54
- name: "Create tracking plan",
55
- description: "Create a new tracking plan.",
56
- method: "POST",
57
- path: "/tracking-plans",
58
- bodyShape: {
59
- name: z.string().min(1),
60
- slug: z.string().optional(),
61
- description: z.string().optional(),
62
- type: z.string().optional()
63
- },
64
- output: trackingPlanSchema,
65
- unwrapKey: "trackingPlan"
66
- });
67
- const updateTrackingPlan = crudMutate({
68
- id: "segment.trackingPlans.update",
69
- name: "Update tracking plan",
70
- description: "Patch a tracking plan.",
71
- method: "PATCH",
72
- path: "/tracking-plans/{id}",
73
- bodyShape: {
74
- name: z.string().optional(),
75
- description: z.string().optional(),
76
- slug: z.string().optional()
77
- },
78
- output: trackingPlanSchema,
79
- unwrapKey: "trackingPlan"
80
- });
81
- const deleteTrackingPlan = crudMutate({
82
- id: "segment.trackingPlans.delete",
83
- name: "Delete tracking plan",
84
- description: "Delete a tracking plan.",
85
- method: "DELETE",
86
- path: "/tracking-plans/{id}",
87
- output: z.object({}).catchall(z.unknown())
88
- });
89
- function trackingPlanList(id, name, description, pathSuffix, itemsKey, item) {
90
- return segmentOperation({
91
- id,
92
- name,
93
- description,
94
- input: z.object({ id: segmentIdSchema }),
95
- output: z.object({ items: z.array(item) }),
96
- run: async (input, credentials) => {
97
- const rec = await createSegmentClient(credentials).publicApi.request(`/tracking-plans/${encodeURIComponent(input.id)}${pathSuffix}`);
98
- return { items: (rec.data?.[itemsKey] ?? rec[itemsKey] ?? []).map((entry) => item.parse(entry)) };
99
- }
100
- });
101
- }
102
- const listTrackingPlanRules = trackingPlanList("segment.trackingPlans.listRules", "List rules", "List the rules defined on a tracking plan.", "/rules", "rules", ruleSchema);
103
- const replaceTrackingPlanRules = segmentOperation({
104
- id: "segment.trackingPlans.replaceRules",
105
- name: "Replace tracking plan rules",
106
- description: "Replace the rule set on a tracking plan.",
107
- input: z.object({
108
- id: segmentIdSchema,
109
- rules: z.array(ruleSchema)
110
- }),
111
- output: z.object({ items: z.array(ruleSchema) }),
112
- needsApproval: true,
113
- run: async (input, credentials) => {
114
- return { items: ((await createSegmentClient(credentials).publicApi.request(`/tracking-plans/${encodeURIComponent(input.id)}/rules`, {
115
- method: "PUT",
116
- body: { rules: input.rules }
117
- })).data?.rules ?? []).map((entry) => ruleSchema.parse(entry)) };
118
- }
119
- });
120
- const listTrackingPlanSources = trackingPlanList("segment.trackingPlans.listSources", "List connected sources", "List sources connected to this tracking plan.", "/sources", "connections", connectionSchema);
121
- const connectTrackingPlanSource = segmentOperation({
122
- id: "segment.trackingPlans.connectSource",
123
- name: "Connect source to tracking plan",
124
- description: "Attach a source to a tracking plan.",
125
- input: z.object({
126
- id: segmentIdSchema,
127
- sourceId: segmentIdSchema
128
- }),
129
- output: connectionSchema,
130
- needsApproval: true,
131
- run: async (input, credentials) => {
132
- const rec = await createSegmentClient(credentials).publicApi.request(`/tracking-plans/${encodeURIComponent(input.id)}/sources`, {
133
- method: "POST",
134
- body: { sourceId: input.sourceId }
135
- });
136
- return connectionSchema.parse(rec.data?.connection ?? {
137
- sourceId: input.sourceId,
138
- trackingPlanId: input.id
139
- });
140
- }
141
- });
142
- const disconnectTrackingPlanSource = segmentOperation({
143
- id: "segment.trackingPlans.disconnectSource",
144
- name: "Disconnect source from tracking plan",
145
- description: "Detach a source from a tracking plan.",
146
- input: z.object({
147
- id: segmentIdSchema,
148
- sourceId: segmentIdSchema
149
- }),
150
- output: z.object({ removed: z.literal(true) }),
151
- needsApproval: true,
152
- run: async (input, credentials) => {
153
- await createSegmentClient(credentials).publicApi.request(`/tracking-plans/${encodeURIComponent(input.id)}/sources/${encodeURIComponent(input.sourceId)}`, { method: "DELETE" });
154
- return { removed: true };
155
- }
156
- });
157
- const listTrackingPlanViolations = trackingPlanList("segment.trackingPlans.listViolations", "List violations", "List events that violated this tracking plan.", "/violations", "violations", violationSchema);
158
-
159
- //#endregion
160
- export { connectTrackingPlanSource, createTrackingPlan, deleteTrackingPlan, disconnectTrackingPlanSource, getTrackingPlan, listTrackingPlanRules, listTrackingPlanSources, listTrackingPlanViolations, listTrackingPlans, replaceTrackingPlanRules, updateTrackingPlan };