terse-types 0.0.36 → 0.0.38

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/types.d.ts CHANGED
@@ -226,6 +226,11 @@ export declare const deviceTokenExchangeUserSchema: z.ZodObject<{
226
226
  firstName: z.ZodNullable<z.ZodString>;
227
227
  displayName: z.ZodNullable<z.ZodString>;
228
228
  }, z.core.$strip>;
229
+ export declare const sdkOrganizationSummarySchema: z.ZodObject<{
230
+ id: z.ZodString;
231
+ name: z.ZodString;
232
+ }, z.core.$strip>;
233
+ export type SdkOrganizationSummary = z.infer<typeof sdkOrganizationSummarySchema>;
229
234
  export declare const deviceTokenExchangeResponseSchema: z.ZodObject<{
230
235
  apiKey: z.ZodString;
231
236
  user: z.ZodObject<{
@@ -233,8 +238,55 @@ export declare const deviceTokenExchangeResponseSchema: z.ZodObject<{
233
238
  firstName: z.ZodNullable<z.ZodString>;
234
239
  displayName: z.ZodNullable<z.ZodString>;
235
240
  }, z.core.$strip>;
241
+ organization: z.ZodObject<{
242
+ id: z.ZodString;
243
+ name: z.ZodString;
244
+ }, z.core.$strip>;
236
245
  }, z.core.$strip>;
237
246
  export type DeviceTokenExchangeResponse = z.infer<typeof deviceTokenExchangeResponseSchema>;
247
+ export declare const identifyUserSchema: z.ZodObject<{
248
+ workosId: z.ZodString;
249
+ email: z.ZodString;
250
+ firstName: z.ZodNullable<z.ZodString>;
251
+ lastName: z.ZodNullable<z.ZodString>;
252
+ displayName: z.ZodNullable<z.ZodString>;
253
+ }, z.core.$strip>;
254
+ export declare const identifyOrganizationSchema: z.ZodObject<{
255
+ id: z.ZodString;
256
+ name: z.ZodString;
257
+ roles: z.ZodArray<z.ZodString>;
258
+ }, z.core.$strip>;
259
+ export declare const identifyResponseSchema: z.ZodObject<{
260
+ user: z.ZodObject<{
261
+ workosId: z.ZodString;
262
+ email: z.ZodString;
263
+ firstName: z.ZodNullable<z.ZodString>;
264
+ lastName: z.ZodNullable<z.ZodString>;
265
+ displayName: z.ZodNullable<z.ZodString>;
266
+ }, z.core.$strip>;
267
+ organizations: z.ZodArray<z.ZodObject<{
268
+ id: z.ZodString;
269
+ name: z.ZodString;
270
+ roles: z.ZodArray<z.ZodString>;
271
+ }, z.core.$strip>>;
272
+ }, z.core.$strip>;
273
+ export type IdentifyResponse = z.infer<typeof identifyResponseSchema>;
274
+ export declare const sdkOrganizationsListResponseSchema: z.ZodObject<{
275
+ organizations: z.ZodArray<z.ZodObject<{
276
+ id: z.ZodString;
277
+ name: z.ZodString;
278
+ }, z.core.$strip>>;
279
+ activeOrganizationId: z.ZodString;
280
+ }, z.core.$strip>;
281
+ export type SdkOrganizationsListResponse = z.infer<typeof sdkOrganizationsListResponseSchema>;
282
+ export declare const switchOrganizationResponseSchema: z.ZodObject<{
283
+ apiKey: z.ZodString;
284
+ organization: z.ZodObject<{
285
+ id: z.ZodString;
286
+ name: z.ZodString;
287
+ }, z.core.$strip>;
288
+ }, z.core.$strip>;
289
+ export type SwitchOrganizationResponse = z.infer<typeof switchOrganizationResponseSchema>;
238
290
  export declare const triggerMetadataSchema: z.ZodObject<{
239
291
  webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
240
292
  }, z.core.$strip>;
@@ -9269,6 +9321,37 @@ export declare const projectRotateApiKeyResponseSchema: z.ZodObject<{
9269
9321
  projectApiKey: z.ZodString;
9270
9322
  }, z.core.$strip>;
9271
9323
  export type ProjectRotateApiKeyResponse = z.infer<typeof projectRotateApiKeyResponseSchema>;
9324
+ export declare const SECRET_NAME_PATTERN: RegExp;
9325
+ export declare const MAX_SECRET_VALUE_BYTES: number;
9326
+ export declare function validateSecretName(name: string): string | null;
9327
+ export declare function validateSecretValue(value: string): string | null;
9328
+ export declare const projectSecretSummarySchema: z.ZodObject<{
9329
+ name: z.ZodString;
9330
+ }, z.core.$strip>;
9331
+ export type ProjectSecretSummary = z.infer<typeof projectSecretSummarySchema>;
9332
+ export declare const projectSecretsListResponseSchema: z.ZodObject<{
9333
+ secrets: z.ZodArray<z.ZodObject<{
9334
+ name: z.ZodString;
9335
+ }, z.core.$strip>>;
9336
+ }, z.core.$strip>;
9337
+ export type ProjectSecretsListResponse = z.infer<typeof projectSecretsListResponseSchema>;
9338
+ export declare const projectSecretUpsertRequestSchema: z.ZodObject<{
9339
+ name: z.ZodString;
9340
+ value: z.ZodString;
9341
+ }, z.core.$strip>;
9342
+ export type ProjectSecretUpsertRequest = z.infer<typeof projectSecretUpsertRequestSchema>;
9343
+ export declare const projectSecretsImportRequestSchema: z.ZodObject<{
9344
+ entries: z.ZodArray<z.ZodObject<{
9345
+ name: z.ZodString;
9346
+ value: z.ZodString;
9347
+ }, z.core.$strip>>;
9348
+ }, z.core.$strip>;
9349
+ export type ProjectSecretsImportRequest = z.infer<typeof projectSecretsImportRequestSchema>;
9350
+ export declare const projectSecretsImportResponseSchema: z.ZodObject<{
9351
+ added: z.ZodArray<z.ZodString>;
9352
+ updated: z.ZodArray<z.ZodString>;
9353
+ }, z.core.$strip>;
9354
+ export type ProjectSecretsImportResponse = z.infer<typeof projectSecretsImportResponseSchema>;
9272
9355
  export declare const terseProjectConfigSchema: z.ZodObject<{
9273
9356
  projectId: z.ZodString;
9274
9357
  name: z.ZodString;
@@ -9719,10 +9802,19 @@ export declare const apiTokenUpdateRequestSchema: z.ZodObject<{
9719
9802
  name: z.ZodString;
9720
9803
  }, z.core.$strip>;
9721
9804
  export type ApiTokenUpdateRequest = z.infer<typeof apiTokenUpdateRequestSchema>;
9805
+ export declare const identifyRequestSchema: z.ZodObject<{
9806
+ accessToken: z.ZodString;
9807
+ }, z.core.$strip>;
9808
+ export type IdentifyRequest = z.infer<typeof identifyRequestSchema>;
9722
9809
  export declare const deviceTokenExchangeRequestSchema: z.ZodObject<{
9723
9810
  accessToken: z.ZodString;
9811
+ organizationId: z.ZodString;
9724
9812
  }, z.core.$strip>;
9725
9813
  export type DeviceTokenExchangeRequest = z.infer<typeof deviceTokenExchangeRequestSchema>;
9814
+ export declare const switchOrganizationRequestSchema: z.ZodObject<{
9815
+ organizationId: z.ZodString;
9816
+ }, z.core.$strip>;
9817
+ export type SwitchOrganizationRequest = z.infer<typeof switchOrganizationRequestSchema>;
9726
9818
  export declare const sdkToolExecuteRequestSchema: z.ZodObject<{
9727
9819
  toolName: z.ZodString;
9728
9820
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
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({
@@ -512,6 +541,40 @@ export const projectRotateSigningSecretResponseSchema = z.object({
512
541
  export const projectRotateApiKeyResponseSchema = z.object({
513
542
  projectApiKey: z.string()
514
543
  });
544
+ export const SECRET_NAME_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
545
+ export const MAX_SECRET_VALUE_BYTES = 32 * 1024;
546
+ export function validateSecretName(name) {
547
+ if (!SECRET_NAME_PATTERN.test(name)) {
548
+ return "Secret names must match ^[A-Z][A-Z0-9_]{0,63}$";
549
+ }
550
+ if (name.startsWith("TERSE_")) {
551
+ return "Secret names cannot start with TERSE_";
552
+ }
553
+ return null;
554
+ }
555
+ export function validateSecretValue(value) {
556
+ if (new TextEncoder().encode(value).length > MAX_SECRET_VALUE_BYTES) {
557
+ return "Secret value must be 32KB or less";
558
+ }
559
+ return null;
560
+ }
561
+ export const projectSecretSummarySchema = z.object({
562
+ name: z.string()
563
+ });
564
+ export const projectSecretsListResponseSchema = z.object({
565
+ secrets: z.array(projectSecretSummarySchema)
566
+ });
567
+ export const projectSecretUpsertRequestSchema = z.object({
568
+ name: z.string(),
569
+ value: z.string()
570
+ });
571
+ export const projectSecretsImportRequestSchema = z.object({
572
+ entries: z.array(projectSecretUpsertRequestSchema).max(500)
573
+ });
574
+ export const projectSecretsImportResponseSchema = z.object({
575
+ added: z.array(z.string()),
576
+ updated: z.array(z.string())
577
+ });
515
578
  export const terseProjectConfigSchema = z.object({
516
579
  projectId: z.string().min(1),
517
580
  name: z.string().min(1),
@@ -610,9 +673,16 @@ export const apiTokenCreateRequestSchema = z.object({
610
673
  export const apiTokenUpdateRequestSchema = z.object({
611
674
  name: z.string().max(100)
612
675
  });
613
- export const deviceTokenExchangeRequestSchema = z.object({
676
+ export const identifyRequestSchema = z.object({
614
677
  accessToken: z.string()
615
678
  });
679
+ export const deviceTokenExchangeRequestSchema = z.object({
680
+ accessToken: z.string(),
681
+ organizationId: z.string()
682
+ });
683
+ export const switchOrganizationRequestSchema = z.object({
684
+ organizationId: z.string()
685
+ });
616
686
  export const sdkToolExecuteRequestSchema = z.object({
617
687
  toolName: z.string(),
618
688
  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.36",
3
+ "version": "0.0.38",
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
- }