@getclarify/nodejs-sdk 0.0.1

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.
Files changed (131) hide show
  1. package/dist/cjs/client.d.ts +54 -0
  2. package/dist/cjs/client.d.ts.map +1 -0
  3. package/dist/cjs/client.js +88 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/errors/api-error.d.ts +59 -0
  6. package/dist/cjs/errors/api-error.d.ts.map +1 -0
  7. package/dist/cjs/errors/api-error.js +104 -0
  8. package/dist/cjs/errors/api-error.js.map +1 -0
  9. package/dist/cjs/errors/index.d.ts +3 -0
  10. package/dist/cjs/errors/index.d.ts.map +1 -0
  11. package/dist/cjs/errors/index.js +10 -0
  12. package/dist/cjs/errors/index.js.map +1 -0
  13. package/dist/cjs/http/http-client.d.ts +46 -0
  14. package/dist/cjs/http/http-client.d.ts.map +1 -0
  15. package/dist/cjs/http/http-client.js +145 -0
  16. package/dist/cjs/http/http-client.js.map +1 -0
  17. package/dist/cjs/index.d.ts +9 -0
  18. package/dist/cjs/index.d.ts.map +1 -0
  19. package/dist/cjs/index.js +25 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/resources/base-resource.d.ts +15 -0
  22. package/dist/cjs/resources/base-resource.d.ts.map +1 -0
  23. package/dist/cjs/resources/base-resource.js +22 -0
  24. package/dist/cjs/resources/base-resource.js.map +1 -0
  25. package/dist/cjs/resources/messages.d.ts +105 -0
  26. package/dist/cjs/resources/messages.d.ts.map +1 -0
  27. package/dist/cjs/resources/messages.js +166 -0
  28. package/dist/cjs/resources/messages.js.map +1 -0
  29. package/dist/cjs/resources/records.d.ts +157 -0
  30. package/dist/cjs/resources/records.d.ts.map +1 -0
  31. package/dist/cjs/resources/records.js +264 -0
  32. package/dist/cjs/resources/records.js.map +1 -0
  33. package/dist/cjs/resources/relationships.d.ts +96 -0
  34. package/dist/cjs/resources/relationships.d.ts.map +1 -0
  35. package/dist/cjs/resources/relationships.js +157 -0
  36. package/dist/cjs/resources/relationships.js.map +1 -0
  37. package/dist/cjs/resources/tasks.d.ts +141 -0
  38. package/dist/cjs/resources/tasks.d.ts.map +1 -0
  39. package/dist/cjs/resources/tasks.js +211 -0
  40. package/dist/cjs/resources/tasks.js.map +1 -0
  41. package/dist/cjs/types/common.d.ts +126 -0
  42. package/dist/cjs/types/common.d.ts.map +1 -0
  43. package/dist/cjs/types/common.js +3 -0
  44. package/dist/cjs/types/common.js.map +1 -0
  45. package/dist/cjs/types/config.d.ts +36 -0
  46. package/dist/cjs/types/config.d.ts.map +1 -0
  47. package/dist/cjs/types/config.js +11 -0
  48. package/dist/cjs/types/config.js.map +1 -0
  49. package/dist/cjs/types/index.d.ts +4 -0
  50. package/dist/cjs/types/index.d.ts.map +1 -0
  51. package/dist/cjs/types/index.js +6 -0
  52. package/dist/cjs/types/index.js.map +1 -0
  53. package/dist/esm/client.d.ts +54 -0
  54. package/dist/esm/client.d.ts.map +1 -0
  55. package/dist/esm/client.js +88 -0
  56. package/dist/esm/client.js.map +1 -0
  57. package/dist/esm/errors/api-error.d.ts +59 -0
  58. package/dist/esm/errors/api-error.d.ts.map +1 -0
  59. package/dist/esm/errors/api-error.js +104 -0
  60. package/dist/esm/errors/api-error.js.map +1 -0
  61. package/dist/esm/errors/index.d.ts +3 -0
  62. package/dist/esm/errors/index.d.ts.map +1 -0
  63. package/dist/esm/errors/index.js +10 -0
  64. package/dist/esm/errors/index.js.map +1 -0
  65. package/dist/esm/http/http-client.d.ts +46 -0
  66. package/dist/esm/http/http-client.d.ts.map +1 -0
  67. package/dist/esm/http/http-client.js +145 -0
  68. package/dist/esm/http/http-client.js.map +1 -0
  69. package/dist/esm/index.d.ts +9 -0
  70. package/dist/esm/index.d.ts.map +1 -0
  71. package/dist/esm/index.js +25 -0
  72. package/dist/esm/index.js.map +1 -0
  73. package/dist/esm/resources/base-resource.d.ts +15 -0
  74. package/dist/esm/resources/base-resource.d.ts.map +1 -0
  75. package/dist/esm/resources/base-resource.js +22 -0
  76. package/dist/esm/resources/base-resource.js.map +1 -0
  77. package/dist/esm/resources/messages.d.ts +105 -0
  78. package/dist/esm/resources/messages.d.ts.map +1 -0
  79. package/dist/esm/resources/messages.js +166 -0
  80. package/dist/esm/resources/messages.js.map +1 -0
  81. package/dist/esm/resources/records.d.ts +157 -0
  82. package/dist/esm/resources/records.d.ts.map +1 -0
  83. package/dist/esm/resources/records.js +264 -0
  84. package/dist/esm/resources/records.js.map +1 -0
  85. package/dist/esm/resources/relationships.d.ts +96 -0
  86. package/dist/esm/resources/relationships.d.ts.map +1 -0
  87. package/dist/esm/resources/relationships.js +157 -0
  88. package/dist/esm/resources/relationships.js.map +1 -0
  89. package/dist/esm/resources/tasks.d.ts +141 -0
  90. package/dist/esm/resources/tasks.d.ts.map +1 -0
  91. package/dist/esm/resources/tasks.js +211 -0
  92. package/dist/esm/resources/tasks.js.map +1 -0
  93. package/dist/esm/types/common.d.ts +126 -0
  94. package/dist/esm/types/common.d.ts.map +1 -0
  95. package/dist/esm/types/common.js +3 -0
  96. package/dist/esm/types/common.js.map +1 -0
  97. package/dist/esm/types/config.d.ts +36 -0
  98. package/dist/esm/types/config.d.ts.map +1 -0
  99. package/dist/esm/types/config.js +11 -0
  100. package/dist/esm/types/config.js.map +1 -0
  101. package/dist/esm/types/index.d.ts +4 -0
  102. package/dist/esm/types/index.d.ts.map +1 -0
  103. package/dist/esm/types/index.js +6 -0
  104. package/dist/esm/types/index.js.map +1 -0
  105. package/dist/types/client.d.ts +54 -0
  106. package/dist/types/client.d.ts.map +1 -0
  107. package/dist/types/errors/api-error.d.ts +59 -0
  108. package/dist/types/errors/api-error.d.ts.map +1 -0
  109. package/dist/types/errors/index.d.ts +3 -0
  110. package/dist/types/errors/index.d.ts.map +1 -0
  111. package/dist/types/http/http-client.d.ts +46 -0
  112. package/dist/types/http/http-client.d.ts.map +1 -0
  113. package/dist/types/index.d.ts +9 -0
  114. package/dist/types/index.d.ts.map +1 -0
  115. package/dist/types/resources/base-resource.d.ts +15 -0
  116. package/dist/types/resources/base-resource.d.ts.map +1 -0
  117. package/dist/types/resources/messages.d.ts +105 -0
  118. package/dist/types/resources/messages.d.ts.map +1 -0
  119. package/dist/types/resources/records.d.ts +157 -0
  120. package/dist/types/resources/records.d.ts.map +1 -0
  121. package/dist/types/resources/relationships.d.ts +96 -0
  122. package/dist/types/resources/relationships.d.ts.map +1 -0
  123. package/dist/types/resources/tasks.d.ts +141 -0
  124. package/dist/types/resources/tasks.d.ts.map +1 -0
  125. package/dist/types/types/common.d.ts +126 -0
  126. package/dist/types/types/common.d.ts.map +1 -0
  127. package/dist/types/types/config.d.ts +36 -0
  128. package/dist/types/types/config.d.ts.map +1 -0
  129. package/dist/types/types/index.d.ts +4 -0
  130. package/dist/types/types/index.d.ts.map +1 -0
  131. package/package.json +68 -0
@@ -0,0 +1,105 @@
1
+ import type { HttpClient } from '../http/http-client.js';
2
+ import type { ListOptions, ListResponse, ResolvedConfig, Resource, ResourceCreate, SingleResponse } from '../types/index.js';
3
+ import { BaseResource } from './base-resource.js';
4
+ /**
5
+ * Message attributes.
6
+ */
7
+ export interface MessageAttributes {
8
+ subject?: string;
9
+ body?: string;
10
+ from?: string;
11
+ to?: string[];
12
+ cc?: string[];
13
+ bcc?: string[];
14
+ sent_at?: string;
15
+ received_at?: string;
16
+ [key: string]: unknown;
17
+ }
18
+ /**
19
+ * Manages messages in the Clarify platform.
20
+ */
21
+ export declare class MessagesResource extends BaseResource {
22
+ constructor(httpClient: HttpClient, config: ResolvedConfig);
23
+ /**
24
+ * Lists messages.
25
+ *
26
+ * @param options - Pagination, filter, and sort options
27
+ * @returns Paginated list of messages
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const messages = await clarify.messages.list({
32
+ * page: { limit: 20 },
33
+ * filter: { from: 'user@example.com' },
34
+ * });
35
+ * ```
36
+ */
37
+ list<T extends MessageAttributes = MessageAttributes>(options?: ListOptions): Promise<ListResponse<T>>;
38
+ /**
39
+ * Gets a single message by ID.
40
+ *
41
+ * @param id - The message ID
42
+ * @returns The message
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * const message = await clarify.messages.get('message-id');
47
+ * console.log(message.data.attributes.subject);
48
+ * ```
49
+ */
50
+ get<T extends MessageAttributes = MessageAttributes>(id: string): Promise<SingleResponse<T>>;
51
+ /**
52
+ * Creates a new message.
53
+ *
54
+ * @param data - The message data to create
55
+ * @returns The created message
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const message = await clarify.messages.create({
60
+ * type: 'message',
61
+ * attributes: {
62
+ * subject: 'Hello',
63
+ * body: 'Message content',
64
+ * from: 'sender@example.com',
65
+ * to: ['recipient@example.com'],
66
+ * },
67
+ * });
68
+ * ```
69
+ */
70
+ create<T extends MessageAttributes = MessageAttributes>(data: ResourceCreate<T>): Promise<SingleResponse<T>>;
71
+ /**
72
+ * Deletes a message.
73
+ *
74
+ * @param id - The message ID
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * await clarify.messages.delete('message-id');
79
+ * ```
80
+ */
81
+ delete(id: string): Promise<void>;
82
+ /**
83
+ * Async iterator for paginating through all messages.
84
+ *
85
+ * @param options - Filter and sort options (pagination is handled automatically)
86
+ * @yields Individual messages
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * for await (const message of clarify.messages.iterate()) {
91
+ * console.log(message.attributes.subject);
92
+ * }
93
+ * ```
94
+ */
95
+ iterate<T extends MessageAttributes = MessageAttributes>(options?: Omit<ListOptions, 'page'>): AsyncGenerator<Resource<T>, void, undefined>;
96
+ /**
97
+ * Builds query parameters from list options.
98
+ */
99
+ private buildListQuery;
100
+ /**
101
+ * Extracts the cursor from a pagination URL.
102
+ */
103
+ private extractCursor;
104
+ }
105
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/resources/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,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AAC,IAAI,CAAC;IAOvC;;;;;;;;;;;;OAYG;IACI,OAAO,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EAC5D,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAClC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC;IAiB/C;;OAEG;IACH,OAAO,CAAC,cAAc;IAgCtB;;OAEG;IACH,OAAO,CAAC,aAAa;CAYtB"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessagesResource = void 0;
4
+ const base_resource_js_1 = require("./base-resource.js");
5
+ /**
6
+ * Manages messages in the Clarify platform.
7
+ */
8
+ class MessagesResource extends base_resource_js_1.BaseResource {
9
+ constructor(httpClient, config) {
10
+ super(httpClient, config);
11
+ }
12
+ /**
13
+ * Lists messages.
14
+ *
15
+ * @param options - Pagination, filter, and sort options
16
+ * @returns Paginated list of messages
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const messages = await clarify.messages.list({
21
+ * page: { limit: 20 },
22
+ * filter: { from: 'user@example.com' },
23
+ * });
24
+ * ```
25
+ */
26
+ async list(options) {
27
+ const query = this.buildListQuery(options);
28
+ return this.httpClient.request({
29
+ method: 'GET',
30
+ path: `${this.basePath}/messages`,
31
+ query,
32
+ });
33
+ }
34
+ /**
35
+ * Gets a single message by ID.
36
+ *
37
+ * @param id - The message ID
38
+ * @returns The message
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const message = await clarify.messages.get('message-id');
43
+ * console.log(message.data.attributes.subject);
44
+ * ```
45
+ */
46
+ async get(id) {
47
+ return this.httpClient.request({
48
+ method: 'GET',
49
+ path: `${this.basePath}/messages/${id}`,
50
+ });
51
+ }
52
+ /**
53
+ * Creates a new message.
54
+ *
55
+ * @param data - The message data to create
56
+ * @returns The created message
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const message = await clarify.messages.create({
61
+ * type: 'message',
62
+ * attributes: {
63
+ * subject: 'Hello',
64
+ * body: 'Message content',
65
+ * from: 'sender@example.com',
66
+ * to: ['recipient@example.com'],
67
+ * },
68
+ * });
69
+ * ```
70
+ */
71
+ async create(data) {
72
+ const body = { data };
73
+ return this.httpClient.request({
74
+ method: 'POST',
75
+ path: `${this.basePath}/messages`,
76
+ body,
77
+ });
78
+ }
79
+ /**
80
+ * Deletes a message.
81
+ *
82
+ * @param id - The message ID
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * await clarify.messages.delete('message-id');
87
+ * ```
88
+ */
89
+ async delete(id) {
90
+ await this.httpClient.request({
91
+ method: 'DELETE',
92
+ path: `${this.basePath}/messages/${id}`,
93
+ });
94
+ }
95
+ /**
96
+ * Async iterator for paginating through all messages.
97
+ *
98
+ * @param options - Filter and sort options (pagination is handled automatically)
99
+ * @yields Individual messages
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * for await (const message of clarify.messages.iterate()) {
104
+ * console.log(message.attributes.subject);
105
+ * }
106
+ * ```
107
+ */
108
+ async *iterate(options) {
109
+ let cursor;
110
+ do {
111
+ const response = await this.list({
112
+ ...options,
113
+ page: { cursor, limit: 100 },
114
+ });
115
+ for (const message of response.data) {
116
+ yield message;
117
+ }
118
+ cursor = this.extractCursor(response.links?.next);
119
+ } while (cursor);
120
+ }
121
+ /**
122
+ * Builds query parameters from list options.
123
+ */
124
+ buildListQuery(options) {
125
+ const query = {};
126
+ if (options?.page?.cursor) {
127
+ query['page[cursor]'] = options.page.cursor;
128
+ }
129
+ if (options?.page?.limit) {
130
+ query['page[limit]'] = options.page.limit;
131
+ }
132
+ if (options?.filter) {
133
+ for (const [key, value] of Object.entries(options.filter)) {
134
+ if (value !== undefined) {
135
+ query[`filter[${key}]`] = Array.isArray(value)
136
+ ? value.join(',')
137
+ : String(value);
138
+ }
139
+ }
140
+ }
141
+ if (options?.sort) {
142
+ const sorts = Array.isArray(options.sort) ? options.sort : [options.sort];
143
+ query['sort'] = sorts
144
+ .map((s) => (s.direction === 'desc' ? `-${s.field}` : s.field))
145
+ .join(',');
146
+ }
147
+ return query;
148
+ }
149
+ /**
150
+ * Extracts the cursor from a pagination URL.
151
+ */
152
+ extractCursor(url) {
153
+ if (!url) {
154
+ return undefined;
155
+ }
156
+ try {
157
+ const parsedUrl = new URL(url);
158
+ return parsedUrl.searchParams.get('page[cursor]') ?? undefined;
159
+ }
160
+ catch {
161
+ return undefined;
162
+ }
163
+ }
164
+ }
165
+ exports.MessagesResource = MessagesResource;
166
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/resources/messages.ts"],"names":[],"mappings":";;;AAUA,yDAAkD;AAiBlD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,+BAAY;IAChD,YAAY,UAAsB,EAAE,MAAsB;QACxD,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,IAAI,CACR,OAAqB;QAErB,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE3C,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAkB;YAC9C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,WAAW;YACjC,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,GAAG,CACP,EAAU;QAEV,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAoB;YAChD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,GAAG,IAAI,CAAC,QAAQ,aAAa,EAAE,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,MAAM,CACV,IAAuB;QAEvB,MAAM,IAAI,GAAkB,EAAE,IAAI,EAA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,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAtLD,4CAsLC"}
@@ -0,0 +1,157 @@
1
+ import type { HttpClient } from '../http/http-client.js';
2
+ import type { ListOptions, ListResponse, ResolvedConfig, Resource, ResourceCreate, ResourceUpdate, SingleResponse } from '../types/index.js';
3
+ import { BaseResource } from './base-resource.js';
4
+ import { RelationshipsResource } from './relationships.js';
5
+ /**
6
+ * Manages CRUD operations for records.
7
+ */
8
+ export declare class RecordsResource extends BaseResource {
9
+ /** Sub-resource for managing record relationships */
10
+ readonly relationships: RelationshipsResource;
11
+ constructor(httpClient: HttpClient, config: ResolvedConfig);
12
+ /**
13
+ * Lists records of a given entity type.
14
+ *
15
+ * @param entity - The entity type (e.g., 'company', 'person', 'deal')
16
+ * @param options - Pagination, filter, and sort options
17
+ * @returns Paginated list of records
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const companies = await clarify.records.list('company', {
22
+ * page: { limit: 20 },
23
+ * filter: { industry: 'technology' },
24
+ * sort: { field: 'name', direction: 'asc' },
25
+ * });
26
+ * ```
27
+ */
28
+ list<T = Record<string, unknown>>(entity: string, options?: ListOptions): Promise<ListResponse<T>>;
29
+ /**
30
+ * Gets a single record by ID.
31
+ *
32
+ * @param entity - The entity type
33
+ * @param id - The record ID
34
+ * @returns The record
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const company = await clarify.records.get('company', 'company-id');
39
+ * console.log(company.data.attributes.name);
40
+ * ```
41
+ */
42
+ get<T = Record<string, unknown>>(entity: string, id: string): Promise<SingleResponse<T>>;
43
+ /**
44
+ * Creates a new record.
45
+ *
46
+ * @param entity - The entity type
47
+ * @param data - The resource data to create
48
+ * @returns The created record
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const company = await clarify.records.create('company', {
53
+ * type: 'company',
54
+ * attributes: { name: 'Acme Inc.', industry: 'technology' },
55
+ * });
56
+ * ```
57
+ */
58
+ create<T = Record<string, unknown>>(entity: string, data: ResourceCreate<T>): Promise<SingleResponse<T>>;
59
+ /**
60
+ * Updates an existing record.
61
+ *
62
+ * @param entity - The entity type
63
+ * @param id - The record ID
64
+ * @param data - The resource data to update
65
+ * @returns The updated record
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const company = await clarify.records.update('company', 'company-id', {
70
+ * type: 'company',
71
+ * id: 'company-id',
72
+ * attributes: { industry: 'software' },
73
+ * });
74
+ * ```
75
+ */
76
+ update<T = Record<string, unknown>>(entity: string, id: string, data: ResourceUpdate<T>): Promise<SingleResponse<T>>;
77
+ /**
78
+ * Deletes a record.
79
+ *
80
+ * @param entity - The entity type
81
+ * @param id - The record ID
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * await clarify.records.delete('company', 'company-id');
86
+ * ```
87
+ */
88
+ delete(entity: string, id: string): Promise<void>;
89
+ /**
90
+ * Creates multiple records in bulk.
91
+ *
92
+ * @param entity - The entity type
93
+ * @param data - Array of resources to create
94
+ * @returns The created records
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const companies = await clarify.records.createBulk('company', [
99
+ * { type: 'company', attributes: { name: 'Acme Inc.' } },
100
+ * { type: 'company', attributes: { name: 'Globex Corp.' } },
101
+ * ]);
102
+ * ```
103
+ */
104
+ createBulk<T = Record<string, unknown>>(entity: string, data: ResourceCreate<T>[]): Promise<ListResponse<T>>;
105
+ /**
106
+ * Updates multiple records in bulk.
107
+ *
108
+ * @param entity - The entity type
109
+ * @param data - Array of resources to update
110
+ * @returns The updated records
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const companies = await clarify.records.updateBulk('company', [
115
+ * { type: 'company', id: 'id-1', attributes: { industry: 'tech' } },
116
+ * { type: 'company', id: 'id-2', attributes: { industry: 'finance' } },
117
+ * ]);
118
+ * ```
119
+ */
120
+ updateBulk<T = Record<string, unknown>>(entity: string, data: ResourceUpdate<T>[]): Promise<ListResponse<T>>;
121
+ /**
122
+ * Deletes multiple records in bulk.
123
+ *
124
+ * @param entity - The entity type
125
+ * @param ids - Array of record IDs to delete
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * await clarify.records.deleteBulk('company', ['id-1', 'id-2', 'id-3']);
130
+ * ```
131
+ */
132
+ deleteBulk(entity: string, ids: string[]): Promise<void>;
133
+ /**
134
+ * Async iterator for paginating through all records.
135
+ *
136
+ * @param entity - The entity type
137
+ * @param options - Filter and sort options (pagination is handled automatically)
138
+ * @yields Individual records
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * for await (const company of clarify.records.iterate('company')) {
143
+ * console.log(company.attributes.name);
144
+ * }
145
+ * ```
146
+ */
147
+ iterate<T = Record<string, unknown>>(entity: string, options?: Omit<ListOptions, 'page'>): AsyncGenerator<Resource<T>, void, undefined>;
148
+ /**
149
+ * Builds query parameters from list options.
150
+ */
151
+ private buildListQuery;
152
+ /**
153
+ * Extracts the cursor from a pagination URL.
154
+ */
155
+ private extractCursor;
156
+ }
157
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../src/resources/records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAKV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,qDAAqD;IACrD,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;gBAElC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc;IAK1D;;;;;;;;;;;;;;;OAeG;IACG,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,MAAM,E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