@keystrokehq/segment 0.0.16 → 0.1.2

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 (185) hide show
  1. package/README.md +10 -104
  2. package/dist/action.cjs +21 -0
  3. package/dist/action.cjs.map +1 -0
  4. package/dist/action.mjs +21 -0
  5. package/dist/action.mjs.map +1 -0
  6. package/dist/actions/add-labels-to-source.cjs +27 -0
  7. package/dist/actions/add-labels-to-source.cjs.map +1 -0
  8. package/dist/actions/add-labels-to-source.d.cts +28 -0
  9. package/dist/actions/add-labels-to-source.d.cts.map +1 -0
  10. package/dist/actions/add-labels-to-source.d.mts +28 -0
  11. package/dist/actions/add-labels-to-source.d.mts.map +1 -0
  12. package/dist/actions/add-labels-to-source.mjs +26 -0
  13. package/dist/actions/add-labels-to-source.mjs.map +1 -0
  14. package/dist/actions/alias.cjs +23 -0
  15. package/dist/actions/alias.cjs.map +1 -0
  16. package/dist/actions/alias.d.cts +23 -0
  17. package/dist/actions/alias.d.cts.map +1 -0
  18. package/dist/actions/alias.d.mts +23 -0
  19. package/dist/actions/alias.d.mts.map +1 -0
  20. package/dist/actions/alias.mjs +20 -0
  21. package/dist/actions/alias.mjs.map +1 -0
  22. package/dist/actions/batch.cjs +21 -0
  23. package/dist/actions/batch.cjs.map +1 -0
  24. package/dist/actions/batch.d.cts +19 -0
  25. package/dist/actions/batch.d.cts.map +1 -0
  26. package/dist/actions/batch.d.mts +19 -0
  27. package/dist/actions/batch.d.mts.map +1 -0
  28. package/dist/actions/batch.mjs +18 -0
  29. package/dist/actions/batch.mjs.map +1 -0
  30. package/dist/actions/delete-source.cjs +17 -0
  31. package/dist/actions/delete-source.cjs.map +1 -0
  32. package/dist/actions/delete-source.d.cts +17 -0
  33. package/dist/actions/delete-source.d.cts.map +1 -0
  34. package/dist/actions/delete-source.d.mts +17 -0
  35. package/dist/actions/delete-source.d.mts.map +1 -0
  36. package/dist/actions/delete-source.mjs +16 -0
  37. package/dist/actions/delete-source.mjs.map +1 -0
  38. package/dist/actions/get-daily-per-source-api-calls-usage.cjs +37 -0
  39. package/dist/actions/get-daily-per-source-api-calls-usage.cjs.map +1 -0
  40. package/dist/actions/get-daily-per-source-api-calls-usage.d.cts +35 -0
  41. package/dist/actions/get-daily-per-source-api-calls-usage.d.cts.map +1 -0
  42. package/dist/actions/get-daily-per-source-api-calls-usage.d.mts +35 -0
  43. package/dist/actions/get-daily-per-source-api-calls-usage.d.mts.map +1 -0
  44. package/dist/actions/get-daily-per-source-api-calls-usage.mjs +36 -0
  45. package/dist/actions/get-daily-per-source-api-calls-usage.mjs.map +1 -0
  46. package/dist/actions/get-destination.cjs +78 -0
  47. package/dist/actions/get-destination.cjs.map +1 -0
  48. package/dist/actions/get-destination.d.cts +71 -0
  49. package/dist/actions/get-destination.d.cts.map +1 -0
  50. package/dist/actions/get-destination.d.mts +71 -0
  51. package/dist/actions/get-destination.d.mts.map +1 -0
  52. package/dist/actions/get-destination.mjs +77 -0
  53. package/dist/actions/get-destination.mjs.map +1 -0
  54. package/dist/actions/group.cjs +25 -0
  55. package/dist/actions/group.cjs.map +1 -0
  56. package/dist/actions/group.d.cts +27 -0
  57. package/dist/actions/group.d.cts.map +1 -0
  58. package/dist/actions/group.d.mts +27 -0
  59. package/dist/actions/group.d.mts.map +1 -0
  60. package/dist/actions/group.mjs +22 -0
  61. package/dist/actions/group.mjs.map +1 -0
  62. package/dist/actions/identify.cjs +25 -0
  63. package/dist/actions/identify.cjs.map +1 -0
  64. package/dist/actions/identify.d.cts +27 -0
  65. package/dist/actions/identify.d.cts.map +1 -0
  66. package/dist/actions/identify.d.mts +27 -0
  67. package/dist/actions/identify.d.mts.map +1 -0
  68. package/dist/actions/identify.mjs +22 -0
  69. package/dist/actions/identify.mjs.map +1 -0
  70. package/dist/actions/import-historical-data.cjs +20 -0
  71. package/dist/actions/import-historical-data.cjs.map +1 -0
  72. package/dist/actions/import-historical-data.d.cts +19 -0
  73. package/dist/actions/import-historical-data.d.cts.map +1 -0
  74. package/dist/actions/import-historical-data.d.mts +19 -0
  75. package/dist/actions/import-historical-data.d.mts.map +1 -0
  76. package/dist/actions/import-historical-data.mjs +17 -0
  77. package/dist/actions/import-historical-data.mjs.map +1 -0
  78. package/dist/actions/index.cjs +35 -0
  79. package/dist/actions/index.d.cts +18 -0
  80. package/dist/actions/index.d.mts +18 -0
  81. package/dist/actions/index.mjs +18 -0
  82. package/dist/actions/list-connected-warehouses-from-source.cjs +55 -0
  83. package/dist/actions/list-connected-warehouses-from-source.cjs.map +1 -0
  84. package/dist/actions/list-connected-warehouses-from-source.d.cts +50 -0
  85. package/dist/actions/list-connected-warehouses-from-source.d.cts.map +1 -0
  86. package/dist/actions/list-connected-warehouses-from-source.d.mts +50 -0
  87. package/dist/actions/list-connected-warehouses-from-source.d.mts.map +1 -0
  88. package/dist/actions/list-connected-warehouses-from-source.mjs +54 -0
  89. package/dist/actions/list-connected-warehouses-from-source.mjs.map +1 -0
  90. package/dist/actions/list-delivery-metrics-summary-from-destination.cjs +41 -0
  91. package/dist/actions/list-delivery-metrics-summary-from-destination.cjs.map +1 -0
  92. package/dist/actions/list-delivery-metrics-summary-from-destination.d.cts +40 -0
  93. package/dist/actions/list-delivery-metrics-summary-from-destination.d.cts.map +1 -0
  94. package/dist/actions/list-delivery-metrics-summary-from-destination.d.mts +40 -0
  95. package/dist/actions/list-delivery-metrics-summary-from-destination.d.mts.map +1 -0
  96. package/dist/actions/list-delivery-metrics-summary-from-destination.mjs +40 -0
  97. package/dist/actions/list-delivery-metrics-summary-from-destination.mjs.map +1 -0
  98. package/dist/actions/list-schema-settings-in-source.cjs +44 -0
  99. package/dist/actions/list-schema-settings-in-source.cjs.map +1 -0
  100. package/dist/actions/list-schema-settings-in-source.d.cts +38 -0
  101. package/dist/actions/list-schema-settings-in-source.d.cts.map +1 -0
  102. package/dist/actions/list-schema-settings-in-source.d.mts +38 -0
  103. package/dist/actions/list-schema-settings-in-source.d.mts.map +1 -0
  104. package/dist/actions/list-schema-settings-in-source.mjs +43 -0
  105. package/dist/actions/list-schema-settings-in-source.mjs.map +1 -0
  106. package/dist/actions/page.cjs +26 -0
  107. package/dist/actions/page.cjs.map +1 -0
  108. package/dist/actions/page.d.cts +29 -0
  109. package/dist/actions/page.d.cts.map +1 -0
  110. package/dist/actions/page.d.mts +29 -0
  111. package/dist/actions/page.d.mts.map +1 -0
  112. package/dist/actions/page.mjs +23 -0
  113. package/dist/actions/page.mjs.map +1 -0
  114. package/dist/actions/remove-source-write-key.cjs +20 -0
  115. package/dist/actions/remove-source-write-key.cjs.map +1 -0
  116. package/dist/actions/remove-source-write-key.d.cts +19 -0
  117. package/dist/actions/remove-source-write-key.d.cts.map +1 -0
  118. package/dist/actions/remove-source-write-key.d.mts +19 -0
  119. package/dist/actions/remove-source-write-key.d.mts.map +1 -0
  120. package/dist/actions/remove-source-write-key.mjs +19 -0
  121. package/dist/actions/remove-source-write-key.mjs.map +1 -0
  122. package/dist/actions/screen.cjs +25 -0
  123. package/dist/actions/screen.cjs.map +1 -0
  124. package/dist/actions/screen.d.cts +27 -0
  125. package/dist/actions/screen.d.cts.map +1 -0
  126. package/dist/actions/screen.d.mts +27 -0
  127. package/dist/actions/screen.d.mts.map +1 -0
  128. package/dist/actions/screen.mjs +22 -0
  129. package/dist/actions/screen.mjs.map +1 -0
  130. package/dist/actions/track.cjs +25 -0
  131. package/dist/actions/track.cjs.map +1 -0
  132. package/dist/actions/track.d.cts +27 -0
  133. package/dist/actions/track.d.cts.map +1 -0
  134. package/dist/actions/track.d.mts +27 -0
  135. package/dist/actions/track.d.mts.map +1 -0
  136. package/dist/actions/track.mjs +22 -0
  137. package/dist/actions/track.mjs.map +1 -0
  138. package/dist/actions/update-source.cjs +51 -0
  139. package/dist/actions/update-source.cjs.map +1 -0
  140. package/dist/actions/update-source.d.cts +50 -0
  141. package/dist/actions/update-source.d.cts.map +1 -0
  142. package/dist/actions/update-source.d.mts +50 -0
  143. package/dist/actions/update-source.d.mts.map +1 -0
  144. package/dist/actions/update-source.mjs +50 -0
  145. package/dist/actions/update-source.mjs.map +1 -0
  146. package/dist/app.cjs +9 -0
  147. package/dist/app.cjs.map +1 -0
  148. package/dist/app.d.cts +5 -0
  149. package/dist/app.d.cts.map +1 -0
  150. package/dist/app.d.mts +5 -0
  151. package/dist/app.d.mts.map +1 -0
  152. package/dist/app.mjs +10 -0
  153. package/dist/app.mjs.map +1 -0
  154. package/dist/catalog.cjs +27 -0
  155. package/dist/catalog.cjs.map +1 -0
  156. package/dist/catalog.d.cts +26 -0
  157. package/dist/catalog.d.cts.map +1 -0
  158. package/dist/catalog.d.mts +26 -0
  159. package/dist/catalog.d.mts.map +1 -0
  160. package/dist/catalog.mjs +27 -0
  161. package/dist/catalog.mjs.map +1 -0
  162. package/dist/execute.cjs +18 -0
  163. package/dist/execute.cjs.map +1 -0
  164. package/dist/execute.mjs +18 -0
  165. package/dist/execute.mjs.map +1 -0
  166. package/dist/index.cjs +40 -0
  167. package/dist/index.d.cts +20 -0
  168. package/dist/index.d.mts +20 -4
  169. package/dist/index.mjs +21 -5
  170. package/package.json +31 -60
  171. package/LICENSE +0 -21
  172. package/dist/client-DQfeZzLR.mjs +0 -362
  173. package/dist/common-DUU0airJ.mjs +0 -56
  174. package/dist/credential-sets/index.d.mts +0 -2
  175. package/dist/credential-sets/index.mjs +0 -3
  176. package/dist/operations/index.d.mts +0 -2
  177. package/dist/operations/index.mjs +0 -3
  178. package/dist/schemas/index.d.mts +0 -57
  179. package/dist/schemas/index.mjs +0 -3
  180. package/dist/segment.credential-set-BTTrkHO7.mjs +0 -33
  181. package/dist/segment.credential-set-BgROtI_9.d.mts +0 -57
  182. package/dist/triggers/index.d.mts +0 -110
  183. package/dist/triggers/index.mjs +0 -367
  184. package/dist/workspace-list-spaces.operation-DKWX3vl5.mjs +0 -5200
  185. package/dist/workspace-list-spaces.operation-DNIUfIuv.d.mts +0 -6548
@@ -1,57 +0,0 @@
1
- import { CredentialSet } from "@keystrokehq/core";
2
- import { z } from "zod";
3
- import { InferCredentialSetAuth } from "@keystrokehq/core/credential-set";
4
-
5
- //#region src/credential-sets/segment.credential-set.d.ts
6
- declare const segmentRegionSchema: z.ZodEnum<{
7
- us: "us";
8
- eu: "eu";
9
- }>;
10
- declare const segmentAuthSchema: z.ZodObject<{
11
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
12
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
13
- us: "us";
14
- eu: "eu";
15
- }>>;
16
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
17
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
18
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
19
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
20
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
21
- }, z.core.$strip>;
22
- /**
23
- * Segment integration — manual credential model spanning Public API, Tracking
24
- * API, and Profile API surfaces on a single connection.
25
- */
26
- declare const segmentCredentialSet: CredentialSet<"segment", z.ZodObject<{
27
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
28
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
29
- us: "us";
30
- eu: "eu";
31
- }>>;
32
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
33
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
34
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
35
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
36
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
37
- }, z.core.$strip>, {
38
- id: string;
39
- kind: "manual";
40
- label: string;
41
- input: z.ZodObject<{
42
- SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
43
- SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
44
- us: "us";
45
- eu: "eu";
46
- }>>;
47
- SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
48
- SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
49
- SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
50
- SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
51
- SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
52
- }, z.core.$strip>;
53
- }[]>;
54
- type SegmentCredentials = InferCredentialSetAuth<typeof segmentCredentialSet>;
55
- type SegmentRegion = z.infer<typeof segmentRegionSchema>;
56
- //#endregion
57
- export { segmentRegionSchema as a, segmentCredentialSet as i, SegmentRegion as n, segmentAuthSchema as r, SegmentCredentials as t };
@@ -1,110 +0,0 @@
1
- import { i as segmentCredentialSet } from "../segment.credential-set-BgROtI_9.mjs";
2
- import { BoundTrigger } from "@keystrokehq/core";
3
- import { z } from "zod";
4
- import { PollingTriggerManifest } from "@keystrokehq/core/trigger";
5
-
6
- //#region src/events/index.d.ts
7
- declare const segmentReverseEtlRunEventSchema: z.ZodObject<{
8
- runId: z.ZodString;
9
- modelId: z.ZodString;
10
- status: z.ZodEnum<{
11
- IN_PROGRESS: "IN_PROGRESS";
12
- SUCCEEDED: "SUCCEEDED";
13
- FAILED: "FAILED";
14
- }>;
15
- startedAt: z.ZodOptional<z.ZodString>;
16
- finishedAt: z.ZodOptional<z.ZodString>;
17
- error: z.ZodOptional<z.ZodString>;
18
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
19
- }, z.core.$strip>;
20
- type SegmentReverseEtlRunEvent = z.infer<typeof segmentReverseEtlRunEventSchema>;
21
- declare const segmentFunctionVersionEventSchema: z.ZodObject<{
22
- functionId: z.ZodString;
23
- versionId: z.ZodString;
24
- createdAt: z.ZodOptional<z.ZodString>;
25
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
26
- }, z.core.$strip>;
27
- type SegmentFunctionVersionEvent = z.infer<typeof segmentFunctionVersionEventSchema>;
28
- declare const segmentAudienceSyncEventSchema: z.ZodObject<{
29
- syncId: z.ZodString;
30
- audienceId: z.ZodString;
31
- spaceId: z.ZodString;
32
- status: z.ZodEnum<{
33
- success: "success";
34
- partial: "partial";
35
- failed: "failed";
36
- }>;
37
- finishedAt: z.ZodOptional<z.ZodString>;
38
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
39
- }, z.core.$strip>;
40
- type SegmentAudienceSyncEvent = z.infer<typeof segmentAudienceSyncEventSchema>;
41
- declare const segmentSourceCreatedEventSchema: z.ZodObject<{
42
- sourceId: z.ZodString;
43
- name: z.ZodOptional<z.ZodString>;
44
- createdAt: z.ZodOptional<z.ZodString>;
45
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
46
- }, z.core.$strip>;
47
- type SegmentSourceCreatedEvent = z.infer<typeof segmentSourceCreatedEventSchema>;
48
- declare const segmentDestinationCreatedEventSchema: z.ZodObject<{
49
- destinationId: z.ZodString;
50
- name: z.ZodOptional<z.ZodString>;
51
- sourceId: z.ZodOptional<z.ZodString>;
52
- createdAt: z.ZodOptional<z.ZodString>;
53
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
54
- }, z.core.$strip>;
55
- type SegmentDestinationCreatedEvent = z.infer<typeof segmentDestinationCreatedEventSchema>;
56
- declare const segmentTrackingPlanViolationEventSchema: z.ZodObject<{
57
- violationId: z.ZodString;
58
- eventName: z.ZodOptional<z.ZodString>;
59
- trackingPlanId: z.ZodOptional<z.ZodString>;
60
- sourceId: z.ZodOptional<z.ZodString>;
61
- messageId: z.ZodOptional<z.ZodString>;
62
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
63
- }, z.core.$strip>;
64
- type SegmentTrackingPlanViolationEvent = z.infer<typeof segmentTrackingPlanViolationEventSchema>;
65
- declare const segmentDeletionRegulationEventSchema: z.ZodObject<{
66
- regulationId: z.ZodString;
67
- regulationType: z.ZodOptional<z.ZodString>;
68
- finishedAt: z.ZodOptional<z.ZodString>;
69
- raw: z.ZodRecord<z.ZodString, z.ZodUnknown>;
70
- }, z.core.$strip>;
71
- type SegmentDeletionRegulationEvent = z.infer<typeof segmentDeletionRegulationEventSchema>;
72
- //#endregion
73
- //#region src/triggers/polling.d.ts
74
- type SegmentCredentialSets = readonly [typeof segmentCredentialSet];
75
- type SegmentPollingBindingOptions<TEvent, TOutput = TEvent> = IntegrationTriggerBindingOptions<TEvent, TOutput> & {
76
- readonly schedule?: string;
77
- };
78
- type SegmentPollingBoundTrigger<TEvent, TOutput = TEvent> = BoundTrigger<TEvent, SegmentCredentialSets, PollingTriggerManifest, TOutput>;
79
- interface AudienceSyncPollParams {
80
- readonly spaceId: string;
81
- readonly audienceId: string;
82
- }
83
- declare function audienceSyncCompleted<TOutput = SegmentAudienceSyncEvent>(params: AudienceSyncPollParams, options?: SegmentPollingBindingOptions<SegmentAudienceSyncEvent, TOutput>): SegmentPollingBoundTrigger<SegmentAudienceSyncEvent, TOutput>;
84
- interface ReverseEtlRunPollParams {
85
- readonly modelId: string;
86
- }
87
- declare function reverseEtlRunSucceeded<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
88
- declare function reverseEtlRunFailed<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
89
- declare function reverseEtlRunStarted<TOutput = SegmentReverseEtlRunEvent>(params: ReverseEtlRunPollParams, options?: SegmentPollingBindingOptions<SegmentReverseEtlRunEvent, TOutput>): SegmentPollingBoundTrigger<SegmentReverseEtlRunEvent, TOutput>;
90
- interface FunctionVersionPollParams {
91
- readonly functionId: string;
92
- }
93
- declare function functionsDeploymentCompleted<TOutput = SegmentFunctionVersionEvent>(params: FunctionVersionPollParams, options?: SegmentPollingBindingOptions<SegmentFunctionVersionEvent, TOutput>): SegmentPollingBoundTrigger<SegmentFunctionVersionEvent, TOutput>;
94
- declare function trackingPlanViolationDetected<TOutput = SegmentTrackingPlanViolationEvent>(options?: SegmentPollingBindingOptions<SegmentTrackingPlanViolationEvent, TOutput>): SegmentPollingBoundTrigger<SegmentTrackingPlanViolationEvent, TOutput>;
95
- declare function sourceCreated<TOutput = SegmentSourceCreatedEvent>(options?: SegmentPollingBindingOptions<SegmentSourceCreatedEvent, TOutput>): SegmentPollingBoundTrigger<SegmentSourceCreatedEvent, TOutput>;
96
- declare function destinationCreated<TOutput = SegmentDestinationCreatedEvent>(options?: SegmentPollingBindingOptions<SegmentDestinationCreatedEvent, TOutput>): SegmentPollingBoundTrigger<SegmentDestinationCreatedEvent, TOutput>;
97
- declare function deletionRegulationCompleted<TOutput = SegmentDeletionRegulationEvent>(options?: SegmentPollingBindingOptions<SegmentDeletionRegulationEvent, TOutput>): SegmentPollingBoundTrigger<SegmentDeletionRegulationEvent, TOutput>;
98
- declare const polling: Readonly<{
99
- audienceSyncCompleted: typeof audienceSyncCompleted;
100
- reverseEtlRunSucceeded: typeof reverseEtlRunSucceeded;
101
- reverseEtlRunFailed: typeof reverseEtlRunFailed;
102
- reverseEtlRunStarted: typeof reverseEtlRunStarted;
103
- functionsDeploymentCompleted: typeof functionsDeploymentCompleted;
104
- trackingPlanViolationDetected: typeof trackingPlanViolationDetected;
105
- sourceCreated: typeof sourceCreated;
106
- destinationCreated: typeof destinationCreated;
107
- deletionRegulationCompleted: typeof deletionRegulationCompleted;
108
- }>;
109
- //#endregion
110
- export { type AudienceSyncPollParams, type FunctionVersionPollParams, type ReverseEtlRunPollParams, audienceSyncCompleted, deletionRegulationCompleted, destinationCreated, functionsDeploymentCompleted, polling, reverseEtlRunFailed, reverseEtlRunStarted, reverseEtlRunSucceeded, sourceCreated, trackingPlanViolationDetected };
@@ -1,367 +0,0 @@
1
- import { n as segmentCredentialSet } from "../segment.credential-set-BTTrkHO7.mjs";
2
- import { a as segmentLooseObjectSchema } from "../common-DUU0airJ.mjs";
3
- import { t as createSegmentClient } from "../client-DQfeZzLR.mjs";
4
- import { z } from "zod";
5
- import { pollingTrigger } from "@keystrokehq/core/trigger";
6
-
7
- //#region ../../packages/integration-authoring/dist/index.mjs
8
- const IntegrationConfigSchema = z.object({
9
- id: z.string().min(1),
10
- name: z.string().min(1),
11
- description: z.string().optional()
12
- });
13
- function resolveMetadata(metadata, defaults) {
14
- return {
15
- id: metadata?.id ?? defaults.defaultId,
16
- description: metadata?.description ?? defaults.defaultDescription
17
- };
18
- }
19
- function resolveAuthorPayload(payload, mapPayload) {
20
- if (!mapPayload) return payload;
21
- return mapPayload(payload);
22
- }
23
- function createIntegrationTriggerBindingFactory(config) {
24
- const bind = (options) => {
25
- const resolvedMetadata = resolveMetadata(options, config);
26
- const baseTrigger = config.createBaseTrigger(resolvedMetadata);
27
- const userTransform = options?.transform;
28
- return baseTrigger({ transform: userTransform || config.mapPayload ? (runtimePayload, request) => {
29
- const authorPayload = resolveAuthorPayload(runtimePayload, config.mapPayload);
30
- if (authorPayload === null) throw new Error(`Trigger "${resolvedMetadata.id}" mapPayload returned null after the trigger filter passed; tighten the trigger filter schema.`);
31
- if (!userTransform) return authorPayload;
32
- return userTransform(authorPayload, request);
33
- } : void 0 });
34
- };
35
- return Object.freeze(bind);
36
- }
37
- function createPollingTriggerBindingFactory(config) {
38
- return createIntegrationTriggerBindingFactory({
39
- defaultId: config.defaultId,
40
- defaultDescription: config.defaultDescription,
41
- mapPayload: config.mapPayload,
42
- createBaseTrigger: (metadata) => pollingTrigger({
43
- id: metadata.id,
44
- description: metadata.description,
45
- schedule: config.schedule,
46
- response: config.response,
47
- poll: config.poll,
48
- ...config.credentialSets ? { credentialSets: config.credentialSets } : {},
49
- ...config.filter ? { filter: config.filter } : {}
50
- })
51
- });
52
- }
53
-
54
- //#endregion
55
- //#region src/events/index.ts
56
- /**
57
- * segment/events.ts
58
- *
59
- * Curated trigger-event schemas. Segment does not publish a unified webhook
60
- * event catalog — each destination shape (Webhook destination, Monitoring
61
- * alert webhook, Functions runtime webhook) carries its own body. We define
62
- * the author-visible shapes here and parse the raw payload into them in
63
- * `triggers.ts`.
64
- */
65
- /** Loose envelope a Segment Webhook destination delivers for Engage
66
- * audiences: the destination wraps the Engage event as a Segment "track"
67
- * call with properties carrying audience state. */
68
- const segmentAudienceWebhookEnvelopeSchema = segmentLooseObjectSchema({
69
- type: z.string().optional(),
70
- event: z.string().optional(),
71
- userId: z.string().optional(),
72
- anonymousId: z.string().optional(),
73
- messageId: z.string().optional(),
74
- timestamp: z.string().optional(),
75
- traits: z.record(z.string(), z.unknown()).optional(),
76
- properties: z.record(z.string(), z.unknown()).optional(),
77
- context: z.record(z.string(), z.unknown()).optional()
78
- });
79
- /** Monitoring alert webhook envelope (fired for delivery-failure spikes,
80
- * function invocation errors, etc.). */
81
- const segmentMonitoringAlertEnvelopeSchema = segmentLooseObjectSchema({
82
- id: z.string().optional(),
83
- subscriptionId: z.string().optional(),
84
- eventType: z.string().optional(),
85
- severity: z.string().optional(),
86
- firedAt: z.string().optional(),
87
- message: z.string().optional(),
88
- sourceId: z.string().optional(),
89
- destinationId: z.string().optional(),
90
- functionId: z.string().optional(),
91
- metadata: z.record(z.string(), z.unknown()).optional()
92
- });
93
- const segmentAudienceEventSchema = z.object({
94
- type: z.enum(["entered", "exited"]),
95
- audienceKey: z.string(),
96
- userId: z.string().optional(),
97
- anonymousId: z.string().optional(),
98
- profileId: z.string().optional(),
99
- traits: z.record(z.string(), z.unknown()).optional(),
100
- properties: z.record(z.string(), z.unknown()).optional(),
101
- messageId: z.string().optional(),
102
- timestamp: z.string().optional(),
103
- raw: segmentAudienceWebhookEnvelopeSchema
104
- });
105
- const segmentComputedTraitEventSchema = z.object({
106
- traitKey: z.string(),
107
- value: z.unknown(),
108
- userId: z.string().optional(),
109
- profileId: z.string().optional(),
110
- messageId: z.string().optional(),
111
- timestamp: z.string().optional(),
112
- raw: segmentAudienceWebhookEnvelopeSchema
113
- });
114
- const segmentMonitoringEventSchema = z.object({
115
- alertId: z.string(),
116
- eventType: z.string(),
117
- severity: z.string().optional(),
118
- firedAt: z.string().optional(),
119
- sourceId: z.string().optional(),
120
- destinationId: z.string().optional(),
121
- functionId: z.string().optional(),
122
- message: z.string().optional(),
123
- raw: segmentMonitoringAlertEnvelopeSchema
124
- });
125
- const segmentReverseEtlRunEventSchema = z.object({
126
- runId: z.string(),
127
- modelId: z.string(),
128
- status: z.enum([
129
- "IN_PROGRESS",
130
- "SUCCEEDED",
131
- "FAILED"
132
- ]),
133
- startedAt: z.string().optional(),
134
- finishedAt: z.string().optional(),
135
- error: z.string().optional(),
136
- raw: z.record(z.string(), z.unknown())
137
- });
138
- const segmentFunctionVersionEventSchema = z.object({
139
- functionId: z.string(),
140
- versionId: z.string(),
141
- createdAt: z.string().optional(),
142
- raw: z.record(z.string(), z.unknown())
143
- });
144
- const segmentAudienceSyncEventSchema = z.object({
145
- syncId: z.string(),
146
- audienceId: z.string(),
147
- spaceId: z.string(),
148
- status: z.enum([
149
- "success",
150
- "partial",
151
- "failed"
152
- ]),
153
- finishedAt: z.string().optional(),
154
- raw: z.record(z.string(), z.unknown())
155
- });
156
- const segmentSourceCreatedEventSchema = z.object({
157
- sourceId: z.string(),
158
- name: z.string().optional(),
159
- createdAt: z.string().optional(),
160
- raw: z.record(z.string(), z.unknown())
161
- });
162
- const segmentDestinationCreatedEventSchema = z.object({
163
- destinationId: z.string(),
164
- name: z.string().optional(),
165
- sourceId: z.string().optional(),
166
- createdAt: z.string().optional(),
167
- raw: z.record(z.string(), z.unknown())
168
- });
169
- const segmentTrackingPlanViolationEventSchema = z.object({
170
- violationId: z.string(),
171
- eventName: z.string().optional(),
172
- trackingPlanId: z.string().optional(),
173
- sourceId: z.string().optional(),
174
- messageId: z.string().optional(),
175
- raw: z.record(z.string(), z.unknown())
176
- });
177
- const segmentDeletionRegulationEventSchema = z.object({
178
- regulationId: z.string(),
179
- regulationType: z.string().optional(),
180
- finishedAt: z.string().optional(),
181
- raw: z.record(z.string(), z.unknown())
182
- });
183
-
184
- //#endregion
185
- //#region src/triggers/polling.ts
186
- function buildPollingBinding(definition, options) {
187
- const schedule = options?.schedule ?? definition.defaultSchedule;
188
- return createPollingTriggerBindingFactory({
189
- defaultId: definition.defaultId,
190
- defaultDescription: definition.defaultDescription,
191
- schedule,
192
- credentialSets: [segmentCredentialSet],
193
- response: definition.eventSchema,
194
- poll: async (ctx) => {
195
- const credentials = ctx.credentials.segment;
196
- return definition.poll(credentials, ctx.lastPolledAt);
197
- }
198
- })({
199
- ...options?.id ? { id: options.id } : {},
200
- ...options?.description ? { description: options.description } : {},
201
- ...options?.transform ? { transform: options.transform } : {}
202
- });
203
- }
204
- function audienceSyncCompleted(params, options) {
205
- return buildPollingBinding({
206
- defaultId: "segment.audience-sync-completed",
207
- defaultDescription: `Poll /spaces/${params.spaceId}/audiences/${params.audienceId}/syncs and emit the most recent completed sync.`,
208
- defaultSchedule: "5m",
209
- eventSchema: segmentAudienceSyncEventSchema,
210
- poll: async (credentials) => {
211
- const rec = await createSegmentClient(credentials).publicApi.request(`/spaces/${encodeURIComponent(params.spaceId)}/audiences/${encodeURIComponent(params.audienceId)}/syncs`);
212
- const obj = (rec.data?.syncs ?? rec.syncs ?? [])[0] ?? {};
213
- return segmentAudienceSyncEventSchema.parse({
214
- syncId: obj.id ?? "unknown",
215
- audienceId: params.audienceId,
216
- spaceId: params.spaceId,
217
- status: obj.status ?? "success",
218
- ...typeof obj.finishedAt === "string" ? { finishedAt: obj.finishedAt } : {},
219
- raw: obj
220
- });
221
- }
222
- }, options);
223
- }
224
- function reverseEtlRunPollDefinition(params, status, label) {
225
- return {
226
- defaultId: `segment.reverse-etl-run-${label}`,
227
- defaultDescription: `Poll /reverse-etl-models/${params.modelId}/runs and emit the latest run that is ${status}.`,
228
- defaultSchedule: "5m",
229
- eventSchema: segmentReverseEtlRunEventSchema,
230
- poll: async (credentials) => {
231
- const rec = await createSegmentClient(credentials).publicApi.request(`/reverse-etl-models/${encodeURIComponent(params.modelId)}/runs`);
232
- const obj = (rec.data?.runs ?? rec.runs ?? []).find((run) => {
233
- if (!run || typeof run !== "object") return false;
234
- return run.status === status;
235
- }) ?? {};
236
- return segmentReverseEtlRunEventSchema.parse({
237
- runId: obj.id ?? "unknown",
238
- modelId: params.modelId,
239
- status,
240
- ...typeof obj.startedAt === "string" ? { startedAt: obj.startedAt } : {},
241
- ...typeof obj.finishedAt === "string" ? { finishedAt: obj.finishedAt } : {},
242
- ...typeof obj.error === "string" ? { error: obj.error } : {},
243
- raw: obj
244
- });
245
- }
246
- };
247
- }
248
- function reverseEtlRunSucceeded(params, options) {
249
- return buildPollingBinding(reverseEtlRunPollDefinition(params, "SUCCEEDED", "succeeded"), options);
250
- }
251
- function reverseEtlRunFailed(params, options) {
252
- return buildPollingBinding(reverseEtlRunPollDefinition(params, "FAILED", "failed"), options);
253
- }
254
- function reverseEtlRunStarted(params, options) {
255
- return buildPollingBinding(reverseEtlRunPollDefinition(params, "IN_PROGRESS", "started"), options);
256
- }
257
- function functionsDeploymentCompleted(params, options) {
258
- return buildPollingBinding({
259
- defaultId: "segment.functions-deployment-completed",
260
- defaultDescription: `Poll /functions/${params.functionId}/versions and emit the latest version.`,
261
- defaultSchedule: "5m",
262
- eventSchema: segmentFunctionVersionEventSchema,
263
- poll: async (credentials) => {
264
- const rec = await createSegmentClient(credentials).publicApi.request(`/functions/${encodeURIComponent(params.functionId)}/versions`);
265
- const obj = (rec.data?.versions ?? rec.versions ?? [])[0] ?? {};
266
- return segmentFunctionVersionEventSchema.parse({
267
- functionId: params.functionId,
268
- versionId: obj.id ?? "unknown",
269
- ...typeof obj.createdAt === "string" ? { createdAt: obj.createdAt } : {},
270
- raw: obj
271
- });
272
- }
273
- }, options);
274
- }
275
- function trackingPlanViolationDetected(options) {
276
- return buildPollingBinding({
277
- defaultId: "segment.tracking-plan-violation-detected",
278
- defaultDescription: "Poll /events/violations and emit the most recent violation.",
279
- defaultSchedule: "10m",
280
- eventSchema: segmentTrackingPlanViolationEventSchema,
281
- poll: async (credentials) => {
282
- const rec = await createSegmentClient(credentials).publicApi.request("/events/violations");
283
- const obj = (rec.data?.violations ?? rec.violations ?? [])[0] ?? {};
284
- return segmentTrackingPlanViolationEventSchema.parse({
285
- violationId: obj.id ?? "unknown",
286
- ...typeof obj.eventName === "string" ? { eventName: obj.eventName } : {},
287
- ...typeof obj.trackingPlanId === "string" ? { trackingPlanId: obj.trackingPlanId } : {},
288
- ...typeof obj.sourceId === "string" ? { sourceId: obj.sourceId } : {},
289
- ...typeof obj.messageId === "string" ? { messageId: obj.messageId } : {},
290
- raw: obj
291
- });
292
- }
293
- }, options);
294
- }
295
- function sourceCreated(options) {
296
- return buildPollingBinding({
297
- defaultId: "segment.source-created",
298
- defaultDescription: "Poll /sources and emit the most recent source.",
299
- defaultSchedule: "10m",
300
- eventSchema: segmentSourceCreatedEventSchema,
301
- poll: async (credentials) => {
302
- const rec = await createSegmentClient(credentials).publicApi.request("/sources");
303
- const obj = (rec.data?.sources ?? rec.sources ?? [])[0] ?? {};
304
- return segmentSourceCreatedEventSchema.parse({
305
- sourceId: obj.id ?? "unknown",
306
- ...typeof obj.name === "string" ? { name: obj.name } : {},
307
- ...typeof obj.createdAt === "string" ? { createdAt: obj.createdAt } : {},
308
- raw: obj
309
- });
310
- }
311
- }, options);
312
- }
313
- function destinationCreated(options) {
314
- return buildPollingBinding({
315
- defaultId: "segment.destination-created",
316
- defaultDescription: "Poll /destinations and emit the most recent destination.",
317
- defaultSchedule: "10m",
318
- eventSchema: segmentDestinationCreatedEventSchema,
319
- poll: async (credentials) => {
320
- const rec = await createSegmentClient(credentials).publicApi.request("/destinations");
321
- const obj = (rec.data?.destinations ?? rec.destinations ?? [])[0] ?? {};
322
- return segmentDestinationCreatedEventSchema.parse({
323
- destinationId: obj.id ?? "unknown",
324
- ...typeof obj.name === "string" ? { name: obj.name } : {},
325
- ...typeof obj.sourceId === "string" ? { sourceId: obj.sourceId } : {},
326
- ...typeof obj.createdAt === "string" ? { createdAt: obj.createdAt } : {},
327
- raw: obj
328
- });
329
- }
330
- }, options);
331
- }
332
- function deletionRegulationCompleted(options) {
333
- return buildPollingBinding({
334
- defaultId: "segment.deletion-regulation-completed",
335
- defaultDescription: "Poll /workspace/regulations for finished GDPR regulations.",
336
- defaultSchedule: "15m",
337
- eventSchema: segmentDeletionRegulationEventSchema,
338
- poll: async (credentials) => {
339
- const rec = await createSegmentClient(credentials).publicApi.request("/workspace/regulations");
340
- const obj = (rec.data?.regulations ?? rec.regulations ?? []).find((r) => {
341
- if (!r || typeof r !== "object") return false;
342
- const record = r;
343
- return typeof record.finishedAt === "string" && record.finishedAt.length > 0;
344
- }) ?? {};
345
- return segmentDeletionRegulationEventSchema.parse({
346
- regulationId: obj.id ?? "unknown",
347
- ...typeof obj.regulationType === "string" ? { regulationType: obj.regulationType } : {},
348
- ...typeof obj.finishedAt === "string" ? { finishedAt: obj.finishedAt } : {},
349
- raw: obj
350
- });
351
- }
352
- }, options);
353
- }
354
- const polling = Object.freeze({
355
- audienceSyncCompleted,
356
- reverseEtlRunSucceeded,
357
- reverseEtlRunFailed,
358
- reverseEtlRunStarted,
359
- functionsDeploymentCompleted,
360
- trackingPlanViolationDetected,
361
- sourceCreated,
362
- destinationCreated,
363
- deletionRegulationCompleted
364
- });
365
-
366
- //#endregion
367
- export { audienceSyncCompleted, deletionRegulationCompleted, destinationCreated, functionsDeploymentCompleted, polling, reverseEtlRunFailed, reverseEtlRunStarted, reverseEtlRunSucceeded, sourceCreated, trackingPlanViolationDetected };