@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.
- package/README.md +52 -173
- package/dist/{client.mjs → client-DQfeZzLR.mjs} +28 -3
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +3 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +5 -1
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/schemas/index.mjs +1 -1
- package/dist/{integration-CliT2xe3.mjs → segment.credential-set-BTTrkHO7.mjs} +16 -9
- package/dist/{integration-DWeMeBqQ.d.mts → segment.credential-set-BgROtI_9.d.mts} +28 -27
- package/dist/{triggers.d.mts → triggers/index.d.mts} +72 -6
- package/dist/{triggers.mjs → triggers/index.mjs} +186 -7
- package/dist/workspace-list-spaces.operation-DKWX3vl5.mjs +5200 -0
- package/dist/workspace-list-spaces.operation-QbDIgfRG.d.mts +6548 -0
- package/package.json +14 -126
- package/dist/_official/index.d.mts +0 -2
- package/dist/_official/index.mjs +0 -3
- package/dist/_runtime/index.d.mts +0 -1
- package/dist/_runtime/index.mjs +0 -1
- package/dist/audiences.d.mts +0 -193
- package/dist/audiences.mjs +0 -205
- package/dist/client.d.mts +0 -90
- package/dist/computed-traits.d.mts +0 -148
- package/dist/computed-traits.mjs +0 -149
- package/dist/connection.d.mts +0 -2
- package/dist/connection.mjs +0 -3
- package/dist/crud-DGM2Ekdr.mjs +0 -140
- package/dist/deletion-suppression.d.mts +0 -135
- package/dist/deletion-suppression.mjs +0 -103
- package/dist/delivery-overview.d.mts +0 -56
- package/dist/delivery-overview.mjs +0 -54
- package/dist/destination-filters.d.mts +0 -134
- package/dist/destination-filters.mjs +0 -115
- package/dist/destinations.d.mts +0 -318
- package/dist/destinations.mjs +0 -257
- package/dist/edge-functions.d.mts +0 -112
- package/dist/edge-functions.mjs +0 -72
- package/dist/errors-4FGnrowW.mjs +0 -27
- package/dist/events-catalog.d.mts +0 -77
- package/dist/events-catalog.mjs +0 -65
- package/dist/events.d.mts +0 -167
- package/dist/events.mjs +0 -134
- package/dist/factory-Dqb49Dfj.mjs +0 -8
- package/dist/functions.d.mts +0 -236
- package/dist/functions.mjs +0 -180
- package/dist/iam-groups.d.mts +0 -184
- package/dist/iam-groups.mjs +0 -144
- package/dist/iam-users.d.mts +0 -138
- package/dist/iam-users.mjs +0 -91
- package/dist/labels.d.mts +0 -66
- package/dist/labels.mjs +0 -58
- package/dist/monitoring.d.mts +0 -126
- package/dist/monitoring.mjs +0 -88
- package/dist/profiles-sync.d.mts +0 -82
- package/dist/profiles-sync.mjs +0 -89
- package/dist/profiles.d.mts +0 -130
- package/dist/profiles.mjs +0 -137
- package/dist/reverse-etl.d.mts +0 -315
- package/dist/reverse-etl.mjs +0 -228
- package/dist/roles.d.mts +0 -36
- package/dist/roles.mjs +0 -25
- package/dist/sources.d.mts +0 -383
- package/dist/sources.mjs +0 -259
- package/dist/tracking-plans.d.mts +0 -229
- package/dist/tracking-plans.mjs +0 -160
- package/dist/tracking.d.mts +0 -410
- package/dist/tracking.mjs +0 -255
- package/dist/transformations.d.mts +0 -132
- package/dist/transformations.mjs +0 -83
- package/dist/usage.d.mts +0 -47
- package/dist/usage.mjs +0 -55
- package/dist/verification.d.mts +0 -17
- package/dist/verification.mjs +0 -51
- package/dist/warehouses.d.mts +0 -219
- package/dist/warehouses.mjs +0 -176
- package/dist/workspaces.d.mts +0 -61
- package/dist/workspaces.mjs +0 -67
- /package/dist/{common-CdGiJbjq.mjs → common-DUU0airJ.mjs} +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import * as _keystrokehq_core0 from "@keystrokehq/core";
|
|
3
|
-
|
|
4
|
-
//#region src/computed-traits.d.ts
|
|
5
|
-
declare const computedTraitSchema: z.ZodObject<{
|
|
6
|
-
id: z.ZodString;
|
|
7
|
-
key: z.ZodOptional<z.ZodString>;
|
|
8
|
-
name: z.ZodOptional<z.ZodString>;
|
|
9
|
-
description: z.ZodOptional<z.ZodString>;
|
|
10
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
13
|
-
declare const listComputedTraits: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
14
|
-
spaceId: z.ZodString;
|
|
15
|
-
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
pageToken: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
18
|
-
items: z.ZodArray<z.ZodObject<{
|
|
19
|
-
id: z.ZodString;
|
|
20
|
-
key: z.ZodOptional<z.ZodString>;
|
|
21
|
-
name: z.ZodOptional<z.ZodString>;
|
|
22
|
-
description: z.ZodOptional<z.ZodString>;
|
|
23
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
24
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
-
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
26
|
-
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
27
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", 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>;
|
|
39
|
-
declare const getComputedTrait: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
40
|
-
spaceId: z.ZodString;
|
|
41
|
-
id: z.ZodString;
|
|
42
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
-
id: z.ZodString;
|
|
44
|
-
key: z.ZodOptional<z.ZodString>;
|
|
45
|
-
name: z.ZodOptional<z.ZodString>;
|
|
46
|
-
description: z.ZodOptional<z.ZodString>;
|
|
47
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
48
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
50
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
51
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
52
|
-
us: "us";
|
|
53
|
-
eu: "eu";
|
|
54
|
-
}>>;
|
|
55
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
56
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
57
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
58
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
59
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
60
|
-
}, z.core.$strip>>], undefined>;
|
|
61
|
-
declare const createComputedTrait: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
62
|
-
spaceId: z.ZodString;
|
|
63
|
-
name: z.ZodString;
|
|
64
|
-
description: z.ZodOptional<z.ZodString>;
|
|
65
|
-
definition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
-
id: z.ZodString;
|
|
69
|
-
key: z.ZodOptional<z.ZodString>;
|
|
70
|
-
name: z.ZodOptional<z.ZodString>;
|
|
71
|
-
description: z.ZodOptional<z.ZodString>;
|
|
72
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
73
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
75
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
76
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
77
|
-
us: "us";
|
|
78
|
-
eu: "eu";
|
|
79
|
-
}>>;
|
|
80
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
81
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
82
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
83
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
84
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
85
|
-
}, z.core.$strip>>], undefined>;
|
|
86
|
-
declare const updateComputedTrait: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
87
|
-
spaceId: z.ZodString;
|
|
88
|
-
id: z.ZodString;
|
|
89
|
-
name: z.ZodOptional<z.ZodString>;
|
|
90
|
-
description: z.ZodOptional<z.ZodString>;
|
|
91
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
92
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
94
|
-
id: z.ZodString;
|
|
95
|
-
key: z.ZodOptional<z.ZodString>;
|
|
96
|
-
name: z.ZodOptional<z.ZodString>;
|
|
97
|
-
description: z.ZodOptional<z.ZodString>;
|
|
98
|
-
definition: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
99
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
101
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
102
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
103
|
-
us: "us";
|
|
104
|
-
eu: "eu";
|
|
105
|
-
}>>;
|
|
106
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
107
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
108
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
109
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
110
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
111
|
-
}, z.core.$strip>>], undefined>;
|
|
112
|
-
declare const deleteComputedTrait: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
113
|
-
spaceId: z.ZodString;
|
|
114
|
-
id: z.ZodString;
|
|
115
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
116
|
-
deleted: z.ZodLiteral<true>;
|
|
117
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
118
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
119
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
120
|
-
us: "us";
|
|
121
|
-
eu: "eu";
|
|
122
|
-
}>>;
|
|
123
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
124
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
125
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
126
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
127
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
128
|
-
}, z.core.$strip>>], undefined>;
|
|
129
|
-
declare const previewComputedTrait: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
130
|
-
spaceId: z.ZodString;
|
|
131
|
-
definition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
132
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
133
|
-
count: z.ZodOptional<z.ZodNumber>;
|
|
134
|
-
sample: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
135
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
136
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
137
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
138
|
-
us: "us";
|
|
139
|
-
eu: "eu";
|
|
140
|
-
}>>;
|
|
141
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
142
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
143
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
144
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
145
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
146
|
-
}, z.core.$strip>>], undefined>;
|
|
147
|
-
//#endregion
|
|
148
|
-
export { computedTraitSchema, createComputedTrait, deleteComputedTrait, getComputedTrait, listComputedTraits, previewComputedTrait, updateComputedTrait };
|
package/dist/computed-traits.mjs
DELETED
|
@@ -1,149 +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 { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/computed-traits.ts
|
|
7
|
-
/**
|
|
8
|
-
* segment/computed-traits.ts — Engage computed traits. 6 actions (PLAN § 6.8).
|
|
9
|
-
*/
|
|
10
|
-
const computedTraitSchema = segmentLooseObjectSchema({
|
|
11
|
-
id: segmentIdSchema,
|
|
12
|
-
key: z.string().optional(),
|
|
13
|
-
name: z.string().optional(),
|
|
14
|
-
description: z.string().optional(),
|
|
15
|
-
definition: z.record(z.string(), z.unknown()).optional(),
|
|
16
|
-
enabled: z.boolean().optional()
|
|
17
|
-
});
|
|
18
|
-
const previewSchema = segmentLooseObjectSchema({
|
|
19
|
-
count: z.number().optional(),
|
|
20
|
-
sample: z.array(z.record(z.string(), z.unknown())).optional()
|
|
21
|
-
});
|
|
22
|
-
const listComputedTraits = segmentOperation({
|
|
23
|
-
id: "segment.computedTraits.list",
|
|
24
|
-
name: "List computed traits",
|
|
25
|
-
description: "List computed traits in an Engage space.",
|
|
26
|
-
input: z.object({
|
|
27
|
-
spaceId: segmentIdSchema,
|
|
28
|
-
pageSize: z.number().int().positive().max(200).optional(),
|
|
29
|
-
pageToken: z.string().optional()
|
|
30
|
-
}),
|
|
31
|
-
output: z.object({
|
|
32
|
-
items: z.array(computedTraitSchema),
|
|
33
|
-
nextPageToken: z.string().optional()
|
|
34
|
-
}),
|
|
35
|
-
run: async (input, credentials) => {
|
|
36
|
-
const result = await createSegmentClient(credentials).publicApi.list(`/spaces/${encodeURIComponent(input.spaceId)}/computed-traits`, {
|
|
37
|
-
itemsKey: "computedTraits",
|
|
38
|
-
items: computedTraitSchema
|
|
39
|
-
}, { query: {
|
|
40
|
-
count: input.pageSize,
|
|
41
|
-
cursor: input.pageToken
|
|
42
|
-
} });
|
|
43
|
-
return {
|
|
44
|
-
items: [...result.items],
|
|
45
|
-
...result.nextPageToken !== void 0 ? { nextPageToken: result.nextPageToken } : {}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const getComputedTrait = segmentOperation({
|
|
50
|
-
id: "segment.computedTraits.get",
|
|
51
|
-
name: "Get computed trait",
|
|
52
|
-
description: "Fetch a computed trait by id.",
|
|
53
|
-
input: z.object({
|
|
54
|
-
spaceId: segmentIdSchema,
|
|
55
|
-
id: segmentIdSchema
|
|
56
|
-
}),
|
|
57
|
-
output: computedTraitSchema,
|
|
58
|
-
run: async (input, credentials) => {
|
|
59
|
-
const body = await createSegmentClient(credentials).publicApi.request(`/spaces/${encodeURIComponent(input.spaceId)}/computed-traits/${encodeURIComponent(input.id)}`);
|
|
60
|
-
const rec = body;
|
|
61
|
-
return computedTraitSchema.parse(rec.data?.computedTrait ?? body);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
const createComputedTrait = segmentOperation({
|
|
65
|
-
id: "segment.computedTraits.create",
|
|
66
|
-
name: "Create computed trait",
|
|
67
|
-
description: "Create a computed trait definition.",
|
|
68
|
-
input: z.object({
|
|
69
|
-
spaceId: segmentIdSchema,
|
|
70
|
-
name: z.string().min(1),
|
|
71
|
-
description: z.string().optional(),
|
|
72
|
-
definition: z.record(z.string(), z.unknown()),
|
|
73
|
-
enabled: z.boolean().optional()
|
|
74
|
-
}),
|
|
75
|
-
output: computedTraitSchema,
|
|
76
|
-
needsApproval: true,
|
|
77
|
-
run: async (input, credentials) => {
|
|
78
|
-
const client = createSegmentClient(credentials);
|
|
79
|
-
const { spaceId, ...body } = input;
|
|
80
|
-
const response = await client.publicApi.request(`/spaces/${encodeURIComponent(spaceId)}/computed-traits`, {
|
|
81
|
-
method: "POST",
|
|
82
|
-
body
|
|
83
|
-
});
|
|
84
|
-
const rec = response;
|
|
85
|
-
return computedTraitSchema.parse(rec.data?.computedTrait ?? response);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
const updateComputedTrait = segmentOperation({
|
|
89
|
-
id: "segment.computedTraits.update",
|
|
90
|
-
name: "Update computed trait",
|
|
91
|
-
description: "Patch a computed trait definition.",
|
|
92
|
-
input: z.object({
|
|
93
|
-
spaceId: segmentIdSchema,
|
|
94
|
-
id: segmentIdSchema,
|
|
95
|
-
name: z.string().optional(),
|
|
96
|
-
description: z.string().optional(),
|
|
97
|
-
definition: z.record(z.string(), z.unknown()).optional(),
|
|
98
|
-
enabled: z.boolean().optional()
|
|
99
|
-
}),
|
|
100
|
-
output: computedTraitSchema,
|
|
101
|
-
needsApproval: true,
|
|
102
|
-
run: async (input, credentials) => {
|
|
103
|
-
const client = createSegmentClient(credentials);
|
|
104
|
-
const { spaceId, id, ...body } = input;
|
|
105
|
-
const response = await client.publicApi.request(`/spaces/${encodeURIComponent(spaceId)}/computed-traits/${encodeURIComponent(id)}`, {
|
|
106
|
-
method: "PATCH",
|
|
107
|
-
body
|
|
108
|
-
});
|
|
109
|
-
const rec = response;
|
|
110
|
-
return computedTraitSchema.parse(rec.data?.computedTrait ?? response);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
const deleteComputedTrait = segmentOperation({
|
|
114
|
-
id: "segment.computedTraits.delete",
|
|
115
|
-
name: "Delete computed trait",
|
|
116
|
-
description: "Delete a computed trait.",
|
|
117
|
-
input: z.object({
|
|
118
|
-
spaceId: segmentIdSchema,
|
|
119
|
-
id: segmentIdSchema
|
|
120
|
-
}),
|
|
121
|
-
output: z.object({ deleted: z.literal(true) }),
|
|
122
|
-
needsApproval: true,
|
|
123
|
-
run: async (input, credentials) => {
|
|
124
|
-
await createSegmentClient(credentials).publicApi.request(`/spaces/${encodeURIComponent(input.spaceId)}/computed-traits/${encodeURIComponent(input.id)}`, { method: "DELETE" });
|
|
125
|
-
return { deleted: true };
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
const previewComputedTrait = segmentOperation({
|
|
129
|
-
id: "segment.computedTraits.preview",
|
|
130
|
-
name: "Preview computed trait",
|
|
131
|
-
description: "Preview the output of a computed trait definition without saving.",
|
|
132
|
-
input: z.object({
|
|
133
|
-
spaceId: segmentIdSchema,
|
|
134
|
-
definition: z.record(z.string(), z.unknown())
|
|
135
|
-
}),
|
|
136
|
-
output: previewSchema,
|
|
137
|
-
needsApproval: true,
|
|
138
|
-
run: async (input, credentials) => {
|
|
139
|
-
const body = await createSegmentClient(credentials).publicApi.request(`/spaces/${encodeURIComponent(input.spaceId)}/computed-traits/previews`, {
|
|
140
|
-
method: "POST",
|
|
141
|
-
body: { definition: input.definition }
|
|
142
|
-
});
|
|
143
|
-
const rec = body;
|
|
144
|
-
return previewSchema.parse(rec.data?.preview ?? body);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
//#endregion
|
|
149
|
-
export { computedTraitSchema, createComputedTrait, deleteComputedTrait, getComputedTrait, listComputedTraits, previewComputedTrait, updateComputedTrait };
|
package/dist/connection.d.mts
DELETED
package/dist/connection.mjs
DELETED
package/dist/crud-DGM2Ekdr.mjs
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { createSegmentClient } from "./client.mjs";
|
|
2
|
-
import { o as segmentPaginationInputSchema } from "./common-CdGiJbjq.mjs";
|
|
3
|
-
import { t as segmentOperation } from "./factory-Dqb49Dfj.mjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/crud.ts
|
|
7
|
-
/**
|
|
8
|
-
* segment/crud.ts
|
|
9
|
-
*
|
|
10
|
-
* Package-internal helpers for declaring the five canonical Public API CRUD
|
|
11
|
-
* operations (list/get/create/update/delete) succinctly in each domain
|
|
12
|
-
* module. Not exported — if we did, it would create an alternate authoring
|
|
13
|
-
* surface that competes with the factory, which AUTHORING.md prohibits.
|
|
14
|
-
*
|
|
15
|
-
* Each helper returns an `Operation` produced by `segmentOperation(...)`.
|
|
16
|
-
* Domain files wire these alongside any domain-specific operations they
|
|
17
|
-
* define manually.
|
|
18
|
-
*/
|
|
19
|
-
function crudList(config) {
|
|
20
|
-
const extra = config.extraInput ? z.object(config.extraInput) : z.object({});
|
|
21
|
-
const input = segmentPaginationInputSchema.and(extra);
|
|
22
|
-
const output = z.object({
|
|
23
|
-
items: z.array(config.item),
|
|
24
|
-
nextPageToken: z.string().optional(),
|
|
25
|
-
totalEntries: z.number().int().nonnegative().optional()
|
|
26
|
-
});
|
|
27
|
-
return segmentOperation({
|
|
28
|
-
id: config.id,
|
|
29
|
-
name: config.name,
|
|
30
|
-
description: config.description,
|
|
31
|
-
input,
|
|
32
|
-
output,
|
|
33
|
-
run: async (parsed, credentials) => {
|
|
34
|
-
const client = createSegmentClient(credentials);
|
|
35
|
-
const { pageSize, pageToken, ...rest } = parsed;
|
|
36
|
-
const query = {};
|
|
37
|
-
if (pageSize !== void 0) query.count = pageSize;
|
|
38
|
-
if (pageToken !== void 0) query.cursor = pageToken;
|
|
39
|
-
for (const [k, v] of Object.entries(rest)) {
|
|
40
|
-
if (v === void 0) continue;
|
|
41
|
-
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") query[k] = v;
|
|
42
|
-
}
|
|
43
|
-
const result = await client.publicApi.list(config.path, {
|
|
44
|
-
itemsKey: config.itemsKey,
|
|
45
|
-
items: config.item
|
|
46
|
-
}, { query });
|
|
47
|
-
return {
|
|
48
|
-
items: [...result.items],
|
|
49
|
-
...result.nextPageToken !== void 0 ? { nextPageToken: result.nextPageToken } : {},
|
|
50
|
-
...result.totalEntries !== void 0 ? { totalEntries: result.totalEntries } : {}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function crudGet(config) {
|
|
56
|
-
const idField = config.idField ?? "id";
|
|
57
|
-
const pathParamKeys = Object.keys(config.pathParams ?? {});
|
|
58
|
-
const inputShape = {
|
|
59
|
-
[idField]: z.string().min(1),
|
|
60
|
-
...config.extraInput ?? {},
|
|
61
|
-
...Object.fromEntries(pathParamKeys.map((k) => [k, z.string().min(1)]))
|
|
62
|
-
};
|
|
63
|
-
return segmentOperation({
|
|
64
|
-
id: config.id,
|
|
65
|
-
name: config.name,
|
|
66
|
-
description: config.description,
|
|
67
|
-
input: z.object(inputShape),
|
|
68
|
-
output: config.output,
|
|
69
|
-
run: async (raw, credentials) => {
|
|
70
|
-
const client = createSegmentClient(credentials);
|
|
71
|
-
const input = raw;
|
|
72
|
-
let path = config.path.replace(`{${idField}}`, encodeURIComponent(String(input[idField])));
|
|
73
|
-
for (const [key, placeholder] of Object.entries(config.pathParams ?? {})) path = path.replace(placeholder, encodeURIComponent(String(input[key])));
|
|
74
|
-
const query = {};
|
|
75
|
-
for (const key of Object.keys(config.extraInput ?? {})) {
|
|
76
|
-
const v = input[key];
|
|
77
|
-
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") query[key] = v;
|
|
78
|
-
}
|
|
79
|
-
return unwrapAndParse(await client.publicApi.request(path, { query }), config.output, config.unwrapKey);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function crudMutate(config) {
|
|
84
|
-
const idField = config.idField ?? "id";
|
|
85
|
-
const includeId = config.includeId ?? config.method !== "POST";
|
|
86
|
-
const pathParamKeys = Object.keys(config.pathParams ?? {});
|
|
87
|
-
const bodyKeys = new Set(Object.keys(config.bodyShape ?? {}));
|
|
88
|
-
const queryKeys = new Set(Object.keys(config.queryShape ?? {}));
|
|
89
|
-
const inputShape = {
|
|
90
|
-
...includeId ? { [idField]: z.string().min(1) } : {},
|
|
91
|
-
...Object.fromEntries(pathParamKeys.map((k) => [k, z.string().min(1)])),
|
|
92
|
-
...config.bodyShape ?? {},
|
|
93
|
-
...config.queryShape ?? {}
|
|
94
|
-
};
|
|
95
|
-
return segmentOperation({
|
|
96
|
-
id: config.id,
|
|
97
|
-
name: config.name,
|
|
98
|
-
description: config.description,
|
|
99
|
-
input: z.object(inputShape),
|
|
100
|
-
output: config.output,
|
|
101
|
-
needsApproval: true,
|
|
102
|
-
run: async (raw, credentials) => {
|
|
103
|
-
const client = createSegmentClient(credentials);
|
|
104
|
-
const input = raw;
|
|
105
|
-
let path = config.path;
|
|
106
|
-
if (includeId) path = path.replace(`{${idField}}`, encodeURIComponent(String(input[idField])));
|
|
107
|
-
for (const [key, placeholder] of Object.entries(config.pathParams ?? {})) path = path.replace(placeholder, encodeURIComponent(String(input[key])));
|
|
108
|
-
const body = {};
|
|
109
|
-
const query = {};
|
|
110
|
-
for (const [k, v] of Object.entries(input)) {
|
|
111
|
-
if (v === void 0) continue;
|
|
112
|
-
if (bodyKeys.has(k)) body[k] = v;
|
|
113
|
-
else if (queryKeys.has(k) && (typeof v === "string" || typeof v === "number" || typeof v === "boolean")) query[k] = v;
|
|
114
|
-
}
|
|
115
|
-
return unwrapAndParse(await client.publicApi.request(path, {
|
|
116
|
-
method: config.method,
|
|
117
|
-
...Object.keys(body).length > 0 ? { body } : {},
|
|
118
|
-
...Object.keys(query).length > 0 ? { query } : {}
|
|
119
|
-
}), config.output, config.unwrapKey);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function unwrapAndParse(body, output, unwrapKey) {
|
|
124
|
-
if (body === void 0 || body === null) {
|
|
125
|
-
const parsed = output.safeParse({});
|
|
126
|
-
if (parsed.success) return parsed.data;
|
|
127
|
-
return output.parse(null);
|
|
128
|
-
}
|
|
129
|
-
if (!unwrapKey) return output.parse(body);
|
|
130
|
-
if (typeof body === "object") {
|
|
131
|
-
const record = body;
|
|
132
|
-
const data = record.data ?? record;
|
|
133
|
-
if (unwrapKey in data) return output.parse(data[unwrapKey]);
|
|
134
|
-
return output.parse(body);
|
|
135
|
-
}
|
|
136
|
-
return output.parse(body);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
//#endregion
|
|
140
|
-
export { crudList as n, crudMutate as r, crudGet as t };
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import * as _keystrokehq_core0 from "@keystrokehq/core";
|
|
3
|
-
|
|
4
|
-
//#region src/deletion-suppression.d.ts
|
|
5
|
-
declare const regulationSchema: z.ZodObject<{
|
|
6
|
-
id: z.ZodString;
|
|
7
|
-
regulationType: z.ZodOptional<z.ZodString>;
|
|
8
|
-
status: z.ZodOptional<z.ZodString>;
|
|
9
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
10
|
-
finishedAt: z.ZodOptional<z.ZodString>;
|
|
11
|
-
subjectIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
13
|
-
declare const suppressionSchema: z.ZodObject<{
|
|
14
|
-
id: z.ZodString;
|
|
15
|
-
userId: z.ZodOptional<z.ZodString>;
|
|
16
|
-
suppressionType: z.ZodOptional<z.ZodString>;
|
|
17
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.core.$catchall<z.ZodUnknown>>;
|
|
19
|
-
declare const createUserDeletion: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
20
|
-
subjectIds: z.ZodArray<z.ZodString>;
|
|
21
|
-
subjectType: z.ZodDefault<z.ZodEnum<{
|
|
22
|
-
userId: "userId";
|
|
23
|
-
anonymousId: "anonymousId";
|
|
24
|
-
email: "email";
|
|
25
|
-
}>>;
|
|
26
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
-
id: z.ZodString;
|
|
28
|
-
regulationType: z.ZodOptional<z.ZodString>;
|
|
29
|
-
status: z.ZodOptional<z.ZodString>;
|
|
30
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
31
|
-
finishedAt: z.ZodOptional<z.ZodString>;
|
|
32
|
-
subjectIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
34
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
35
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
36
|
-
us: "us";
|
|
37
|
-
eu: "eu";
|
|
38
|
-
}>>;
|
|
39
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
40
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
41
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
42
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
43
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
44
|
-
}, z.core.$strip>>], undefined>;
|
|
45
|
-
declare const createSuppression: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
46
|
-
subjectIds: z.ZodArray<z.ZodString>;
|
|
47
|
-
subjectType: z.ZodDefault<z.ZodEnum<{
|
|
48
|
-
userId: "userId";
|
|
49
|
-
anonymousId: "anonymousId";
|
|
50
|
-
email: "email";
|
|
51
|
-
}>>;
|
|
52
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
-
id: z.ZodString;
|
|
54
|
-
regulationType: z.ZodOptional<z.ZodString>;
|
|
55
|
-
status: z.ZodOptional<z.ZodString>;
|
|
56
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
57
|
-
finishedAt: z.ZodOptional<z.ZodString>;
|
|
58
|
-
subjectIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
60
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
61
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
62
|
-
us: "us";
|
|
63
|
-
eu: "eu";
|
|
64
|
-
}>>;
|
|
65
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
66
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
67
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
68
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
69
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
70
|
-
}, z.core.$strip>>], undefined>;
|
|
71
|
-
declare const removeSuppression: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
72
|
-
id: z.ZodString;
|
|
73
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
74
|
-
removed: z.ZodLiteral<true>;
|
|
75
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
76
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
77
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
78
|
-
us: "us";
|
|
79
|
-
eu: "eu";
|
|
80
|
-
}>>;
|
|
81
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
82
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
83
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
84
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
85
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
86
|
-
}, z.core.$strip>>], undefined>;
|
|
87
|
-
declare const listRegulations: _keystrokehq_core0.Operation<z.ZodIntersection<z.ZodObject<{
|
|
88
|
-
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
89
|
-
pageToken: z.ZodOptional<z.ZodString>;
|
|
90
|
-
}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>>, z.ZodObject<{
|
|
91
|
-
items: z.ZodArray<z.ZodObject<{
|
|
92
|
-
id: z.ZodString;
|
|
93
|
-
regulationType: z.ZodOptional<z.ZodString>;
|
|
94
|
-
status: z.ZodOptional<z.ZodString>;
|
|
95
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
96
|
-
finishedAt: z.ZodOptional<z.ZodString>;
|
|
97
|
-
subjectIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
-
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
99
|
-
nextPageToken: z.ZodOptional<z.ZodString>;
|
|
100
|
-
totalEntries: z.ZodOptional<z.ZodNumber>;
|
|
101
|
-
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
102
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
103
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
104
|
-
us: "us";
|
|
105
|
-
eu: "eu";
|
|
106
|
-
}>>;
|
|
107
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
108
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
109
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
110
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
111
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
112
|
-
}, z.core.$strip>>], undefined>;
|
|
113
|
-
declare const getRegulation: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
114
|
-
[x: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
115
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
116
|
-
id: z.ZodString;
|
|
117
|
-
regulationType: z.ZodOptional<z.ZodString>;
|
|
118
|
-
status: z.ZodOptional<z.ZodString>;
|
|
119
|
-
createdAt: z.ZodOptional<z.ZodString>;
|
|
120
|
-
finishedAt: z.ZodOptional<z.ZodString>;
|
|
121
|
-
subjectIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
-
}, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:segment", z.ZodObject<{
|
|
123
|
-
SEGMENT_PUBLIC_API_TOKEN: z.ZodString;
|
|
124
|
-
SEGMENT_REGION: z.ZodDefault<z.ZodEnum<{
|
|
125
|
-
us: "us";
|
|
126
|
-
eu: "eu";
|
|
127
|
-
}>>;
|
|
128
|
-
SEGMENT_DEFAULT_WRITE_KEY: z.ZodOptional<z.ZodString>;
|
|
129
|
-
SEGMENT_WRITE_KEYS_JSON: z.ZodOptional<z.ZodString>;
|
|
130
|
-
SEGMENT_PROFILE_API_TOKEN: z.ZodOptional<z.ZodString>;
|
|
131
|
-
SEGMENT_PROFILE_SPACE_ID: z.ZodOptional<z.ZodString>;
|
|
132
|
-
SEGMENT_WEBHOOK_SHARED_SECRET: z.ZodOptional<z.ZodString>;
|
|
133
|
-
}, z.core.$strip>>], undefined>;
|
|
134
|
-
//#endregion
|
|
135
|
-
export { createSuppression, createUserDeletion, getRegulation, listRegulations, regulationSchema, removeSuppression, suppressionSchema };
|
|
@@ -1,103 +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, t as crudGet } from "./crud-DGM2Ekdr.mjs";
|
|
5
|
-
import { z } from "zod";
|
|
6
|
-
|
|
7
|
-
//#region src/deletion-suppression.ts
|
|
8
|
-
/**
|
|
9
|
-
* segment/deletion-suppression.ts — GDPR user deletion + suppression rules.
|
|
10
|
-
* 5 actions (PLAN § 6.20).
|
|
11
|
-
*/
|
|
12
|
-
const regulationSchema = segmentLooseObjectSchema({
|
|
13
|
-
id: segmentIdSchema,
|
|
14
|
-
regulationType: z.string().optional(),
|
|
15
|
-
status: z.string().optional(),
|
|
16
|
-
createdAt: z.string().optional(),
|
|
17
|
-
finishedAt: z.string().optional(),
|
|
18
|
-
subjectIds: z.array(z.string()).optional()
|
|
19
|
-
});
|
|
20
|
-
const suppressionSchema = segmentLooseObjectSchema({
|
|
21
|
-
id: segmentIdSchema,
|
|
22
|
-
userId: z.string().optional(),
|
|
23
|
-
suppressionType: z.string().optional(),
|
|
24
|
-
createdAt: z.string().optional()
|
|
25
|
-
});
|
|
26
|
-
const createUserDeletion = segmentOperation({
|
|
27
|
-
id: "segment.deletion.createUser",
|
|
28
|
-
name: "Create user-deletion regulation",
|
|
29
|
-
description: "Submit a GDPR user-deletion regulation. Deletes data for the specified user ids from every destination that supports it.",
|
|
30
|
-
input: z.object({
|
|
31
|
-
subjectIds: z.array(z.string().min(1)).min(1),
|
|
32
|
-
subjectType: z.enum([
|
|
33
|
-
"userId",
|
|
34
|
-
"email",
|
|
35
|
-
"anonymousId"
|
|
36
|
-
]).default("userId")
|
|
37
|
-
}),
|
|
38
|
-
output: regulationSchema,
|
|
39
|
-
needsApproval: true,
|
|
40
|
-
run: async (input, credentials) => {
|
|
41
|
-
const body = await createSegmentClient(credentials).publicApi.request("/workspace/regulations/user-deletion-and-suppression", {
|
|
42
|
-
method: "POST",
|
|
43
|
-
body: input
|
|
44
|
-
});
|
|
45
|
-
const rec = body;
|
|
46
|
-
return regulationSchema.parse(rec.data?.regulation ?? body);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const createSuppression = segmentOperation({
|
|
50
|
-
id: "segment.deletion.createSuppression",
|
|
51
|
-
name: "Create suppression rule",
|
|
52
|
-
description: "Suppress future events for a list of users without deleting historical data.",
|
|
53
|
-
input: z.object({
|
|
54
|
-
subjectIds: z.array(z.string().min(1)).min(1),
|
|
55
|
-
subjectType: z.enum([
|
|
56
|
-
"userId",
|
|
57
|
-
"email",
|
|
58
|
-
"anonymousId"
|
|
59
|
-
]).default("userId")
|
|
60
|
-
}),
|
|
61
|
-
output: regulationSchema,
|
|
62
|
-
needsApproval: true,
|
|
63
|
-
run: async (input, credentials) => {
|
|
64
|
-
const body = await createSegmentClient(credentials).publicApi.request("/workspace/regulations/suppressions", {
|
|
65
|
-
method: "POST",
|
|
66
|
-
body: input
|
|
67
|
-
});
|
|
68
|
-
const rec = body;
|
|
69
|
-
return regulationSchema.parse(rec.data?.regulation ?? body);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
const removeSuppression = segmentOperation({
|
|
73
|
-
id: "segment.deletion.removeSuppression",
|
|
74
|
-
name: "Remove suppression",
|
|
75
|
-
description: "Remove a suppression rule so that events for the user flow again.",
|
|
76
|
-
input: z.object({ id: segmentIdSchema }),
|
|
77
|
-
output: z.object({ removed: z.literal(true) }),
|
|
78
|
-
needsApproval: true,
|
|
79
|
-
run: async (input, credentials) => {
|
|
80
|
-
await createSegmentClient(credentials).publicApi.request(`/workspace/regulations/suppressions/${encodeURIComponent(input.id)}`, { method: "DELETE" });
|
|
81
|
-
return { removed: true };
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const listRegulations = crudList({
|
|
85
|
-
id: "segment.deletion.listRegulations",
|
|
86
|
-
name: "List regulations",
|
|
87
|
-
description: "List user-deletion / suppression regulations filed against the workspace.",
|
|
88
|
-
path: "/workspace/regulations",
|
|
89
|
-
itemsKey: "regulations",
|
|
90
|
-
item: regulationSchema,
|
|
91
|
-
extraInput: { status: z.string().optional() }
|
|
92
|
-
});
|
|
93
|
-
const getRegulation = crudGet({
|
|
94
|
-
id: "segment.deletion.getRegulation",
|
|
95
|
-
name: "Get regulation",
|
|
96
|
-
description: "Fetch a regulation by id.",
|
|
97
|
-
path: "/workspace/regulations/{id}",
|
|
98
|
-
output: regulationSchema,
|
|
99
|
-
unwrapKey: "regulation"
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
export { createSuppression, createUserDeletion, getRegulation, listRegulations, regulationSchema, removeSuppression, suppressionSchema };
|