terse-types 0.0.39 → 0.0.41

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.
@@ -70,6 +70,9 @@ export const attioIntegrationsKey = () => {
70
70
  export const snowflakeIntegrationsKey = () => {
71
71
  return ["snowflakeIntegrations"];
72
72
  };
73
+ export const heyReachIntegrationsKey = () => {
74
+ return ["heyReachIntegrations"];
75
+ };
73
76
  export const attioObjectsKey = (integrationId) => {
74
77
  if (!integrationId) {
75
78
  return null;
@@ -140,12 +143,8 @@ export const userByIdKey = (userId) => {
140
143
  return null;
141
144
  return ["userById", userId];
142
145
  };
143
- export const agentFilesKey = (agentId) => ["agentFiles", agentId];
144
- export const agentFileContentKey = (agentId, fileId) => ["agentFileContent", agentId, fileId];
145
146
  export const projectDeploysKey = (projectId) => ["projectDeploys", projectId];
146
147
  export const projectSecretsKey = (projectId) => ["projectSecrets", projectId];
147
- export const projectSourceFilesKey = (projectId) => ["projectSourceFiles", projectId];
148
- export const projectSourceFileContentKey = (projectId, fileId) => ["projectSourceFileContent", projectId, fileId];
149
148
  export const billingContextKey = (params) => [
150
149
  "billingContext",
151
150
  params?.timezone ?? "",
@@ -135,7 +135,6 @@ export declare const toolCallCompleteSchema: z.ZodObject<{
135
135
  }, z.core.$strip>;
136
136
  export type ToolCallComplete = z.infer<typeof toolCallCompleteSchema>;
137
137
  export declare enum SandboxStage {
138
- DOWNLOADING_SOURCE = "downloading_source",
139
138
  BOOTING = "booting",
140
139
  INSTALLING_DEPENDENCIES = "installing_dependencies",
141
140
  INSTALLING_CLI = "installing_cli",
@@ -92,7 +92,6 @@ export const toolCallCompleteSchema = modelEventBaseSchema.extend({
92
92
  });
93
93
  export var SandboxStage;
94
94
  (function (SandboxStage) {
95
- SandboxStage["DOWNLOADING_SOURCE"] = "downloading_source";
96
95
  SandboxStage["BOOTING"] = "booting";
97
96
  SandboxStage["INSTALLING_DEPENDENCIES"] = "installing_dependencies";
98
97
  SandboxStage["INSTALLING_CLI"] = "installing_cli";
@@ -100,7 +99,6 @@ export var SandboxStage;
100
99
  })(SandboxStage || (SandboxStage = {}));
101
100
  export const sandboxStageSchema = z.enum(SandboxStage);
102
101
  export const SANDBOX_STAGE_LABELS = {
103
- [SandboxStage.DOWNLOADING_SOURCE]: "Downloading source code",
104
102
  [SandboxStage.BOOTING]: "Booting sandbox",
105
103
  [SandboxStage.INSTALLING_DEPENDENCIES]: "Installing dependencies",
106
104
  [SandboxStage.INSTALLING_CLI]: "Installing CLI",
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod";
2
2
  import type { ModelEvent } from "./ModelEvents.js";
3
- import type { RunHistoryRecord, RunHistoryRecordWithAgent, User } from "./types.js";
3
+ import type { RunHistoryRecord, RunHistoryRecordWithAgent, UserSession } from "./types.js";
4
4
  export declare const RunHistoryStatus: {
5
5
  readonly SUCCESS: "success";
6
6
  readonly FAILED: "failed";
@@ -98,5 +98,5 @@ export type RunHistoryModelSocketEvent = {
98
98
  export type TrackingParams = {
99
99
  runId: string;
100
100
  agentId: string;
101
- user: User;
101
+ user: UserSession;
102
102
  };
@@ -23,7 +23,7 @@ export { User as TicketSystemUser };
23
23
  export interface UserContext {
24
24
  userInfo: User;
25
25
  teams: Team[];
26
- organization: Organization;
26
+ organization: LinearOrganization;
27
27
  ticketStates: TicketState[];
28
28
  milestones: Milestone[];
29
29
  }
@@ -35,7 +35,7 @@ interface Milestone {
35
35
  id: string;
36
36
  name: string;
37
37
  }
38
- export interface Organization {
38
+ export interface LinearOrganization {
39
39
  id: string;
40
40
  name: string;
41
41
  createdAt: string;
package/dist/Tools.d.ts CHANGED
@@ -1268,8 +1268,8 @@ export declare const posthogEventSummarySchema: z.ZodObject<{
1268
1268
  url: z.ZodOptional<z.ZodString>;
1269
1269
  }, z.core.$strip>;
1270
1270
  export declare const posthogSessionEventTypeSchema: z.ZodEnum<{
1271
- input: "input";
1272
1271
  custom: "custom";
1272
+ input: "input";
1273
1273
  click: "click";
1274
1274
  scroll: "scroll";
1275
1275
  console: "console";
@@ -1280,8 +1280,8 @@ export declare const posthogSessionEventTypeSchema: z.ZodEnum<{
1280
1280
  }>;
1281
1281
  export declare const posthogSessionEventSchema: z.ZodObject<{
1282
1282
  type: z.ZodEnum<{
1283
- input: "input";
1284
1283
  custom: "custom";
1284
+ input: "input";
1285
1285
  click: "click";
1286
1286
  scroll: "scroll";
1287
1287
  console: "console";
@@ -3619,8 +3619,8 @@ export declare const getPosthogSessionEventsTool: {
3619
3619
  }, z.core.$strip>;
3620
3620
  events: z.ZodArray<z.ZodObject<{
3621
3621
  type: z.ZodEnum<{
3622
- input: "input";
3623
3622
  custom: "custom";
3623
+ input: "input";
3624
3624
  click: "click";
3625
3625
  scroll: "scroll";
3626
3626
  console: "console";
@@ -7274,8 +7274,8 @@ export declare const ToolDefinitions: {
7274
7274
  }, z.core.$strip>;
7275
7275
  events: z.ZodArray<z.ZodObject<{
7276
7276
  type: z.ZodEnum<{
7277
- input: "input";
7278
7277
  custom: "custom";
7278
+ input: "input";
7279
7279
  click: "click";
7280
7280
  scroll: "scroll";
7281
7281
  console: "console";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Pure config-to-ACL derivation (no network I/O).
3
+ *
4
+ * ACL and `readOnly` apply only to model-selected tool calls during agent runs; see `ACL.ts`
5
+ * for the full product contract.
6
+ */
7
+ import type { ACLRule } from "./ACL.js";
8
+ import type { ConfigData } from "./Configs.js";
9
+ export declare function getConfigACLRules(config: ConfigData): ACLRule[];
10
+ export declare function getMergedACLRules(configs: ConfigData[]): ACLRule[];
File without changes
package/dist/index.d.ts CHANGED
@@ -20,7 +20,6 @@ export * from "./Survey.js";
20
20
  export * from "./Tools.js";
21
21
  export * from "./Billing.js";
22
22
  export * from "./ModelRegistry.js";
23
- export * from "./TicketSystem.js";
24
23
  export * from "./ToolDisplayUtils.js";
25
24
  export * from "./Triggers.js";
26
25
  export * from "./ToolsTypes.js";
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ export * from "./Survey.js";
20
20
  export * from "./Tools.js";
21
21
  export * from "./Billing.js";
22
22
  export * from "./ModelRegistry.js";
23
- export * from "./TicketSystem.js";
23
+ // export * from "./TicketSystem"
24
24
  export * from "./ToolDisplayUtils.js";
25
25
  export * from "./Triggers.js";
26
26
  export * from "./ToolsTypes.js";
package/dist/types.d.ts CHANGED
@@ -7,32 +7,44 @@ export declare const roleSchema: z.ZodEnum<{
7
7
  admin: "admin";
8
8
  }>;
9
9
  export type Role = z.infer<typeof roleSchema>;
10
- export declare const userSchema: z.ZodObject<{
10
+ export declare const userProfileSchema: z.ZodObject<{
11
11
  id: z.ZodString;
12
- workosId: z.ZodString;
13
- organizationId: z.ZodString;
14
- organizationName: z.ZodString;
15
12
  email: z.ZodString;
16
13
  displayName: z.ZodString;
17
14
  firstName: z.ZodNullable<z.ZodString>;
18
15
  lastName: z.ZodNullable<z.ZodString>;
19
16
  displayPhotoUrl: z.ZodString;
20
- roles: z.ZodArray<z.ZodEnum<{
21
- user: "user";
22
- admin: "admin";
23
- }>>;
24
17
  }, z.core.$strip>;
25
- export type User = z.infer<typeof userSchema>;
26
- export declare const userNoOrganizationSchema: z.ZodObject<{
18
+ export type UserProfile = z.infer<typeof userProfileSchema>;
19
+ export declare const userSessionSchema: z.ZodObject<{
27
20
  id: z.ZodString;
28
21
  email: z.ZodString;
22
+ displayName: z.ZodString;
29
23
  firstName: z.ZodNullable<z.ZodString>;
30
24
  lastName: z.ZodNullable<z.ZodString>;
31
- workosId: z.ZodString;
32
- displayName: z.ZodString;
33
25
  displayPhotoUrl: z.ZodString;
26
+ organizationId: z.ZodString;
27
+ organizationName: z.ZodString;
28
+ roles: z.ZodArray<z.ZodEnum<{
29
+ user: "user";
30
+ admin: "admin";
31
+ }>>;
32
+ }, z.core.$strip>;
33
+ export type UserSession = z.infer<typeof userSessionSchema>;
34
+ export declare const organizationSchema: z.ZodObject<{
35
+ id: z.ZodString;
36
+ name: z.ZodString;
37
+ }, z.core.$strip>;
38
+ export type Organization = z.infer<typeof organizationSchema>;
39
+ export declare const membershipSchema: z.ZodObject<{
40
+ organizationId: z.ZodString;
41
+ organizationName: z.ZodString;
42
+ roles: z.ZodArray<z.ZodEnum<{
43
+ user: "user";
44
+ admin: "admin";
45
+ }>>;
34
46
  }, z.core.$strip>;
35
- export type UserNoOrganization = z.infer<typeof userNoOrganizationSchema>;
47
+ export type Membership = z.infer<typeof membershipSchema>;
36
48
  export declare const commitAssociationSchema: z.ZodObject<{
37
49
  sha: z.ZodString;
38
50
  message: z.ZodString;
@@ -245,7 +257,7 @@ export declare const deviceTokenExchangeResponseSchema: z.ZodObject<{
245
257
  }, z.core.$strip>;
246
258
  export type DeviceTokenExchangeResponse = z.infer<typeof deviceTokenExchangeResponseSchema>;
247
259
  export declare const identifyUserSchema: z.ZodObject<{
248
- workosId: z.ZodString;
260
+ id: z.ZodString;
249
261
  email: z.ZodString;
250
262
  firstName: z.ZodNullable<z.ZodString>;
251
263
  lastName: z.ZodNullable<z.ZodString>;
@@ -258,7 +270,7 @@ export declare const identifyOrganizationSchema: z.ZodObject<{
258
270
  }, z.core.$strip>;
259
271
  export declare const identifyResponseSchema: z.ZodObject<{
260
272
  user: z.ZodObject<{
261
- workosId: z.ZodString;
273
+ id: z.ZodString;
262
274
  email: z.ZodString;
263
275
  firstName: z.ZodNullable<z.ZodString>;
264
276
  lastName: z.ZodNullable<z.ZodString>;
@@ -8154,7 +8166,6 @@ export declare const doneSchema: z.ZodObject<{
8154
8166
  type: z.ZodLiteral<"done">;
8155
8167
  }, z.core.$strip>;
8156
8168
  export declare const sdkDeployStageEnum: z.ZodEnum<{
8157
- UPLOADING_SOURCE: "UPLOADING_SOURCE";
8158
8169
  BUILDING_DEPENDENCY_IMAGE: "BUILDING_DEPENDENCY_IMAGE";
8159
8170
  BUILDING_SOURCE_IMAGE: "BUILDING_SOURCE_IMAGE";
8160
8171
  CONFIGURING_AUTOMATIONS: "CONFIGURING_AUTOMATIONS";
@@ -8163,7 +8174,6 @@ export type SdkDeployStage = z.infer<typeof sdkDeployStageEnum>;
8163
8174
  export declare const deployStageSchema: z.ZodObject<{
8164
8175
  type: z.ZodLiteral<"deploy_stage">;
8165
8176
  stage: z.ZodEnum<{
8166
- UPLOADING_SOURCE: "UPLOADING_SOURCE";
8167
8177
  BUILDING_DEPENDENCY_IMAGE: "BUILDING_DEPENDENCY_IMAGE";
8168
8178
  BUILDING_SOURCE_IMAGE: "BUILDING_SOURCE_IMAGE";
8169
8179
  CONFIGURING_AUTOMATIONS: "CONFIGURING_AUTOMATIONS";
@@ -8225,7 +8235,6 @@ export declare const sdkAgentStreamEventSchema: z.ZodDiscriminatedUnion<[z.ZodOb
8225
8235
  }, z.core.$strip>, z.ZodObject<{
8226
8236
  type: z.ZodLiteral<"deploy_stage">;
8227
8237
  stage: z.ZodEnum<{
8228
- UPLOADING_SOURCE: "UPLOADING_SOURCE";
8229
8238
  BUILDING_DEPENDENCY_IMAGE: "BUILDING_DEPENDENCY_IMAGE";
8230
8239
  BUILDING_SOURCE_IMAGE: "BUILDING_SOURCE_IMAGE";
8231
8240
  CONFIGURING_AUTOMATIONS: "CONFIGURING_AUTOMATIONS";
@@ -21288,29 +21297,6 @@ export declare const webhookJobTriggerResponseSchema: z.ZodObject<{
21288
21297
  filtered: z.ZodOptional<z.ZodBoolean>;
21289
21298
  }, z.core.$strip>;
21290
21299
  export type WebhookJobTriggerResponse = z.infer<typeof webhookJobTriggerResponseSchema>;
21291
- declare const fileSchema: z.ZodObject<{
21292
- id: z.ZodString;
21293
- name: z.ZodString;
21294
- children: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$strip>>>;
21295
- }, z.core.$strip>;
21296
- export type File = z.infer<typeof fileSchema>;
21297
- export declare const agentFilesResponseSchema: z.ZodObject<{
21298
- id: z.ZodString;
21299
- files: z.ZodArray<z.ZodObject<{
21300
- id: z.ZodString;
21301
- name: z.ZodString;
21302
- children: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$strip>>>;
21303
- }, z.core.$strip>>;
21304
- }, z.core.$strip>;
21305
- export type AgentFilesResponse = z.infer<typeof agentFilesResponseSchema>;
21306
- /** Proxied SDK zip member: raw bytes as base64 plus path metadata (no separate GCS objects). */
21307
- export declare const agentFileContentResponseSchema: z.ZodObject<{
21308
- path: z.ZodString;
21309
- fileName: z.ZodString;
21310
- contentBase64: z.ZodString;
21311
- mimeType: z.ZodOptional<z.ZodString>;
21312
- }, z.core.$strip>;
21313
- export type AgentFileContentResponse = z.infer<typeof agentFileContentResponseSchema>;
21314
21300
  export declare const projectDeployStatusSchema: z.ZodEnum<{
21315
21301
  FAILED: "FAILED";
21316
21302
  IN_PROGRESS: "IN_PROGRESS";
@@ -21381,17 +21367,6 @@ export declare const projectDeploysResponseSchema: z.ZodObject<{
21381
21367
  }, z.core.$strip>>;
21382
21368
  }, z.core.$strip>;
21383
21369
  export type ProjectDeploysResponse = z.infer<typeof projectDeploysResponseSchema>;
21384
- export declare const projectSourceFilesResponseSchema: z.ZodObject<{
21385
- projectId: z.ZodString;
21386
- deployId: z.ZodNullable<z.ZodString>;
21387
- deployedAt: z.ZodNullable<z.ZodString>;
21388
- files: z.ZodArray<z.ZodObject<{
21389
- id: z.ZodString;
21390
- name: z.ZodString;
21391
- children: z.ZodOptional<z.ZodArray<z.ZodObject</*elided*/ any, z.core.$strip>>>;
21392
- }, z.core.$strip>>;
21393
- }, z.core.$strip>;
21394
- export type ProjectSourceFilesResponse = z.infer<typeof projectSourceFilesResponseSchema>;
21395
21370
  export declare const sdkListenQuerySchema: z.ZodObject<{
21396
21371
  jobName: z.ZodString;
21397
21372
  projectId: z.ZodString;
package/dist/types.js CHANGED
@@ -6,22 +6,27 @@ import { SlackChannelType, slackChannelTypeSchema } from "./SlackTypes.js";
6
6
  import { slackUserResponseSchema } from "./Tools.js";
7
7
  import { TriggerSchema, serializedEventSchema } from "./Triggers.js";
8
8
  export const roleSchema = z.enum(["admin", "user"]);
9
- export const userSchema = z.object({
9
+ export const userProfileSchema = z.object({
10
10
  id: z.string(),
11
- workosId: z.string(),
12
- organizationId: z.string(),
13
- organizationName: z.string(),
14
11
  email: z.string(),
15
12
  displayName: z.string(),
16
13
  firstName: z.string().nullable(),
17
14
  lastName: z.string().nullable(),
18
- displayPhotoUrl: z.string(),
15
+ displayPhotoUrl: z.string()
16
+ });
17
+ export const userSessionSchema = userProfileSchema.extend({
18
+ organizationId: z.string(),
19
+ organizationName: z.string(),
19
20
  roles: z.array(roleSchema)
20
21
  });
21
- export const userNoOrganizationSchema = userSchema.omit({
22
- organizationId: true,
23
- organizationName: true,
24
- roles: true
22
+ export const organizationSchema = z.object({
23
+ id: z.string(),
24
+ name: z.string()
25
+ });
26
+ export const membershipSchema = z.object({
27
+ organizationId: z.string(),
28
+ organizationName: z.string(),
29
+ roles: z.array(roleSchema)
25
30
  });
26
31
  export const commitAssociationSchema = z.object({
27
32
  sha: z.string(),
@@ -136,11 +141,7 @@ export const deviceTokenExchangeResponseSchema = z.object({
136
141
  user: deviceTokenExchangeUserSchema,
137
142
  organization: sdkOrganizationSummarySchema
138
143
  });
139
- export const identifyUserSchema = z.object({
140
- workosId: z.string(),
141
- email: z.string(),
142
- firstName: z.string().nullable(),
143
- lastName: z.string().nullable(),
144
+ export const identifyUserSchema = userProfileSchema.pick({ id: true, email: true, firstName: true, lastName: true }).extend({
144
145
  displayName: z.string().nullable()
145
146
  });
146
147
  export const identifyOrganizationSchema = z.object({
@@ -471,7 +472,7 @@ export const toolApprovalRequestedSchema = z.object({
471
472
  export const actionSchema = z.object({ type: z.literal("action"), action: runHistoryActionBaseSchema });
472
473
  export const errorSchema = z.object({ type: z.literal("error"), message: z.string() });
473
474
  export const doneSchema = z.object({ type: z.literal("done") });
474
- export const sdkDeployStageEnum = z.enum(["UPLOADING_SOURCE", "BUILDING_DEPENDENCY_IMAGE", "BUILDING_SOURCE_IMAGE", "CONFIGURING_AUTOMATIONS"]);
475
+ export const sdkDeployStageEnum = z.enum(["BUILDING_DEPENDENCY_IMAGE", "BUILDING_SOURCE_IMAGE", "CONFIGURING_AUTOMATIONS"]);
475
476
  export const deployStageSchema = z.object({ type: z.literal("deploy_stage"), stage: sdkDeployStageEnum });
476
477
  export const sdkAgentStreamEventSchema = z.discriminatedUnion("type", [
477
478
  runStartedSchema,
@@ -764,24 +765,6 @@ export const webhookJobTriggerResponseSchema = z.object({
764
765
  status: z.string().optional(),
765
766
  filtered: z.boolean().optional()
766
767
  });
767
- const fileSchema = z.object({
768
- id: z.string(),
769
- name: z.string(),
770
- get children() {
771
- return z.array(fileSchema).optional();
772
- }
773
- });
774
- export const agentFilesResponseSchema = z.object({
775
- id: z.string(),
776
- files: z.array(fileSchema)
777
- });
778
- /** Proxied SDK zip member: raw bytes as base64 plus path metadata (no separate GCS objects). */
779
- export const agentFileContentResponseSchema = z.object({
780
- path: z.string(),
781
- fileName: z.string(),
782
- contentBase64: z.string(),
783
- mimeType: z.string().optional()
784
- });
785
768
  export const projectDeployStatusSchema = z.enum(["IN_PROGRESS", "SUCCEEDED", "FAILED", "ROLLED_BACK"]);
786
769
  export const projectDeployUserSchema = z.object({
787
770
  id: z.string(),
@@ -807,12 +790,6 @@ export const projectDeploysResponseSchema = z.object({
807
790
  projectId: z.string(),
808
791
  deploys: z.array(projectDeploySchema)
809
792
  });
810
- export const projectSourceFilesResponseSchema = z.object({
811
- projectId: z.string(),
812
- deployId: z.string().nullable(),
813
- deployedAt: z.string().nullable(),
814
- files: z.array(fileSchema)
815
- });
816
793
  export const sdkListenQuerySchema = z.object({
817
794
  jobName: z.string().min(1),
818
795
  projectId: z.string().min(1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terse-types",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "description": "Shared Terse TypeScript types, enums, constants, and helpers.",
6
6
  "main": "./dist/index.js",
@@ -1,19 +0,0 @@
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;
@@ -1,71 +0,0 @@
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
- }