terse-types 0.0.35 → 0.0.37
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/ACL.d.ts +375 -0
- package/dist/ACL.js +105 -0
- package/dist/ACLPolicy.d.ts +17 -0
- package/dist/ACLPolicy.js +18 -0
- package/dist/ApiRouteBuilder.d.ts +3 -0
- package/dist/ApiRoutes.json +3 -0
- package/dist/getConfigACLRules.d.ts +10 -0
- package/dist/getConfigACLRules.js +0 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.js +38 -2
- package/package.json +2 -2
- package/dist/AttioRecordFlatten.d.ts +0 -19
- package/dist/AttioRecordFlatten.js +0 -71
- package/dist/json-schema/terse-types.schema.json +0 -15994
package/dist/types.js
CHANGED
|
@@ -127,9 +127,38 @@ export const deviceTokenExchangeUserSchema = z.object({
|
|
|
127
127
|
firstName: z.string().nullable(),
|
|
128
128
|
displayName: z.string().nullable()
|
|
129
129
|
});
|
|
130
|
+
export const sdkOrganizationSummarySchema = z.object({
|
|
131
|
+
id: z.string(),
|
|
132
|
+
name: z.string()
|
|
133
|
+
});
|
|
130
134
|
export const deviceTokenExchangeResponseSchema = z.object({
|
|
131
135
|
apiKey: z.string(),
|
|
132
|
-
user: deviceTokenExchangeUserSchema
|
|
136
|
+
user: deviceTokenExchangeUserSchema,
|
|
137
|
+
organization: sdkOrganizationSummarySchema
|
|
138
|
+
});
|
|
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
|
+
displayName: z.string().nullable()
|
|
145
|
+
});
|
|
146
|
+
export const identifyOrganizationSchema = z.object({
|
|
147
|
+
id: z.string(),
|
|
148
|
+
name: z.string(),
|
|
149
|
+
roles: z.array(z.string())
|
|
150
|
+
});
|
|
151
|
+
export const identifyResponseSchema = z.object({
|
|
152
|
+
user: identifyUserSchema,
|
|
153
|
+
organizations: z.array(identifyOrganizationSchema)
|
|
154
|
+
});
|
|
155
|
+
export const sdkOrganizationsListResponseSchema = z.object({
|
|
156
|
+
organizations: z.array(sdkOrganizationSummarySchema),
|
|
157
|
+
activeOrganizationId: z.string()
|
|
158
|
+
});
|
|
159
|
+
export const switchOrganizationResponseSchema = z.object({
|
|
160
|
+
apiKey: z.string(),
|
|
161
|
+
organization: sdkOrganizationSummarySchema
|
|
133
162
|
});
|
|
134
163
|
const configInstanceDataSchema = configDataSchema;
|
|
135
164
|
export const triggerMetadataSchema = z.object({
|
|
@@ -610,9 +639,16 @@ export const apiTokenCreateRequestSchema = z.object({
|
|
|
610
639
|
export const apiTokenUpdateRequestSchema = z.object({
|
|
611
640
|
name: z.string().max(100)
|
|
612
641
|
});
|
|
613
|
-
export const
|
|
642
|
+
export const identifyRequestSchema = z.object({
|
|
614
643
|
accessToken: z.string()
|
|
615
644
|
});
|
|
645
|
+
export const deviceTokenExchangeRequestSchema = z.object({
|
|
646
|
+
accessToken: z.string(),
|
|
647
|
+
organizationId: z.string()
|
|
648
|
+
});
|
|
649
|
+
export const switchOrganizationRequestSchema = z.object({
|
|
650
|
+
organizationId: z.string()
|
|
651
|
+
});
|
|
616
652
|
export const sdkToolExecuteRequestSchema = z.object({
|
|
617
653
|
toolName: z.string(),
|
|
618
654
|
params: z.record(z.string(), z.unknown()).optional()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terse-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared Terse TypeScript types, enums, constants, and helpers.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"license": "
|
|
30
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"tsc-esm-fix": "^3.1.2",
|
|
33
33
|
"tsx": "^4.21.0",
|
|
@@ -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
|
-
}
|