terse-types 0.1.3 → 0.1.5
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/dist/AttioRecordFlatten.d.ts +19 -0
- package/dist/AttioRecordFlatten.js +71 -0
- package/dist/Configs.d.ts +5 -0
- package/dist/Configs.js +1 -0
- package/dist/OrganizationMetadata.d.ts +0 -0
- package/dist/OrganizationMetadata.js +10 -0
- package/dist/Triggers.d.ts +92 -0
- package/dist/Triggers.js +12 -0
- package/dist/json-schema/terse-types.schema.json +15994 -0
- package/dist/types.d.ts +23 -0
- package/package.json +1 -1
- package/dist/Events.d.ts +0 -112
- package/dist/Events.js +0 -32
- package/dist/TriggerProjections.d.ts +0 -18
- package/dist/TriggerProjections.js +0 -167
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapses a single Attio value entry (or nested structure) toward primitives /
|
|
3
|
+
* simple objects, matching the shape produced for generated Attio tool outputs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function flattenAttioLeafValue(value: unknown): unknown;
|
|
6
|
+
/**
|
|
7
|
+
* Flattens one attribute’s raw value (often an array of interaction rows from the REST API).
|
|
8
|
+
* @param preferArray When true, keep all entries as an array; when false, use the first entry only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function flattenAttioAttributeValue(rawValue: unknown, preferArray: boolean): unknown;
|
|
11
|
+
/**
|
|
12
|
+
* Flattens `record.values` from Attio’s GET record / webhook enrichment payload.
|
|
13
|
+
*/
|
|
14
|
+
export declare function flattenAttioRecordValues(values: Record<string, unknown>, isMultiValueAttribute: (attributeSlug: string) => boolean): Record<string, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Slug-only heuristic when object attribute metadata is unavailable (e.g. Attio webhook triggers).
|
|
17
|
+
* Prefer {@link flattenAttioRecordValues} with object-aware multi-value info from codegen when possible.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isProbablyAttioMultiValueAttributeSlug(attributeSlug: string): boolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Keys Attio nests on attribute timeline entries (not the semantic payload). */
|
|
2
|
+
const ATTIO_VALUE_METADATA_KEYS = new Set([
|
|
3
|
+
"active_from",
|
|
4
|
+
"active_until",
|
|
5
|
+
"attribute_type",
|
|
6
|
+
"created_by_actor"
|
|
7
|
+
]);
|
|
8
|
+
/**
|
|
9
|
+
* Collapses a single Attio value entry (or nested structure) toward primitives /
|
|
10
|
+
* simple objects, matching the shape produced for generated Attio tool outputs.
|
|
11
|
+
*/
|
|
12
|
+
export function flattenAttioLeafValue(value) {
|
|
13
|
+
if (value === null || value === undefined)
|
|
14
|
+
return value;
|
|
15
|
+
if (Array.isArray(value))
|
|
16
|
+
return value.map(entry => flattenAttioLeafValue(entry));
|
|
17
|
+
if (typeof value !== "object")
|
|
18
|
+
return value;
|
|
19
|
+
const rawObject = value;
|
|
20
|
+
if (typeof rawObject.full_name === "string")
|
|
21
|
+
return rawObject.full_name;
|
|
22
|
+
if (typeof rawObject.email_address === "string")
|
|
23
|
+
return rawObject.email_address;
|
|
24
|
+
if (typeof rawObject.domain === "string")
|
|
25
|
+
return rawObject.domain;
|
|
26
|
+
if (typeof rawObject.phone_number === "string")
|
|
27
|
+
return rawObject.phone_number;
|
|
28
|
+
if ("value" in rawObject)
|
|
29
|
+
return flattenAttioLeafValue(rawObject.value);
|
|
30
|
+
const dataEntries = Object.entries(rawObject).filter(([key]) => !ATTIO_VALUE_METADATA_KEYS.has(key));
|
|
31
|
+
if (dataEntries.length === 0)
|
|
32
|
+
return rawObject;
|
|
33
|
+
if (dataEntries.length === 1)
|
|
34
|
+
return flattenAttioLeafValue(dataEntries[0][1]);
|
|
35
|
+
return Object.fromEntries(dataEntries.map(([key, entryValue]) => [key, flattenAttioLeafValue(entryValue)]));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Flattens one attribute’s raw value (often an array of interaction rows from the REST API).
|
|
39
|
+
* @param preferArray When true, keep all entries as an array; when false, use the first entry only.
|
|
40
|
+
*/
|
|
41
|
+
export function flattenAttioAttributeValue(rawValue, preferArray) {
|
|
42
|
+
if (!Array.isArray(rawValue))
|
|
43
|
+
return flattenAttioLeafValue(rawValue);
|
|
44
|
+
const flattened = rawValue.map(entry => flattenAttioLeafValue(entry)).filter(entry => entry !== undefined);
|
|
45
|
+
return preferArray ? flattened : flattened[0];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Flattens `record.values` from Attio’s GET record / webhook enrichment payload.
|
|
49
|
+
*/
|
|
50
|
+
export function flattenAttioRecordValues(values, isMultiValueAttribute) {
|
|
51
|
+
const flattenedValues = {};
|
|
52
|
+
for (const [attributeSlug, rawValue] of Object.entries(values)) {
|
|
53
|
+
flattenedValues[attributeSlug] = flattenAttioAttributeValue(rawValue, isMultiValueAttribute(attributeSlug));
|
|
54
|
+
}
|
|
55
|
+
return flattenedValues;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Slug-only heuristic when object attribute metadata is unavailable (e.g. Attio webhook triggers).
|
|
59
|
+
* Prefer {@link flattenAttioRecordValues} with object-aware multi-value info from codegen when possible.
|
|
60
|
+
*/
|
|
61
|
+
export function isProbablyAttioMultiValueAttributeSlug(attributeSlug) {
|
|
62
|
+
const slug = attributeSlug.toLowerCase();
|
|
63
|
+
return (slug === "email_addresses" ||
|
|
64
|
+
slug === "domains" ||
|
|
65
|
+
slug === "phone_numbers" ||
|
|
66
|
+
slug === "social_profiles" ||
|
|
67
|
+
slug === "links" ||
|
|
68
|
+
slug === "tags" ||
|
|
69
|
+
slug.endsWith("_addresses") ||
|
|
70
|
+
slug.endsWith("_ids"));
|
|
71
|
+
}
|
package/dist/Configs.d.ts
CHANGED
|
@@ -271,6 +271,7 @@ export declare const GitHubEventType: {
|
|
|
271
271
|
readonly PR_MERGED: "pull_request.merged";
|
|
272
272
|
readonly PR_CLOSED: "pull_request.closed";
|
|
273
273
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
274
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
274
275
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
275
276
|
};
|
|
276
277
|
export declare const gitHubEventTypeSchema: z.ZodEnum<{
|
|
@@ -279,6 +280,7 @@ export declare const gitHubEventTypeSchema: z.ZodEnum<{
|
|
|
279
280
|
readonly PR_MERGED: "pull_request.merged";
|
|
280
281
|
readonly PR_CLOSED: "pull_request.closed";
|
|
281
282
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
283
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
282
284
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
283
285
|
}>;
|
|
284
286
|
export type GitHubEventType = z.infer<typeof gitHubEventTypeSchema>;
|
|
@@ -591,6 +593,7 @@ export declare const GitHubConfigSchema: z.ZodObject<{
|
|
|
591
593
|
readonly PR_MERGED: "pull_request.merged";
|
|
592
594
|
readonly PR_CLOSED: "pull_request.closed";
|
|
593
595
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
596
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
594
597
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
595
598
|
}>>>;
|
|
596
599
|
}, z.core.$strip>;
|
|
@@ -1534,6 +1537,7 @@ export declare const configDataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
1534
1537
|
readonly PR_MERGED: "pull_request.merged";
|
|
1535
1538
|
readonly PR_CLOSED: "pull_request.closed";
|
|
1536
1539
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
1540
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
1537
1541
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
1538
1542
|
}>>>;
|
|
1539
1543
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -2176,6 +2180,7 @@ export declare const triggerConfigDataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
2176
2180
|
readonly PR_MERGED: "pull_request.merged";
|
|
2177
2181
|
readonly PR_CLOSED: "pull_request.closed";
|
|
2178
2182
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
2183
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
2179
2184
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
2180
2185
|
}>>>;
|
|
2181
2186
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/Configs.js
CHANGED
|
@@ -282,6 +282,7 @@ export const GitHubEventType = {
|
|
|
282
282
|
PR_MERGED: "pull_request.merged",
|
|
283
283
|
PR_CLOSED: "pull_request.closed",
|
|
284
284
|
PR_SYNCHRONIZE: "pull_request.synchronize",
|
|
285
|
+
PR_COMMENT_CREATED: "pull_request.comment.created",
|
|
285
286
|
ISSUE_COMMENT_CREATED: "issue_comment.created"
|
|
286
287
|
};
|
|
287
288
|
export const gitHubEventTypeSchema = z.enum(GitHubEventType);
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Can be serialized a string, supports deserialization
|
|
3
|
+
const booleanMetadataSchema = z
|
|
4
|
+
.union([z.boolean(), z.string()])
|
|
5
|
+
.optional()
|
|
6
|
+
.transform(value => value === true || value === "true");
|
|
7
|
+
export const organizationMetadataSchema = z.object({
|
|
8
|
+
stripeCustomerId: z.string(),
|
|
9
|
+
runExecutionBlocked: booleanMetadataSchema
|
|
10
|
+
});
|
package/dist/Triggers.d.ts
CHANGED
|
@@ -521,6 +521,51 @@ export declare const GithubIssueCommentCreatedTriggerSchema: z.ZodObject<{
|
|
|
521
521
|
}, z.core.$strip>;
|
|
522
522
|
}, z.core.$strip>;
|
|
523
523
|
export type GithubIssueCommentCreatedTrigger = z.infer<typeof GithubIssueCommentCreatedTriggerSchema>;
|
|
524
|
+
export declare const GithubPRCommentCreatedTriggerSchema: z.ZodObject<{
|
|
525
|
+
integrationType: z.ZodLiteral<IntegrationType.GITHUB>;
|
|
526
|
+
username: z.ZodString;
|
|
527
|
+
installationId: z.ZodNumber;
|
|
528
|
+
repositoryName: z.ZodString;
|
|
529
|
+
repository: z.ZodObject<{
|
|
530
|
+
id: z.ZodNumber;
|
|
531
|
+
name: z.ZodString;
|
|
532
|
+
owner: z.ZodString;
|
|
533
|
+
defaultBranch: z.ZodString;
|
|
534
|
+
}, z.core.$strip>;
|
|
535
|
+
sender: z.ZodObject<{
|
|
536
|
+
login: z.ZodString;
|
|
537
|
+
email: z.ZodOptional<z.ZodString>;
|
|
538
|
+
}, z.core.$strip>;
|
|
539
|
+
eventType: z.ZodLiteral<"issue_comment.created">;
|
|
540
|
+
issue: z.ZodObject<{
|
|
541
|
+
id: z.ZodNumber;
|
|
542
|
+
number: z.ZodNumber;
|
|
543
|
+
title: z.ZodString;
|
|
544
|
+
body: z.ZodOptional<z.ZodString>;
|
|
545
|
+
state: z.ZodEnum<{
|
|
546
|
+
open: "open";
|
|
547
|
+
closed: "closed";
|
|
548
|
+
}>;
|
|
549
|
+
url: z.ZodString;
|
|
550
|
+
author: z.ZodObject<{
|
|
551
|
+
login: z.ZodString;
|
|
552
|
+
email: z.ZodOptional<z.ZodString>;
|
|
553
|
+
}, z.core.$strip>;
|
|
554
|
+
isPullRequest: z.ZodLiteral<true>;
|
|
555
|
+
}, z.core.$strip>;
|
|
556
|
+
comment: z.ZodObject<{
|
|
557
|
+
id: z.ZodNumber;
|
|
558
|
+
body: z.ZodString;
|
|
559
|
+
author: z.ZodObject<{
|
|
560
|
+
login: z.ZodString;
|
|
561
|
+
email: z.ZodOptional<z.ZodString>;
|
|
562
|
+
}, z.core.$strip>;
|
|
563
|
+
url: z.ZodString;
|
|
564
|
+
createdAt: z.ZodString;
|
|
565
|
+
updatedAt: z.ZodString;
|
|
566
|
+
}, z.core.$strip>;
|
|
567
|
+
}, z.core.$strip>;
|
|
568
|
+
export type GithubPRCommentCreatedTrigger = z.infer<typeof GithubPRCommentCreatedTriggerSchema>;
|
|
524
569
|
export declare const GithubPRTriggerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
525
570
|
integrationType: z.ZodLiteral<IntegrationType.GITHUB>;
|
|
526
571
|
username: z.ZodString;
|
|
@@ -1220,6 +1265,7 @@ export declare const TriggerTypeSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
1220
1265
|
readonly PR_MERGED: "pull_request.merged";
|
|
1221
1266
|
readonly PR_CLOSED: "pull_request.closed";
|
|
1222
1267
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
1268
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
1223
1269
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
1224
1270
|
}>, z.ZodEnum<{
|
|
1225
1271
|
readonly ISSUE_CREATED: "issue.created";
|
|
@@ -1293,6 +1339,7 @@ export declare const baseTriggerSchema: z.ZodObject<{
|
|
|
1293
1339
|
readonly PR_MERGED: "pull_request.merged";
|
|
1294
1340
|
readonly PR_CLOSED: "pull_request.closed";
|
|
1295
1341
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
1342
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
1296
1343
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
1297
1344
|
}>, z.ZodEnum<{
|
|
1298
1345
|
readonly ISSUE_CREATED: "issue.created";
|
|
@@ -9297,6 +9344,7 @@ export declare const serializedEventSchema: z.ZodObject<{
|
|
|
9297
9344
|
readonly PR_MERGED: "pull_request.merged";
|
|
9298
9345
|
readonly PR_CLOSED: "pull_request.closed";
|
|
9299
9346
|
readonly PR_SYNCHRONIZE: "pull_request.synchronize";
|
|
9347
|
+
readonly PR_COMMENT_CREATED: "pull_request.comment.created";
|
|
9300
9348
|
readonly ISSUE_COMMENT_CREATED: "issue_comment.created";
|
|
9301
9349
|
}>, z.ZodEnum<{
|
|
9302
9350
|
readonly ISSUE_CREATED: "issue.created";
|
|
@@ -13726,6 +13774,50 @@ export declare const TriggerDefinitions: {
|
|
|
13726
13774
|
updatedAt: z.ZodString;
|
|
13727
13775
|
}, z.core.$strip>;
|
|
13728
13776
|
}, z.core.$strip>>;
|
|
13777
|
+
GithubPRCommentCreatedTrigger: ConcreteTriggerDefinition<z.ZodObject<{
|
|
13778
|
+
integrationType: z.ZodLiteral<IntegrationType.GITHUB>;
|
|
13779
|
+
username: z.ZodString;
|
|
13780
|
+
installationId: z.ZodNumber;
|
|
13781
|
+
repositoryName: z.ZodString;
|
|
13782
|
+
repository: z.ZodObject<{
|
|
13783
|
+
id: z.ZodNumber;
|
|
13784
|
+
name: z.ZodString;
|
|
13785
|
+
owner: z.ZodString;
|
|
13786
|
+
defaultBranch: z.ZodString;
|
|
13787
|
+
}, z.core.$strip>;
|
|
13788
|
+
sender: z.ZodObject<{
|
|
13789
|
+
login: z.ZodString;
|
|
13790
|
+
email: z.ZodOptional<z.ZodString>;
|
|
13791
|
+
}, z.core.$strip>;
|
|
13792
|
+
eventType: z.ZodLiteral<"issue_comment.created">;
|
|
13793
|
+
issue: z.ZodObject<{
|
|
13794
|
+
id: z.ZodNumber;
|
|
13795
|
+
number: z.ZodNumber;
|
|
13796
|
+
title: z.ZodString;
|
|
13797
|
+
body: z.ZodOptional<z.ZodString>;
|
|
13798
|
+
state: z.ZodEnum<{
|
|
13799
|
+
open: "open";
|
|
13800
|
+
closed: "closed";
|
|
13801
|
+
}>;
|
|
13802
|
+
url: z.ZodString;
|
|
13803
|
+
author: z.ZodObject<{
|
|
13804
|
+
login: z.ZodString;
|
|
13805
|
+
email: z.ZodOptional<z.ZodString>;
|
|
13806
|
+
}, z.core.$strip>;
|
|
13807
|
+
isPullRequest: z.ZodLiteral<true>;
|
|
13808
|
+
}, z.core.$strip>;
|
|
13809
|
+
comment: z.ZodObject<{
|
|
13810
|
+
id: z.ZodNumber;
|
|
13811
|
+
body: z.ZodString;
|
|
13812
|
+
author: z.ZodObject<{
|
|
13813
|
+
login: z.ZodString;
|
|
13814
|
+
email: z.ZodOptional<z.ZodString>;
|
|
13815
|
+
}, z.core.$strip>;
|
|
13816
|
+
url: z.ZodString;
|
|
13817
|
+
createdAt: z.ZodString;
|
|
13818
|
+
updatedAt: z.ZodString;
|
|
13819
|
+
}, z.core.$strip>;
|
|
13820
|
+
}, z.core.$strip>>;
|
|
13729
13821
|
GithubPRTrigger: import("./TriggerDefinition.js").UnionTriggerDefinition;
|
|
13730
13822
|
GithubTrigger: import("./TriggerDefinition.js").UnionTriggerDefinition;
|
|
13731
13823
|
GmailTrigger: ConcreteTriggerDefinition<z.ZodObject<{
|
package/dist/Triggers.js
CHANGED
|
@@ -149,6 +149,12 @@ export const GithubIssueCommentCreatedTriggerSchema = GithubTriggerBaseSchema.ex
|
|
|
149
149
|
issue: issueCommentTargetSchema,
|
|
150
150
|
comment: issueCommentSchema
|
|
151
151
|
});
|
|
152
|
+
const pullRequestCommentTargetSchema = issueCommentTargetSchema.extend({ isPullRequest: z.literal(true) });
|
|
153
|
+
export const GithubPRCommentCreatedTriggerSchema = GithubTriggerBaseSchema.extend({
|
|
154
|
+
eventType: z.literal(GitHubEventType.ISSUE_COMMENT_CREATED),
|
|
155
|
+
issue: pullRequestCommentTargetSchema,
|
|
156
|
+
comment: issueCommentSchema
|
|
157
|
+
});
|
|
152
158
|
export const GithubPRTriggerSchema = z.discriminatedUnion("eventType", [GithubPROpenedTriggerSchema, GithubPRSynchronizedTriggerSchema, GithubPRClosedTriggerSchema, GithubPRMergedTriggerSchema]);
|
|
153
159
|
export const GithubTriggerSchema = z.discriminatedUnion("eventType", [GithubPushTriggerSchema, GithubPRTriggerSchema, GithubIssueCommentCreatedTriggerSchema]);
|
|
154
160
|
export const GmailParsedAttachmentSchema = z.object({
|
|
@@ -892,6 +898,12 @@ export const TriggerDefinitions = {
|
|
|
892
898
|
eventTypes: [GitHubEventType.ISSUE_COMMENT_CREATED],
|
|
893
899
|
presenter: githubPresenter
|
|
894
900
|
}),
|
|
901
|
+
GithubPRCommentCreatedTrigger: defineTrigger({
|
|
902
|
+
integration: IntegrationType.GITHUB,
|
|
903
|
+
schema: GithubPRCommentCreatedTriggerSchema,
|
|
904
|
+
eventTypes: [GitHubEventType.PR_COMMENT_CREATED],
|
|
905
|
+
presenter: githubPresenter
|
|
906
|
+
}),
|
|
895
907
|
GithubPRTrigger: defineTriggerUnion({
|
|
896
908
|
integration: IntegrationType.GITHUB,
|
|
897
909
|
members: ["GithubPROpenedTrigger", "GithubPRSynchronizedTrigger", "GithubPRClosedTrigger", "GithubPRMergedTrigger"]
|