attio-ts-sdk 1.0.0 → 1.1.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/dist/index.mjs CHANGED
@@ -97,6 +97,12 @@ const runBatch = (items, options = {}) => {
97
97
 
98
98
  //#endregion
99
99
  //#region src/attio/cache.ts
100
+ const DEFAULT_METADATA_CACHE_TTL_MS = 300 * 1e3;
101
+ const DEFAULT_METADATA_CACHE_MAX_ENTRIES = {
102
+ attributes: 200,
103
+ options: 500,
104
+ statuses: 500
105
+ };
100
106
  var TtlCache = class {
101
107
  ttlMs;
102
108
  maxEntries;
@@ -131,6 +137,18 @@ var TtlCache = class {
131
137
  this.store.clear();
132
138
  }
133
139
  };
140
+ const createTtlCacheAdapter = (params) => {
141
+ const cache = new TtlCache({
142
+ ttlMs: params.ttlMs,
143
+ maxEntries: params.maxEntries
144
+ });
145
+ return {
146
+ get: (key) => cache.get(key),
147
+ set: (key, value) => cache.set(key, value),
148
+ delete: (key) => cache.delete(key),
149
+ clear: () => cache.clear()
150
+ };
151
+ };
134
152
  const clientCache = /* @__PURE__ */ new Map();
135
153
  const getCachedClient = (key, validator) => {
136
154
  const cached = clientCache.get(key);
@@ -149,12 +167,88 @@ const setCachedClient = (key, client) => {
149
167
  const clearClientCache = () => {
150
168
  clientCache.clear();
151
169
  };
170
+ const ANONYMOUS_HASH = "anon";
152
171
  const hashToken = (value) => {
172
+ if (value === void 0) return ANONYMOUS_HASH;
153
173
  let hash = 5381;
154
174
  for (let i = 0; i < value.length; i += 1) hash = hash * 33 ^ value.charCodeAt(i);
155
175
  return (hash >>> 0).toString(36);
156
176
  };
157
177
  const createTtlCache = (options) => new TtlCache(options);
178
+ const metadataCacheRegistry = /* @__PURE__ */ new Map();
179
+ const resolveMaxEntries = (maxEntries, scope) => {
180
+ if (typeof maxEntries === "number") return maxEntries;
181
+ if (maxEntries && maxEntries[scope] !== void 0) return maxEntries[scope];
182
+ return DEFAULT_METADATA_CACHE_MAX_ENTRIES[scope];
183
+ };
184
+ const isMetadataCacheDisabled = (config) => config.enabled === false;
185
+ const createMetadataCacheManager = (config = {}) => {
186
+ if (isMetadataCacheDisabled(config)) return {
187
+ get: () => void 0,
188
+ clear: () => void 0
189
+ };
190
+ const ttlMs = config.ttlMs ?? DEFAULT_METADATA_CACHE_TTL_MS;
191
+ const adapterFactory = config.adapter ?? { create: (params) => createTtlCacheAdapter(params) };
192
+ const caches = /* @__PURE__ */ new Map();
193
+ const get = (scope) => {
194
+ const existing = caches.get(scope);
195
+ if (existing) return existing;
196
+ const adapter = adapterFactory.create({
197
+ scope,
198
+ ttlMs,
199
+ maxEntries: resolveMaxEntries(config.maxEntries, scope)
200
+ });
201
+ caches.set(scope, adapter);
202
+ return adapter;
203
+ };
204
+ const clear = () => {
205
+ for (const adapter of caches.values()) adapter.clear();
206
+ caches.clear();
207
+ };
208
+ return {
209
+ get,
210
+ clear
211
+ };
212
+ };
213
+ const buildMetadataCacheFingerprint = (config) => {
214
+ return `ttl:${config.ttlMs ?? "default"}|max:${typeof config.maxEntries === "number" ? config.maxEntries : JSON.stringify(config.maxEntries ?? "default")}`;
215
+ };
216
+ const getMetadataCacheManager = (key, config) => {
217
+ if (config?.enabled === false) return createMetadataCacheManager(config);
218
+ if (config?.adapter) return createMetadataCacheManager(config);
219
+ const registryKey = `${key}|${config ? buildMetadataCacheFingerprint(config) : "default"}`;
220
+ const existing = metadataCacheRegistry.get(registryKey);
221
+ if (existing) return existing;
222
+ const manager = createMetadataCacheManager(config);
223
+ metadataCacheRegistry.set(registryKey, manager);
224
+ return manager;
225
+ };
226
+ const clearMetadataCacheRegistry = () => {
227
+ for (const manager of metadataCacheRegistry.values()) manager.clear();
228
+ metadataCacheRegistry.clear();
229
+ };
230
+ const isAttioCacheDisabled = (config) => config?.enabled === false;
231
+ const resolveMetadataCacheConfig = (config) => {
232
+ if (isAttioCacheDisabled(config)) return { enabled: false };
233
+ const metadataBase = config?.metadata;
234
+ if (metadataBase?.enabled === false) return { enabled: false };
235
+ return {
236
+ enabled: true,
237
+ ttlMs: metadataBase?.ttlMs,
238
+ maxEntries: metadataBase?.maxEntries,
239
+ adapter: metadataBase?.adapter
240
+ };
241
+ };
242
+ const createAttioCacheManager = (key, config) => {
243
+ const metadata = getMetadataCacheManager(key, resolveMetadataCacheConfig(config));
244
+ const clear = () => {
245
+ metadata.clear();
246
+ };
247
+ return {
248
+ metadata,
249
+ clear
250
+ };
251
+ };
158
252
 
159
253
  //#endregion
160
254
  //#region src/generated/core/bodySerializer.gen.ts
@@ -766,6 +860,22 @@ const createClient = (config = {}) => {
766
860
  };
767
861
  };
768
862
 
863
+ //#endregion
864
+ //#region src/attio/config.ts
865
+ const TRAILING_SLASHES_REGEX = /\/+$/;
866
+ const DEFAULT_BASE_URL = "https://api.attio.com";
867
+ const getEnvValue = (key) => {
868
+ if (typeof process === "undefined") return;
869
+ return process.env?.[key];
870
+ };
871
+ const normalizeBaseUrl = (baseUrl) => baseUrl.replace(TRAILING_SLASHES_REGEX, "");
872
+ const resolveBaseUrl = (config) => {
873
+ return normalizeBaseUrl(config?.baseUrl ?? getEnvValue("ATTIO_BASE_URL") ?? DEFAULT_BASE_URL);
874
+ };
875
+ const resolveAuthToken = (config) => config?.apiKey ?? config?.accessToken ?? config?.authToken ?? getEnvValue("ATTIO_API_KEY") ?? getEnvValue("ATTIO_ACCESS_TOKEN");
876
+ const resolveResponseStyle = (config) => config?.responseStyle ?? "fields";
877
+ const resolveThrowOnError = (config) => config?.throwOnError ?? true;
878
+
769
879
  //#endregion
770
880
  //#region src/attio/error-enhancer.ts
771
881
  const knownFieldValues = /* @__PURE__ */ new Map();
@@ -961,31 +1071,6 @@ const normalizeAttioError = (error, context = {}) => {
961
1071
  return networkError;
962
1072
  };
963
1073
 
964
- //#endregion
965
- //#region src/attio/config.ts
966
- const TRAILING_SLASHES_REGEX = /\/+$/;
967
- const WHITESPACE_REGEX = /\s/;
968
- const DEFAULT_BASE_URL = "https://api.attio.com";
969
- const getEnvValue = (key) => {
970
- if (typeof process === "undefined") return;
971
- return process.env?.[key];
972
- };
973
- const normalizeBaseUrl = (baseUrl) => baseUrl.replace(TRAILING_SLASHES_REGEX, "");
974
- const resolveBaseUrl = (config) => {
975
- return normalizeBaseUrl(config?.baseUrl ?? getEnvValue("ATTIO_BASE_URL") ?? DEFAULT_BASE_URL);
976
- };
977
- const resolveAuthToken = (config) => config?.apiKey ?? config?.accessToken ?? config?.authToken ?? getEnvValue("ATTIO_API_KEY") ?? getEnvValue("ATTIO_ACCESS_TOKEN");
978
- const MISSING_API_KEY_ERROR = "Missing Attio API key. Set ATTIO_API_KEY or pass apiKey.";
979
- const AuthTokenSchema = z.string().min(1, MISSING_API_KEY_ERROR).min(10, "Invalid Attio API key: too short.").refine((t) => !WHITESPACE_REGEX.test(t), "Invalid Attio API key: contains whitespace.");
980
- const validateAuthToken = (token) => {
981
- if (token === void 0 || token.length === 0) throw new AttioConfigError(MISSING_API_KEY_ERROR, { code: "MISSING_API_KEY" });
982
- const result = AuthTokenSchema.safeParse(token);
983
- if (!result.success) throw new AttioConfigError(result.error.issues[0].message, { code: "INVALID_API_KEY" });
984
- return result.data;
985
- };
986
- const resolveResponseStyle = (config) => config?.responseStyle ?? "fields";
987
- const resolveThrowOnError = (config) => config?.throwOnError ?? true;
988
-
989
1074
  //#endregion
990
1075
  //#region src/attio/retry.ts
991
1076
  const DEFAULT_RETRY_CONFIG = {
@@ -1034,7 +1119,7 @@ const isRetryableError = (error, config) => {
1034
1119
  return isRetryableStatus(info?.status, config);
1035
1120
  };
1036
1121
  const getRetryAfterMs = (error) => extractRetryErrorInfo(error)?.retryAfterMs;
1037
- const callWithRetry = async (fn, config) => {
1122
+ async function callWithRetry(fn, config) {
1038
1123
  const retryConfig = {
1039
1124
  ...DEFAULT_RETRY_CONFIG,
1040
1125
  ...config
@@ -1052,13 +1137,20 @@ const callWithRetry = async (fn, config) => {
1052
1137
  attempt += 1;
1053
1138
  }
1054
1139
  throw new AttioRetryError("Retry attempts exhausted.", { code: "RETRY_EXHAUSTED" });
1055
- };
1140
+ }
1056
1141
 
1057
1142
  //#endregion
1058
1143
  //#region src/attio/client.ts
1059
1144
  const interceptorUseSchema = z.object({ use: z.function() }).passthrough();
1060
1145
  const attioClientShapeSchema = z.object({
1061
1146
  request: z.function(),
1147
+ cache: z.object({
1148
+ metadata: z.object({
1149
+ get: z.function(),
1150
+ clear: z.function()
1151
+ }).passthrough(),
1152
+ clear: z.function()
1153
+ }).passthrough(),
1062
1154
  interceptors: z.object({
1063
1155
  error: interceptorUseSchema,
1064
1156
  request: interceptorUseSchema,
@@ -1066,16 +1158,16 @@ const attioClientShapeSchema = z.object({
1066
1158
  }).passthrough()
1067
1159
  }).passthrough();
1068
1160
  const AttioClientSchema = z.any().refine((value) => attioClientShapeSchema.safeParse(value).success, { message: "Invalid cached Attio client." });
1069
- const combineSignalsWithAny = (initSignal, controllerSignal) => AbortSignal.any([initSignal, controllerSignal]);
1070
- const combineSignalsWithFallback = (initSignal, controllerSignal) => {
1161
+ const combineSignalsWithAny = ({ requestSignal, timeoutSignal }) => AbortSignal.any([requestSignal, timeoutSignal]);
1162
+ const combineSignalsWithFallback = ({ requestSignal, timeoutSignal }) => {
1071
1163
  const combinedController = new AbortController();
1072
- if (initSignal.aborted) {
1164
+ if (requestSignal.aborted) {
1073
1165
  combinedController.abort();
1074
1166
  return { combinedSignal: combinedController.signal };
1075
1167
  }
1076
1168
  const abortCombined = () => combinedController.abort();
1077
- initSignal.addEventListener("abort", abortCombined, { once: true });
1078
- controllerSignal.addEventListener("abort", abortCombined, { once: true });
1169
+ requestSignal.addEventListener("abort", abortCombined, { once: true });
1170
+ timeoutSignal.addEventListener("abort", abortCombined, { once: true });
1079
1171
  return {
1080
1172
  combinedSignal: combinedController.signal,
1081
1173
  abortCombined
@@ -1090,8 +1182,14 @@ const resolveFetch = (config) => {
1090
1182
  const timeoutId = setTimeout(() => controller.abort(), config.timeoutMs);
1091
1183
  let combinedSignal = controller.signal;
1092
1184
  let abortCombined;
1093
- if (init?.signal) if (typeof AbortSignal !== "undefined" && "any" in AbortSignal) combinedSignal = combineSignalsWithAny(init.signal, controller.signal);
1094
- else ({combinedSignal, abortCombined} = combineSignalsWithFallback(init.signal, controller.signal));
1185
+ if (init?.signal) {
1186
+ const signals = {
1187
+ requestSignal: init.signal,
1188
+ timeoutSignal: controller.signal
1189
+ };
1190
+ if (typeof AbortSignal !== "undefined" && "any" in AbortSignal) combinedSignal = combineSignalsWithAny(signals);
1191
+ else ({combinedSignal, abortCombined} = combineSignalsWithFallback(signals));
1192
+ }
1095
1193
  try {
1096
1194
  return await baseFetch(input, {
1097
1195
  ...init,
@@ -1109,12 +1207,77 @@ const resolveFetch = (config) => {
1109
1207
  const buildClientCacheKey = ({ config, authToken }) => {
1110
1208
  if (config.cache?.key) return `${config.cache.key}:${hashToken(authToken)}`;
1111
1209
  };
1112
- const applyInterceptors = (client) => {
1113
- client.interceptors.error.use((error, response, request, options) => normalizeAttioError(error, {
1114
- response,
1115
- request,
1116
- options
1117
- }));
1210
+ const buildMetadataCacheKey = ({ config, authToken, baseUrl }) => `${config.cache?.key ?? "attio"}:${hashToken(authToken)}:${baseUrl}`;
1211
+ const composeHook = (first, second) => {
1212
+ if (!first) return second;
1213
+ if (!second) return first;
1214
+ return (payload) => {
1215
+ first(payload);
1216
+ second(payload);
1217
+ };
1218
+ };
1219
+ const createLoggerHooks = (logger) => {
1220
+ if (!logger) return {};
1221
+ const { debug, error: logError } = logger;
1222
+ return {
1223
+ onRequest: debug ? ({ request }) => debug("attio.request", {
1224
+ method: request.method,
1225
+ url: request.url
1226
+ }) : void 0,
1227
+ onResponse: debug ? ({ response, request }) => debug("attio.response", {
1228
+ method: request.method,
1229
+ url: request.url,
1230
+ status: response.status
1231
+ }) : void 0,
1232
+ onError: logError ? ({ error, request, response }) => logError("attio.error", {
1233
+ message: error.message,
1234
+ code: error.code,
1235
+ status: error.status,
1236
+ requestId: error.requestId,
1237
+ url: request?.url,
1238
+ responseStatus: response?.status
1239
+ }) : void 0
1240
+ };
1241
+ };
1242
+ const resolveClientHooks = (config) => {
1243
+ const loggerHooks = createLoggerHooks(config?.logger);
1244
+ const customHooks = config?.hooks ?? {};
1245
+ return {
1246
+ onRequest: composeHook(loggerHooks.onRequest, customHooks.onRequest),
1247
+ onResponse: composeHook(loggerHooks.onResponse, customHooks.onResponse),
1248
+ onError: composeHook(loggerHooks.onError, customHooks.onError)
1249
+ };
1250
+ };
1251
+ const applyInterceptors = (client, hooks) => {
1252
+ if (hooks.onRequest) client.interceptors.request.use((request, options) => {
1253
+ hooks.onRequest?.({
1254
+ request,
1255
+ options
1256
+ });
1257
+ return request;
1258
+ });
1259
+ if (hooks.onResponse) client.interceptors.response.use((response, request, options) => {
1260
+ hooks.onResponse?.({
1261
+ response,
1262
+ request,
1263
+ options
1264
+ });
1265
+ return response;
1266
+ });
1267
+ client.interceptors.error.use((error, response, request, options) => {
1268
+ const normalized = normalizeAttioError(error, {
1269
+ response,
1270
+ request,
1271
+ options
1272
+ });
1273
+ hooks.onError?.({
1274
+ error: normalized,
1275
+ response,
1276
+ request,
1277
+ options
1278
+ });
1279
+ return normalized;
1280
+ });
1118
1281
  };
1119
1282
  const wrapClient = (base, retry) => {
1120
1283
  const requestWithRetry = (options) => {
@@ -1155,6 +1318,7 @@ const createAttioClientWithAuthToken = ({ config = {}, authToken }) => {
1155
1318
  const baseUrl = resolveBaseUrl(config);
1156
1319
  const responseStyle = resolveResponseStyle(config);
1157
1320
  const throwOnError = resolveThrowOnError(config);
1321
+ const hooks = resolveClientHooks(config);
1158
1322
  const { cleanConfig, headers, retry, timeoutMs } = extractAndCleanConfig(config);
1159
1323
  const mergedHeaders = mergeHeaders({ Accept: "application/json" }, headers);
1160
1324
  const base = createClient({
@@ -1169,22 +1333,28 @@ const createAttioClientWithAuthToken = ({ config = {}, authToken }) => {
1169
1333
  responseStyle,
1170
1334
  throwOnError
1171
1335
  });
1172
- applyInterceptors(base);
1173
- return wrapClient(base, retry);
1336
+ applyInterceptors(base, hooks);
1337
+ const wrapped = wrapClient(base, retry);
1338
+ const cache = createAttioCacheManager(buildMetadataCacheKey({
1339
+ config,
1340
+ authToken,
1341
+ baseUrl
1342
+ }), config.cache);
1343
+ return Object.assign(wrapped, { cache });
1174
1344
  };
1175
1345
  const createAttioClient = (config = {}) => {
1176
1346
  return createAttioClientWithAuthToken({
1177
1347
  config,
1178
- authToken: validateAuthToken(resolveAuthToken(config))
1348
+ authToken: resolveAuthToken(config)
1179
1349
  });
1180
1350
  };
1181
1351
  const getAttioClient = (config = {}) => {
1182
1352
  const cacheEnabled = config.cache?.enabled ?? true;
1183
- const authToken = validateAuthToken(resolveAuthToken(config));
1184
- const cacheKey = buildClientCacheKey({
1353
+ const authToken = resolveAuthToken(config);
1354
+ const cacheKey = authToken ? buildClientCacheKey({
1185
1355
  config,
1186
1356
  authToken
1187
- });
1357
+ }) : void 0;
1188
1358
  if (cacheEnabled && cacheKey) {
1189
1359
  const cached = getCachedClient(cacheKey, AttioClientSchema);
1190
1360
  if (cached) return cached;
@@ -18460,35 +18630,136 @@ const getV2Self = (options) => (options?.client ?? client).get({
18460
18630
 
18461
18631
  //#endregion
18462
18632
  //#region src/attio/response.ts
18463
- const unwrapData = (result) => {
18464
- if (!result || typeof result !== "object") return result;
18465
- if ("data" in result) return result.data;
18466
- return result;
18467
- };
18468
- const unwrapItems = (result) => {
18469
- const data = unwrapData(result);
18470
- if (Array.isArray(data)) return data;
18471
- if (data && typeof data === "object") {
18633
+ const DEFAULT_UNWRAP_DEPTH = 3;
18634
+ const responseEnvelopeSchema = z.object({
18635
+ data: z.unknown().optional(),
18636
+ error: z.unknown().optional(),
18637
+ request: z.instanceof(Request).optional(),
18638
+ response: z.instanceof(Response).optional()
18639
+ }).passthrough();
18640
+ function unwrapData(result, options = {}) {
18641
+ const maxDepth = options.maxDepth ?? DEFAULT_UNWRAP_DEPTH;
18642
+ let current = result;
18643
+ for (let depth = 0; depth < maxDepth; depth += 1) {
18644
+ if (!current || typeof current !== "object") break;
18645
+ if (!("data" in current)) break;
18646
+ current = current.data;
18647
+ }
18648
+ if (options.schema) {
18649
+ const parsed = options.schema.safeParse(current);
18650
+ if (!parsed.success) throw createSchemaError(parsed.error);
18651
+ return parsed.data;
18652
+ }
18653
+ return current;
18654
+ }
18655
+ /**
18656
+ * Searches nested data structures for an array, checking `data`, `items`,
18657
+ * and `records` keys at each level up to DEFAULT_UNWRAP_DEPTH.
18658
+ */
18659
+ const findArrayInData = (initialData) => {
18660
+ let data = initialData;
18661
+ for (let depth = 0; depth < DEFAULT_UNWRAP_DEPTH; depth += 1) {
18662
+ if (Array.isArray(data)) return data;
18663
+ if (!data || typeof data !== "object") return;
18472
18664
  const record = data;
18473
18665
  const nested = record.data ?? record.items ?? record.records;
18474
- if (Array.isArray(nested)) return nested;
18666
+ if (nested === void 0) return;
18667
+ data = nested;
18475
18668
  }
18476
- return [];
18669
+ };
18670
+ const validateItemsArray = (items, schema) => {
18671
+ const parsed = z.array(schema).safeParse(items);
18672
+ if (!parsed.success) throw createSchemaError(parsed.error);
18673
+ return parsed.data;
18674
+ };
18675
+ function unwrapItems(result, options = {}) {
18676
+ const items = findArrayInData(unwrapData(result));
18677
+ if (!items) return [];
18678
+ if (options.schema) return validateItemsArray(items, options.schema);
18679
+ return items;
18680
+ }
18681
+ const readPaginationCursor = (pagination) => {
18682
+ if (!pagination || typeof pagination !== "object") return null;
18683
+ const cursor = pagination.next_cursor ?? pagination.nextCursor;
18684
+ return typeof cursor === "string" ? cursor : null;
18477
18685
  };
18478
18686
  const unwrapPaginationCursor = (result) => {
18479
- const readCursor = (pagination) => {
18480
- if (!pagination || typeof pagination !== "object") return null;
18481
- const cursor = pagination.next_cursor ?? pagination.nextCursor;
18482
- return typeof cursor === "string" ? cursor : null;
18483
- };
18484
18687
  if (result && typeof result === "object") {
18485
- const rootCursor = readCursor(result.pagination);
18688
+ const rootCursor = readPaginationCursor(result.pagination);
18486
18689
  if (rootCursor) return rootCursor;
18487
18690
  }
18488
18691
  const data = unwrapData(result);
18489
18692
  if (!data || typeof data !== "object") return null;
18490
- return readCursor(data.pagination);
18693
+ return readPaginationCursor(data.pagination);
18694
+ };
18695
+ const readPaginationOffset = (pagination) => {
18696
+ if (!pagination || typeof pagination !== "object") return null;
18697
+ const record = pagination;
18698
+ const nextOffset = record.next_offset ?? record.nextOffset;
18699
+ return typeof nextOffset === "number" ? nextOffset : null;
18700
+ };
18701
+ const unwrapPaginationOffset = (result) => {
18702
+ if (result && typeof result === "object") {
18703
+ const rootOffset = readPaginationOffset(result.pagination);
18704
+ if (rootOffset !== null) return rootOffset;
18705
+ }
18706
+ const data = unwrapData(result);
18707
+ if (!data || typeof data !== "object") return null;
18708
+ return readPaginationOffset(data.pagination);
18491
18709
  };
18710
+ const parseResponseEnvelope = (result) => {
18711
+ const parsed = responseEnvelopeSchema.safeParse(result);
18712
+ if (!parsed.success) return;
18713
+ return parsed.data;
18714
+ };
18715
+ const createSchemaError = (details) => new AttioResponseError("Invalid API response: schema mismatch", {
18716
+ code: "INVALID_RESPONSE",
18717
+ data: details
18718
+ });
18719
+ function assertOk(result, options) {
18720
+ const envelope = parseResponseEnvelope(result);
18721
+ if (envelope?.error !== void 0) throw normalizeAttioError(envelope.error, {
18722
+ response: envelope.response,
18723
+ request: envelope.request
18724
+ });
18725
+ const unwrapped = unwrapData(envelope?.data ?? result, { maxDepth: options?.maxDepth });
18726
+ if (!options?.schema) return unwrapped;
18727
+ const parsed = options.schema.safeParse(unwrapped);
18728
+ if (!parsed.success) throw createSchemaError(parsed.error);
18729
+ return parsed.data;
18730
+ }
18731
+ function toResult(result, options) {
18732
+ const envelope = parseResponseEnvelope(result);
18733
+ if (envelope?.error !== void 0) return {
18734
+ ok: false,
18735
+ error: normalizeAttioError(envelope.error, {
18736
+ response: envelope.response,
18737
+ request: envelope.request
18738
+ }),
18739
+ request: envelope.request,
18740
+ response: envelope.response
18741
+ };
18742
+ const unwrapped = unwrapData(envelope?.data ?? result, { maxDepth: options?.maxDepth });
18743
+ if (!options?.schema) return {
18744
+ ok: true,
18745
+ value: unwrapped,
18746
+ request: envelope?.request,
18747
+ response: envelope?.response
18748
+ };
18749
+ const parsed = options.schema.safeParse(unwrapped);
18750
+ if (!parsed.success) return {
18751
+ ok: false,
18752
+ error: createSchemaError(parsed.error),
18753
+ request: envelope?.request,
18754
+ response: envelope?.response
18755
+ };
18756
+ return {
18757
+ ok: true,
18758
+ value: parsed.data,
18759
+ request: envelope?.request,
18760
+ response: envelope?.response
18761
+ };
18762
+ }
18492
18763
 
18493
18764
  //#endregion
18494
18765
  //#region src/attio/lists.ts
@@ -18498,7 +18769,8 @@ const listLists = async (input = {}) => {
18498
18769
  const getList = async (input) => {
18499
18770
  return unwrapData(await getV2ListsByList({
18500
18771
  client: resolveAttioClient(input),
18501
- path: { list: input.list }
18772
+ path: { list: input.list },
18773
+ ...input.options
18502
18774
  }));
18503
18775
  };
18504
18776
  const queryListEntries = async (input) => {
@@ -18518,6 +18790,7 @@ const addListEntry = async (input) => {
18518
18790
  client: resolveAttioClient(input),
18519
18791
  path: { list: input.list },
18520
18792
  body: { data: {
18793
+ parent_object: input.parentObject,
18521
18794
  parent_record_id: input.parentRecordId,
18522
18795
  entry_values: input.entryValues ?? {}
18523
18796
  } },
@@ -18550,19 +18823,7 @@ const removeListEntry = async (input) => {
18550
18823
 
18551
18824
  //#endregion
18552
18825
  //#region src/attio/metadata.ts
18553
- const DEFAULT_TTL_MS = 300 * 1e3;
18554
- const attributesCache = createTtlCache({
18555
- ttlMs: DEFAULT_TTL_MS,
18556
- maxEntries: 200
18557
- });
18558
- const optionsCache = createTtlCache({
18559
- ttlMs: DEFAULT_TTL_MS,
18560
- maxEntries: 500
18561
- });
18562
- const statusesCache = createTtlCache({
18563
- ttlMs: DEFAULT_TTL_MS,
18564
- maxEntries: 500
18565
- });
18826
+ const getMetadataCache = (client, scope) => client.cache.metadata.get(scope);
18566
18827
  const buildKey = (target, identifier, attribute) => [
18567
18828
  target,
18568
18829
  identifier,
@@ -18579,33 +18840,51 @@ const buildAttributeMetadataPath = (input) => ({
18579
18840
  identifier: input.identifier,
18580
18841
  attribute: input.attribute
18581
18842
  });
18582
- const listAttributeMetadata = async ({ input, cache, fetcher }) => {
18843
+ const listAttributeMetadata = async ({ input, cache, fetcher, itemSchema }) => {
18583
18844
  const cacheKey = buildKey(input.target, input.identifier, input.attribute);
18584
- const cached = cache.get(cacheKey);
18585
- if (cached) return cached;
18845
+ const arraySchema = z.array(itemSchema);
18846
+ if (cache) {
18847
+ const cached = cache.get(cacheKey);
18848
+ if (cached) {
18849
+ const parsed = arraySchema.safeParse(cached);
18850
+ if (parsed.success) return parsed.data;
18851
+ cache.delete(cacheKey);
18852
+ }
18853
+ }
18854
+ const client = resolveAttioClient(input);
18855
+ const options = input.options ?? {};
18586
18856
  const items = unwrapItems(await fetcher({
18587
- client: resolveAttioClient(input),
18857
+ client,
18588
18858
  path: buildAttributeMetadataPath(input),
18589
- ...input.options
18590
- }));
18859
+ ...options
18860
+ }), { schema: itemSchema });
18591
18861
  const titles = extractTitles(items);
18592
18862
  updateKnownFieldValues(input.attribute, titles);
18593
- cache.set(cacheKey, items);
18863
+ cache?.set(cacheKey, items);
18594
18864
  return items;
18595
18865
  };
18596
18866
  const listAttributes = async (input) => {
18867
+ const client = resolveAttioClient(input);
18868
+ const cache = getMetadataCache(client, "attributes");
18597
18869
  const cacheKey = buildKey(input.target, input.identifier);
18598
- const cached = attributesCache.get(cacheKey);
18599
- if (cached) return cached;
18870
+ const arraySchema = z.array(zAttribute);
18871
+ if (cache) {
18872
+ const cached = cache.get(cacheKey);
18873
+ if (cached) {
18874
+ const parsed = arraySchema.safeParse(cached);
18875
+ if (!parsed.success) throw createSchemaError(parsed.error);
18876
+ return parsed.data;
18877
+ }
18878
+ }
18600
18879
  const items = unwrapItems(await getV2ByTargetByIdentifierAttributes({
18601
- client: resolveAttioClient(input),
18880
+ client,
18602
18881
  path: {
18603
18882
  target: input.target,
18604
18883
  identifier: input.identifier
18605
18884
  },
18606
18885
  ...input.options
18607
- }));
18608
- attributesCache.set(cacheKey, items);
18886
+ }), { schema: zAttribute });
18887
+ cache?.set(cacheKey, items);
18609
18888
  return items;
18610
18889
  };
18611
18890
  const getAttribute = async (input) => {
@@ -18617,18 +18896,32 @@ const getAttribute = async (input) => {
18617
18896
  attribute: input.attribute
18618
18897
  },
18619
18898
  ...input.options
18620
- }));
18899
+ }), { schema: zAttribute });
18900
+ };
18901
+ const getAttributeOptions = (input) => {
18902
+ const client = resolveAttioClient(input);
18903
+ return listAttributeMetadata({
18904
+ input: {
18905
+ ...input,
18906
+ client
18907
+ },
18908
+ cache: getMetadataCache(client, "options"),
18909
+ fetcher: getV2ByTargetByIdentifierAttributesByAttributeOptions,
18910
+ itemSchema: zSelectOption
18911
+ });
18912
+ };
18913
+ const getAttributeStatuses = (input) => {
18914
+ const client = resolveAttioClient(input);
18915
+ return listAttributeMetadata({
18916
+ input: {
18917
+ ...input,
18918
+ client
18919
+ },
18920
+ cache: getMetadataCache(client, "statuses"),
18921
+ fetcher: getV2ByTargetByIdentifierAttributesByAttributeStatuses,
18922
+ itemSchema: zStatus
18923
+ });
18621
18924
  };
18622
- const getAttributeOptions = async (input) => listAttributeMetadata({
18623
- input,
18624
- cache: optionsCache,
18625
- fetcher: getV2ByTargetByIdentifierAttributesByAttributeOptions
18626
- });
18627
- const getAttributeStatuses = async (input) => listAttributeMetadata({
18628
- input,
18629
- cache: statusesCache,
18630
- fetcher: getV2ByTargetByIdentifierAttributesByAttributeStatuses
18631
- });
18632
18925
 
18633
18926
  //#endregion
18634
18927
  //#region src/attio/notes.ts
@@ -18638,7 +18931,8 @@ const listNotes = async (input = {}) => {
18638
18931
  const getNote = async (input) => {
18639
18932
  return unwrapData(await getV2NotesByNoteId({
18640
18933
  client: resolveAttioClient(input),
18641
- path: { note_id: input.noteId }
18934
+ path: { note_id: input.noteId },
18935
+ ...input.options
18642
18936
  }));
18643
18937
  };
18644
18938
  const createNote = async (input) => {
@@ -18648,7 +18942,10 @@ const createNote = async (input) => {
18648
18942
  parent_object: input.parentObject,
18649
18943
  parent_record_id: input.parentRecordId,
18650
18944
  title: input.title,
18651
- content: input.content
18945
+ format: input.format,
18946
+ content: input.content,
18947
+ created_at: input.createdAt,
18948
+ meeting_id: input.meetingId
18652
18949
  } },
18653
18950
  ...input.options
18654
18951
  }));
@@ -18656,11 +18953,62 @@ const createNote = async (input) => {
18656
18953
  const deleteNote = async (input) => {
18657
18954
  await deleteV2NotesByNoteId({
18658
18955
  client: resolveAttioClient(input),
18659
- path: { note_id: input.noteId }
18956
+ path: { note_id: input.noteId },
18957
+ ...input.options
18660
18958
  });
18661
18959
  return true;
18662
18960
  };
18663
18961
 
18962
+ //#endregion
18963
+ //#region src/attio/objects.ts
18964
+ const AttioObjectSchema = z.object({
18965
+ id: z.object({
18966
+ workspace_id: z.string(),
18967
+ object_id: z.string()
18968
+ }),
18969
+ api_slug: z.string(),
18970
+ singular_noun: z.string(),
18971
+ plural_noun: z.string(),
18972
+ created_at: z.string()
18973
+ }).passthrough();
18974
+ const listObjects = async (input = {}) => {
18975
+ return unwrapItems(await getV2Objects({
18976
+ client: resolveAttioClient(input),
18977
+ ...input.options
18978
+ }), { schema: AttioObjectSchema });
18979
+ };
18980
+ const getObject = async (input) => {
18981
+ return unwrapData(await getV2ObjectsByObject({
18982
+ client: resolveAttioClient(input),
18983
+ path: { object: input.object },
18984
+ ...input.options
18985
+ }), { schema: AttioObjectSchema });
18986
+ };
18987
+ const createObject = async (input) => {
18988
+ return unwrapData(await postV2Objects({
18989
+ client: resolveAttioClient(input),
18990
+ body: { data: {
18991
+ api_slug: input.apiSlug,
18992
+ singular_noun: input.singularNoun,
18993
+ plural_noun: input.pluralNoun
18994
+ } },
18995
+ ...input.options
18996
+ }), { schema: AttioObjectSchema });
18997
+ };
18998
+ const buildUpdateObjectData = (input) => ({
18999
+ ...input.apiSlug !== void 0 && { api_slug: input.apiSlug },
19000
+ ...input.singularNoun !== void 0 && { singular_noun: input.singularNoun },
19001
+ ...input.pluralNoun !== void 0 && { plural_noun: input.pluralNoun }
19002
+ });
19003
+ const updateObject = async (input) => {
19004
+ return unwrapData(await patchV2ObjectsByObject({
19005
+ client: resolveAttioClient(input),
19006
+ path: { object: input.object },
19007
+ body: { data: buildUpdateObjectData(input) },
19008
+ ...input.options
19009
+ }), { schema: AttioObjectSchema });
19010
+ };
19011
+
18664
19012
  //#endregion
18665
19013
  //#region src/attio/pagination.ts
18666
19014
  const createPageResultSchema = (itemSchema) => z.object({
@@ -18671,17 +19019,38 @@ const basePageResultSchema = z.object({
18671
19019
  items: z.array(z.unknown()),
18672
19020
  nextCursor: z.string().nullish()
18673
19021
  });
19022
+ const createOffsetPageResultSchema = (itemSchema) => z.object({
19023
+ items: z.array(itemSchema),
19024
+ nextOffset: z.number().nullish(),
19025
+ total: z.number().optional()
19026
+ });
19027
+ const baseOffsetPageResultSchema = z.object({
19028
+ items: z.array(z.unknown()),
19029
+ nextOffset: z.number().nullish(),
19030
+ total: z.number().optional()
19031
+ });
18674
19032
  const toPageResult = (result) => {
18675
19033
  return {
18676
19034
  items: unwrapItems(result),
18677
19035
  nextCursor: unwrapPaginationCursor(result)
18678
19036
  };
18679
19037
  };
19038
+ const toOffsetPageResult = (result) => {
19039
+ return {
19040
+ items: unwrapItems(result),
19041
+ nextOffset: unwrapPaginationOffset(result)
19042
+ };
19043
+ };
18680
19044
  const parsePageResult = (page, itemSchema) => {
18681
19045
  const result = (itemSchema ? createPageResultSchema(itemSchema) : basePageResultSchema).safeParse(page);
18682
19046
  if (!result.success) return;
18683
19047
  return result.data;
18684
19048
  };
19049
+ const parseOffsetPageResult = (page, itemSchema) => {
19050
+ const result = (itemSchema ? createOffsetPageResultSchema(itemSchema) : baseOffsetPageResultSchema).safeParse(page);
19051
+ if (!result.success) return;
19052
+ return result.data;
19053
+ };
18685
19054
  const paginate = async (fetchPage, options = {}) => {
18686
19055
  const items = [];
18687
19056
  let cursor = options.cursor ?? null;
@@ -18698,6 +19067,36 @@ const paginate = async (fetchPage, options = {}) => {
18698
19067
  }
18699
19068
  return items.slice(0, maxItems);
18700
19069
  };
19070
+ const DEFAULT_OFFSET_PAGE_SIZE = 50;
19071
+ const resolveNextOffset = ({ nextOffset, pageItemsLength, limit, currentOffset }) => {
19072
+ if (typeof nextOffset === "number") return nextOffset;
19073
+ if (pageItemsLength < limit) return null;
19074
+ return currentOffset + limit;
19075
+ };
19076
+ const paginateOffset = async (fetchPage, options = {}) => {
19077
+ const items = [];
19078
+ const maxPages = options.maxPages ?? Number.POSITIVE_INFINITY;
19079
+ const maxItems = options.maxItems ?? Number.POSITIVE_INFINITY;
19080
+ const limit = Math.max(1, options.limit ?? options.pageSize ?? DEFAULT_OFFSET_PAGE_SIZE);
19081
+ let offset = Math.max(0, options.offset ?? 0);
19082
+ let pages = 0;
19083
+ while (pages < maxPages && items.length < maxItems) {
19084
+ const page = await fetchPage(offset, limit);
19085
+ const { items: pageItems, nextOffset } = parseOffsetPageResult(page, options.itemSchema) ?? toOffsetPageResult(page);
19086
+ items.push(...pageItems);
19087
+ pages += 1;
19088
+ if (items.length >= maxItems) break;
19089
+ const resolvedOffset = resolveNextOffset({
19090
+ nextOffset,
19091
+ pageItemsLength: pageItems.length,
19092
+ limit,
19093
+ currentOffset: offset
19094
+ });
19095
+ if (resolvedOffset === null || resolvedOffset <= offset) break;
19096
+ offset = resolvedOffset;
19097
+ }
19098
+ return items.slice(0, maxItems);
19099
+ };
18701
19100
 
18702
19101
  //#endregion
18703
19102
  //#region src/attio/record-utils.ts
@@ -18748,7 +19147,7 @@ const extractIdFromUnknown = (value) => {
18748
19147
  if (!record) return;
18749
19148
  return extractIdFromRecord(record);
18750
19149
  };
18751
- const extractValues = (obj) => {
19150
+ const extractValues$1 = (obj) => {
18752
19151
  const record = parseObject(obj);
18753
19152
  if (!record) return;
18754
19153
  return extractValuesObject(record);
@@ -18784,7 +19183,7 @@ const hasValidRecordId = (raw) => {
18784
19183
  const extractNestedValues = (result) => {
18785
19184
  const candidates = collectNestedCandidates(result);
18786
19185
  for (const candidate of candidates) {
18787
- const values = extractValues(candidate);
19186
+ const values = extractValues$1(candidate);
18788
19187
  if (values) return values;
18789
19188
  }
18790
19189
  };
@@ -18822,18 +19221,22 @@ function normalizeRecords(items, options = defaultNormalizeRecordOptions) {
18822
19221
  return normalized;
18823
19222
  }
18824
19223
 
19224
+ //#endregion
19225
+ //#region src/attio/schemas.ts
19226
+ const rawRecordSchema = z.record(z.string(), z.unknown());
19227
+
18825
19228
  //#endregion
18826
19229
  //#region src/attio/records.ts
18827
19230
  const createRecord = async (input) => {
18828
- return normalizeRecord(unwrapData(await postV2ObjectsByObjectRecords({
19231
+ return normalizeRecord(assertOk(await postV2ObjectsByObjectRecords({
18829
19232
  client: resolveAttioClient(input),
18830
19233
  path: { object: input.object },
18831
19234
  body: { data: { values: input.values } },
18832
19235
  ...input.options
18833
- })));
19236
+ }), { schema: rawRecordSchema }));
18834
19237
  };
18835
19238
  const updateRecord = async (input) => {
18836
- return normalizeRecord(unwrapData(await patchV2ObjectsByObjectRecordsByRecordId({
19239
+ return normalizeRecord(assertOk(await patchV2ObjectsByObjectRecordsByRecordId({
18837
19240
  client: resolveAttioClient(input),
18838
19241
  path: {
18839
19242
  object: input.object,
@@ -18841,28 +19244,26 @@ const updateRecord = async (input) => {
18841
19244
  },
18842
19245
  body: { data: { values: input.values } },
18843
19246
  ...input.options
18844
- })));
19247
+ }), { schema: rawRecordSchema }));
18845
19248
  };
18846
19249
  const upsertRecord = async (input) => {
18847
- return normalizeRecord(unwrapData(await putV2ObjectsByObjectRecords({
19250
+ return normalizeRecord(assertOk(await putV2ObjectsByObjectRecords({
18848
19251
  client: resolveAttioClient(input),
18849
19252
  path: { object: input.object },
18850
- body: {
18851
- data: { values: input.values },
18852
- matching_attribute: input.matchingAttribute
18853
- },
19253
+ body: { data: { values: input.values } },
19254
+ query: { matching_attribute: input.matchingAttribute },
18854
19255
  ...input.options
18855
- })));
19256
+ }), { schema: rawRecordSchema }));
18856
19257
  };
18857
19258
  const getRecord = async (input) => {
18858
- return normalizeRecord(unwrapData(await getV2ObjectsByObjectRecordsByRecordId({
19259
+ return normalizeRecord(assertOk(await getV2ObjectsByObjectRecordsByRecordId({
18859
19260
  client: resolveAttioClient(input),
18860
19261
  path: {
18861
19262
  object: input.object,
18862
19263
  record_id: input.recordId
18863
19264
  },
18864
19265
  ...input.options
18865
- })));
19266
+ }), { schema: rawRecordSchema }));
18866
19267
  };
18867
19268
  const deleteRecord = async (input) => {
18868
19269
  await deleteV2ObjectsByObjectRecordsByRecordId({
@@ -18887,7 +19288,203 @@ const queryRecords = async (input) => {
18887
19288
  offset: input.offset
18888
19289
  },
18889
19290
  ...input.options
18890
- })));
19291
+ }), { schema: rawRecordSchema }));
19292
+ };
19293
+
19294
+ //#endregion
19295
+ //#region src/attio/values.ts
19296
+ const nonEmptyStringSchema = z.string().min(1, "Expected a non-empty string.");
19297
+ const emailSchema = z.string().email("Expected a valid email address.");
19298
+ const currencyCodeSchema = z.string().regex(/^[A-Z]{3}$/, "Expected ISO 4217 currency code.");
19299
+ const finiteNumberSchema = z.number().finite("Expected a finite number.");
19300
+ const wrapSingle = (input) => [input];
19301
+ const value = {
19302
+ string: (input) => wrapSingle({ value: nonEmptyStringSchema.parse(input) }),
19303
+ number: (input) => wrapSingle({ value: finiteNumberSchema.parse(input) }),
19304
+ boolean: (input) => wrapSingle({ value: z.boolean().parse(input) }),
19305
+ domain: (input) => wrapSingle({ domain: nonEmptyStringSchema.parse(input) }),
19306
+ email: (input) => wrapSingle({ email_address: emailSchema.parse(input) }),
19307
+ currency: (input, currencyCode) => {
19308
+ const currency_value = finiteNumberSchema.parse(input);
19309
+ if (currencyCode === void 0) return wrapSingle({ currency_value });
19310
+ return wrapSingle({
19311
+ currency_value,
19312
+ currency_code: currencyCodeSchema.parse(currencyCode)
19313
+ });
19314
+ }
19315
+ };
19316
+ const recordValuesSchema = z.object({ values: z.record(z.string(), z.array(z.unknown())).optional() }).passthrough();
19317
+ const extractValues = (record) => {
19318
+ const parsed = recordValuesSchema.safeParse(record);
19319
+ if (!parsed.success) return;
19320
+ return parsed.data.values;
19321
+ };
19322
+ const parseValuesOrThrow = (raw, schema, attribute) => {
19323
+ const parsed = [];
19324
+ for (const entry of raw) {
19325
+ const result = schema.safeParse(entry);
19326
+ if (!result.success) throw new AttioResponseError(`Invalid API response: attribute "${attribute}" value mismatch`, {
19327
+ code: "INVALID_VALUE",
19328
+ data: result.error
19329
+ });
19330
+ parsed.push(result.data);
19331
+ }
19332
+ return parsed;
19333
+ };
19334
+ function getValue(record, attribute, options) {
19335
+ const raw = extractValues(record)?.[attribute];
19336
+ if (!raw) return;
19337
+ if (!options?.schema) return raw;
19338
+ return parseValuesOrThrow(raw, options.schema, attribute);
19339
+ }
19340
+ function getFirstValue(record, attribute, options) {
19341
+ const values = getValue(record, attribute, options);
19342
+ return values ? values[0] : void 0;
19343
+ }
19344
+
19345
+ //#endregion
19346
+ //#region src/attio/schema.ts
19347
+ const createAccessor = (attribute) => ({
19348
+ attribute,
19349
+ getValue: (record) => getValue(record, attribute.api_slug),
19350
+ getFirstValue: (record) => getFirstValue(record, attribute.api_slug),
19351
+ getValueAs: (record, options) => getValue(record, attribute.api_slug, options),
19352
+ getFirstValueAs: (record, options) => getFirstValue(record, attribute.api_slug, options)
19353
+ });
19354
+ const createSchema = async (input) => {
19355
+ const attributes = await listAttributes({
19356
+ ...input,
19357
+ options: input.options
19358
+ });
19359
+ const attributeMap = /* @__PURE__ */ new Map();
19360
+ const attributeSlugs = [];
19361
+ for (const attribute of attributes) {
19362
+ attributeMap.set(attribute.api_slug, attribute);
19363
+ attributeSlugs.push(attribute.api_slug);
19364
+ }
19365
+ const getAttribute = (slug) => attributeMap.get(slug);
19366
+ const getAttributeOrThrow = (slug) => {
19367
+ const attribute = getAttribute(slug);
19368
+ if (!attribute) throw new AttioResponseError(`Unknown attribute slug "${slug}" for ${input.target}:${input.identifier}`, { code: "UNKNOWN_ATTRIBUTE" });
19369
+ return attribute;
19370
+ };
19371
+ const getAccessor = (slug) => {
19372
+ const attribute = getAttribute(slug);
19373
+ if (!attribute) return;
19374
+ return createAccessor(attribute);
19375
+ };
19376
+ const getAccessorOrThrow = (slug) => createAccessor(getAttributeOrThrow(slug));
19377
+ return {
19378
+ target: input.target,
19379
+ identifier: input.identifier,
19380
+ attributes,
19381
+ attributeSlugs,
19382
+ getAttribute,
19383
+ getAttributeOrThrow,
19384
+ getAccessor,
19385
+ getAccessorOrThrow
19386
+ };
19387
+ };
19388
+
19389
+ //#endregion
19390
+ //#region src/attio/sdk.ts
19391
+ const createAttioSdk = (input = {}) => {
19392
+ const client = resolveAttioClient(input);
19393
+ return {
19394
+ client,
19395
+ objects: {
19396
+ list: (params = {}) => listObjects({
19397
+ ...params,
19398
+ client
19399
+ }),
19400
+ get: (params) => getObject({
19401
+ ...params,
19402
+ client
19403
+ }),
19404
+ create: (params) => createObject({
19405
+ ...params,
19406
+ client
19407
+ }),
19408
+ update: (params) => updateObject({
19409
+ ...params,
19410
+ client
19411
+ })
19412
+ },
19413
+ records: {
19414
+ create: (params) => createRecord({
19415
+ ...params,
19416
+ client
19417
+ }),
19418
+ update: (params) => updateRecord({
19419
+ ...params,
19420
+ client
19421
+ }),
19422
+ upsert: (params) => upsertRecord({
19423
+ ...params,
19424
+ client
19425
+ }),
19426
+ get: (params) => getRecord({
19427
+ ...params,
19428
+ client
19429
+ }),
19430
+ delete: (params) => deleteRecord({
19431
+ ...params,
19432
+ client
19433
+ }),
19434
+ query: (params) => queryRecords({
19435
+ ...params,
19436
+ client
19437
+ })
19438
+ },
19439
+ lists: {
19440
+ list: (params = {}) => listLists({
19441
+ ...params,
19442
+ client
19443
+ }),
19444
+ get: (params) => getList({
19445
+ ...params,
19446
+ client
19447
+ }),
19448
+ queryEntries: (params) => queryListEntries({
19449
+ ...params,
19450
+ client
19451
+ }),
19452
+ addEntry: (params) => addListEntry({
19453
+ ...params,
19454
+ client
19455
+ }),
19456
+ updateEntry: (params) => updateListEntry({
19457
+ ...params,
19458
+ client
19459
+ }),
19460
+ removeEntry: (params) => removeListEntry({
19461
+ ...params,
19462
+ client
19463
+ })
19464
+ },
19465
+ metadata: {
19466
+ listAttributes: (params) => listAttributes({
19467
+ ...params,
19468
+ client
19469
+ }),
19470
+ getAttribute: (params) => getAttribute({
19471
+ ...params,
19472
+ client
19473
+ }),
19474
+ getAttributeOptions: (params) => getAttributeOptions({
19475
+ ...params,
19476
+ client
19477
+ }),
19478
+ getAttributeStatuses: (params) => getAttributeStatuses({
19479
+ ...params,
19480
+ client
19481
+ }),
19482
+ schema: (params) => createSchema({
19483
+ ...params,
19484
+ client
19485
+ })
19486
+ }
19487
+ };
18891
19488
  };
18892
19489
 
18893
19490
  //#endregion
@@ -18902,26 +19499,27 @@ const searchRecords = async (input) => {
18902
19499
  limit: input.limit
18903
19500
  },
18904
19501
  ...input.options
18905
- })));
19502
+ }), { schema: rawRecordSchema }));
18906
19503
  };
18907
19504
 
18908
19505
  //#endregion
18909
19506
  //#region src/attio/tasks.ts
18910
19507
  const listTasks = async (input = {}) => {
18911
- return unwrapItems(await getV2Tasks({ client: resolveAttioClient(input) }));
19508
+ return unwrapItems(await getV2Tasks({ client: resolveAttioClient(input) }), { schema: zTask });
18912
19509
  };
18913
19510
  const getTask = async (input) => {
18914
19511
  return unwrapData(await getV2TasksByTaskId({
18915
19512
  client: resolveAttioClient(input),
18916
- path: { task_id: input.taskId }
18917
- }));
19513
+ path: { task_id: input.taskId },
19514
+ ...input.options
19515
+ }), { schema: zTask });
18918
19516
  };
18919
19517
  const createTask = async (input) => {
18920
19518
  return unwrapData(await postV2Tasks({
18921
19519
  client: resolveAttioClient(input),
18922
19520
  body: { data: input.data },
18923
19521
  ...input.options
18924
- }));
19522
+ }), { schema: zTask });
18925
19523
  };
18926
19524
  const updateTask = async (input) => {
18927
19525
  return unwrapData(await patchV2TasksByTaskId({
@@ -18929,14 +19527,14 @@ const updateTask = async (input) => {
18929
19527
  path: { task_id: input.taskId },
18930
19528
  body: { data: input.data },
18931
19529
  ...input.options
18932
- }));
19530
+ }), { schema: zTask });
18933
19531
  };
18934
19532
  const deleteTask = async (input) => {
18935
- await deleteV2TasksByTaskId({
19533
+ return (await deleteV2TasksByTaskId({
18936
19534
  client: resolveAttioClient(input),
18937
- path: { task_id: input.taskId }
18938
- });
18939
- return true;
19535
+ path: { task_id: input.taskId },
19536
+ ...input.options
19537
+ })).data ?? {};
18940
19538
  };
18941
19539
 
18942
19540
  //#endregion
@@ -18952,5 +19550,5 @@ const getWorkspaceMember = async (input) => {
18952
19550
  };
18953
19551
 
18954
19552
  //#endregion
18955
- export { AttioApiError, AttioBatchError, AttioConfigError, AttioEnvironmentError, AttioError, AttioNetworkError, AttioResponseError, AttioRetryError, DEFAULT_BASE_URL, DEFAULT_RETRY_CONFIG, TtlCache, addListEntry, buildAttributeMetadataPath, buildKey, calculateRetryDelay, callWithRetry, clearClientCache, createAttioClient, createNote, createPageResultSchema, createRecord, createTask, createTtlCache, deleteNote, deleteRecord, deleteTask, deleteV2CommentsByCommentId, deleteV2ListsByListEntriesByEntryId, deleteV2MeetingsByMeetingIdCallRecordingsByCallRecordingId, deleteV2NotesByNoteId, deleteV2ObjectsByObjectRecordsByRecordId, deleteV2TasksByTaskId, deleteV2WebhooksByWebhookId, enhanceAttioError, extractRecordId, extractTitles, filters, getAttioClient, getAttribute, getAttributeOptions, getAttributeStatuses, getCachedClient, getEnvValue, getKnownFieldValues, getList, getNote, getRecord, getTask, getV2ByTargetByIdentifierAttributes, getV2ByTargetByIdentifierAttributesByAttribute, getV2ByTargetByIdentifierAttributesByAttributeOptions, getV2ByTargetByIdentifierAttributesByAttributeStatuses, getV2CommentsByCommentId, getV2Lists, getV2ListsByList, getV2ListsByListEntriesByEntryId, getV2ListsByListEntriesByEntryIdAttributesByAttributeValues, getV2Meetings, getV2MeetingsByMeetingId, getV2MeetingsByMeetingIdCallRecordings, getV2MeetingsByMeetingIdCallRecordingsByCallRecordingId, getV2MeetingsByMeetingIdCallRecordingsByCallRecordingIdTranscript, getV2Notes, getV2NotesByNoteId, getV2Objects, getV2ObjectsByObject, getV2ObjectsByObjectRecordsByRecordId, getV2ObjectsByObjectRecordsByRecordIdAttributesByAttributeValues, getV2ObjectsByObjectRecordsByRecordIdEntries, getV2Self, getV2Tasks, getV2TasksByTaskId, getV2Threads, getV2ThreadsByThreadId, getV2Webhooks, getV2WebhooksByWebhookId, getV2WorkspaceMembers, getV2WorkspaceMembersByWorkspaceMemberId, getWorkspaceMember, hashToken, isRetryableError, isRetryableStatus, listAttributeMetadata, listAttributes, listLists, listNotes, listTasks, listWorkspaceMembers, normalizeAttioError, normalizeBaseUrl, normalizeRecord, normalizeRecords, paginate, parsePageResult, patchV2ByTargetByIdentifierAttributesByAttribute, patchV2ByTargetByIdentifierAttributesByAttributeOptionsByOption, patchV2ByTargetByIdentifierAttributesByAttributeStatusesByStatus, patchV2ListsByList, patchV2ListsByListEntriesByEntryId, patchV2ObjectsByObject, patchV2ObjectsByObjectRecordsByRecordId, patchV2TasksByTaskId, patchV2WebhooksByWebhookId, postV2ByTargetByIdentifierAttributes, postV2ByTargetByIdentifierAttributesByAttributeOptions, postV2ByTargetByIdentifierAttributesByAttributeStatuses, postV2Comments, postV2Lists, postV2ListsByListEntries, postV2ListsByListEntriesQuery, postV2Meetings, postV2MeetingsByMeetingIdCallRecordings, postV2Notes, postV2Objects, postV2ObjectsByObjectRecords, postV2ObjectsByObjectRecordsQuery, postV2ObjectsRecordsSearch, postV2Tasks, postV2Webhooks, putV2ListsByListEntries, putV2ListsByListEntriesByEntryId, putV2ObjectsByObjectRecords, putV2ObjectsByObjectRecordsByRecordId, queryListEntries, queryRecords, removeListEntry, resolveAttioClient, resolveAuthToken, resolveBaseUrl, resolveResponseStyle, resolveThrowOnError, runBatch, searchRecords, setCachedClient, sleep, toPageResult, unwrapData, unwrapItems, unwrapPaginationCursor, updateKnownFieldValues, updateListEntry, updateRecord, updateTask, upsertRecord, validateAuthToken };
19553
+ export { AttioApiError, AttioBatchError, AttioConfigError, AttioEnvironmentError, AttioError, AttioNetworkError, AttioResponseError, AttioRetryError, DEFAULT_BASE_URL, DEFAULT_METADATA_CACHE_MAX_ENTRIES, DEFAULT_METADATA_CACHE_TTL_MS, DEFAULT_RETRY_CONFIG, TtlCache, addListEntry, assertOk, buildAttributeMetadataPath, buildKey, calculateRetryDelay, callWithRetry, clearClientCache, clearMetadataCacheRegistry, createAttioCacheManager, createAttioClient, createAttioSdk, createNote, createObject, createOffsetPageResultSchema, createPageResultSchema, createRecord, createSchema, createSchemaError, createTask, createTtlCache, createTtlCacheAdapter, deleteNote, deleteRecord, deleteTask, deleteV2CommentsByCommentId, deleteV2ListsByListEntriesByEntryId, deleteV2MeetingsByMeetingIdCallRecordingsByCallRecordingId, deleteV2NotesByNoteId, deleteV2ObjectsByObjectRecordsByRecordId, deleteV2TasksByTaskId, deleteV2WebhooksByWebhookId, enhanceAttioError, extractRecordId, extractTitles, filters, getAttioClient, getAttribute, getAttributeOptions, getAttributeStatuses, getCachedClient, getEnvValue, getFirstValue, getKnownFieldValues, getList, getNote, getObject, getRecord, getTask, getV2ByTargetByIdentifierAttributes, getV2ByTargetByIdentifierAttributesByAttribute, getV2ByTargetByIdentifierAttributesByAttributeOptions, getV2ByTargetByIdentifierAttributesByAttributeStatuses, getV2CommentsByCommentId, getV2Lists, getV2ListsByList, getV2ListsByListEntriesByEntryId, getV2ListsByListEntriesByEntryIdAttributesByAttributeValues, getV2Meetings, getV2MeetingsByMeetingId, getV2MeetingsByMeetingIdCallRecordings, getV2MeetingsByMeetingIdCallRecordingsByCallRecordingId, getV2MeetingsByMeetingIdCallRecordingsByCallRecordingIdTranscript, getV2Notes, getV2NotesByNoteId, getV2Objects, getV2ObjectsByObject, getV2ObjectsByObjectRecordsByRecordId, getV2ObjectsByObjectRecordsByRecordIdAttributesByAttributeValues, getV2ObjectsByObjectRecordsByRecordIdEntries, getV2Self, getV2Tasks, getV2TasksByTaskId, getV2Threads, getV2ThreadsByThreadId, getV2Webhooks, getV2WebhooksByWebhookId, getV2WorkspaceMembers, getV2WorkspaceMembersByWorkspaceMemberId, getValue, getWorkspaceMember, hashToken, isRetryableError, isRetryableStatus, listAttributeMetadata, listAttributes, listLists, listNotes, listObjects, listTasks, listWorkspaceMembers, normalizeAttioError, normalizeBaseUrl, normalizeRecord, normalizeRecords, paginate, paginateOffset, parseOffsetPageResult, parsePageResult, patchV2ByTargetByIdentifierAttributesByAttribute, patchV2ByTargetByIdentifierAttributesByAttributeOptionsByOption, patchV2ByTargetByIdentifierAttributesByAttributeStatusesByStatus, patchV2ListsByList, patchV2ListsByListEntriesByEntryId, patchV2ObjectsByObject, patchV2ObjectsByObjectRecordsByRecordId, patchV2TasksByTaskId, patchV2WebhooksByWebhookId, postV2ByTargetByIdentifierAttributes, postV2ByTargetByIdentifierAttributesByAttributeOptions, postV2ByTargetByIdentifierAttributesByAttributeStatuses, postV2Comments, postV2Lists, postV2ListsByListEntries, postV2ListsByListEntriesQuery, postV2Meetings, postV2MeetingsByMeetingIdCallRecordings, postV2Notes, postV2Objects, postV2ObjectsByObjectRecords, postV2ObjectsByObjectRecordsQuery, postV2ObjectsRecordsSearch, postV2Tasks, postV2Webhooks, putV2ListsByListEntries, putV2ListsByListEntriesByEntryId, putV2ObjectsByObjectRecords, putV2ObjectsByObjectRecordsByRecordId, queryListEntries, queryRecords, removeListEntry, resolveAttioClient, resolveAuthToken, resolveBaseUrl, resolveResponseStyle, resolveThrowOnError, runBatch, searchRecords, setCachedClient, sleep, toOffsetPageResult, toPageResult, toResult, unwrapData, unwrapItems, unwrapPaginationCursor, unwrapPaginationOffset, updateKnownFieldValues, updateListEntry, updateObject, updateRecord, updateTask, upsertRecord, value };
18956
19554
  //# sourceMappingURL=index.mjs.map