@getclarify/nodejs-sdk 0.0.2 → 0.0.4

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 (79) hide show
  1. package/dist/cjs/client.d.ts +7 -5
  2. package/dist/cjs/client.d.ts.map +1 -1
  3. package/dist/cjs/client.js +8 -5
  4. package/dist/cjs/client.js.map +1 -1
  5. package/dist/cjs/index.d.ts +1 -0
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js +3 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/json-api/link.d.ts +40 -0
  10. package/dist/cjs/json-api/link.d.ts.map +1 -0
  11. package/dist/cjs/json-api/link.js +68 -0
  12. package/dist/cjs/json-api/link.js.map +1 -0
  13. package/dist/cjs/resources/resources.d.ts +208 -0
  14. package/dist/cjs/resources/resources.d.ts.map +1 -0
  15. package/dist/cjs/resources/resources.js +172 -0
  16. package/dist/cjs/resources/resources.js.map +1 -0
  17. package/dist/cjs/types/index.d.ts +1 -1
  18. package/dist/cjs/types/index.d.ts.map +1 -1
  19. package/dist/cjs/types/index.js.map +1 -1
  20. package/dist/esm/client.d.ts +7 -5
  21. package/dist/esm/client.d.ts.map +1 -1
  22. package/dist/esm/client.js +8 -5
  23. package/dist/esm/client.js.map +1 -1
  24. package/dist/esm/index.d.ts +1 -0
  25. package/dist/esm/index.d.ts.map +1 -1
  26. package/dist/esm/index.js +3 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/json-api/link.d.ts +40 -0
  29. package/dist/esm/json-api/link.d.ts.map +1 -0
  30. package/dist/esm/json-api/link.js +68 -0
  31. package/dist/esm/json-api/link.js.map +1 -0
  32. package/dist/esm/resources/resources.d.ts +208 -0
  33. package/dist/esm/resources/resources.d.ts.map +1 -0
  34. package/dist/esm/resources/resources.js +172 -0
  35. package/dist/esm/resources/resources.js.map +1 -0
  36. package/dist/esm/types/index.d.ts +1 -1
  37. package/dist/esm/types/index.d.ts.map +1 -1
  38. package/dist/esm/types/index.js.map +1 -1
  39. package/dist/types/client.d.ts +7 -5
  40. package/dist/types/client.d.ts.map +1 -1
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/json-api/link.d.ts +40 -0
  44. package/dist/types/json-api/link.d.ts.map +1 -0
  45. package/dist/types/resources/resources.d.ts +208 -0
  46. package/dist/types/resources/resources.d.ts.map +1 -0
  47. package/dist/types/types/index.d.ts +1 -1
  48. package/dist/types/types/index.d.ts.map +1 -1
  49. package/package.json +37 -37
  50. package/dist/cjs/resources/messages.d.ts +0 -105
  51. package/dist/cjs/resources/messages.d.ts.map +0 -1
  52. package/dist/cjs/resources/messages.js +0 -166
  53. package/dist/cjs/resources/messages.js.map +0 -1
  54. package/dist/cjs/resources/relationships.d.ts +0 -96
  55. package/dist/cjs/resources/relationships.d.ts.map +0 -1
  56. package/dist/cjs/resources/relationships.js +0 -157
  57. package/dist/cjs/resources/relationships.js.map +0 -1
  58. package/dist/cjs/resources/tasks.d.ts +0 -141
  59. package/dist/cjs/resources/tasks.d.ts.map +0 -1
  60. package/dist/cjs/resources/tasks.js +0 -211
  61. package/dist/cjs/resources/tasks.js.map +0 -1
  62. package/dist/esm/resources/messages.d.ts +0 -105
  63. package/dist/esm/resources/messages.d.ts.map +0 -1
  64. package/dist/esm/resources/messages.js +0 -166
  65. package/dist/esm/resources/messages.js.map +0 -1
  66. package/dist/esm/resources/relationships.d.ts +0 -96
  67. package/dist/esm/resources/relationships.d.ts.map +0 -1
  68. package/dist/esm/resources/relationships.js +0 -157
  69. package/dist/esm/resources/relationships.js.map +0 -1
  70. package/dist/esm/resources/tasks.d.ts +0 -141
  71. package/dist/esm/resources/tasks.d.ts.map +0 -1
  72. package/dist/esm/resources/tasks.js +0 -211
  73. package/dist/esm/resources/tasks.js.map +0 -1
  74. package/dist/types/resources/messages.d.ts +0 -105
  75. package/dist/types/resources/messages.d.ts.map +0 -1
  76. package/dist/types/resources/relationships.d.ts +0 -96
  77. package/dist/types/resources/relationships.d.ts.map +0 -1
  78. package/dist/types/resources/tasks.d.ts +0 -141
  79. package/dist/types/resources/tasks.d.ts.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import { RecordsResource } from './resources/records.js';
2
+ import { ResourcesResource } from './resources/resources.js';
2
3
  import type { ClarifyClientConfig } from './types/index.js';
3
4
  /**
4
5
  * The main client for interacting with the Clarify API.
@@ -21,16 +22,17 @@ import type { ClarifyClientConfig } from './types/index.js';
21
22
  * type: 'company',
22
23
  * attributes: { name: 'Acme Inc.' },
23
24
  * });
24
- *
25
- * // Iterate through all records
26
- * for await (const company of clarify.records.iterate('company')) {
27
- * console.log(company.attributes.name);
28
- * }
29
25
  * ```
30
26
  */
31
27
  export declare class ClarifyClient {
32
28
  /** Resource for managing records */
33
29
  readonly records: RecordsResource;
30
+ /**
31
+ * Resource for querying and creating resources via the `/resources` endpoints.
32
+ * Responses include relationships and an `included` array.
33
+ * Use `linkJsonApi` to resolve relationship references into inline objects.
34
+ */
35
+ readonly resources: ResourcesResource;
34
36
  private readonly config;
35
37
  private readonly httpClient;
36
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAG5E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,aAAa;IACxB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC;;;;;OAKG;gBACS,MAAM,EAAE,mBAAmB;IAOvC;;OAEG;IACH,OAAO,CAAC,aAAa;CA4BtB"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,kBAAkB,CAAC;AAG5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;IACxB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC;;;;;OAKG;gBACS,MAAM,EAAE,mBAAmB;IAQvC;;OAEG;IACH,OAAO,CAAC,aAAa;CA4BtB"}
@@ -3,4 +3,5 @@ export { ClarifyError, ClarifyApiError, ClarifyValidationError, ClarifyTimeoutEr
3
3
  export type { ApiErrorDetail } from './errors/index.js';
4
4
  export type { ClarifyClientConfig, ResourceIdentifier, Resource, ResourceCreate, ResourceUpdate, SingleResponse, ListResponse, PaginationLinks, PaginationMeta, PaginationOptions, FilterOptions, SortOptions, ListOptions, GetRecordOptions, FieldOperationRules, UpdateRecordOptions, } from './types/index.js';
5
5
  export { RecordsResource } from './resources/records.js';
6
+ export { ResourcesResource, type ResourceLinked, type SingleResourceResponse, type ListResourceResponse, type SortDirection, type ResourceGetParams, type ResourceListParams, type ResourceRelationshipInput, type ResourceRelationshipsInput, type ResourceCreateParams, type ResourceDeleteParams, } from './resources/resources.js';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Internal representation of a resource that may have relationships
3
+ * either as raw refs (before linking) or as full resources (after linking).
4
+ */
5
+ interface AnyResource {
6
+ type: string;
7
+ id: string;
8
+ attributes: Record<string, unknown>;
9
+ relationships?: Record<string, {
10
+ data: unknown;
11
+ }>;
12
+ }
13
+ /**
14
+ * Minimal shape of a raw JSON:API document as returned by the API,
15
+ * before relationship references are resolved.
16
+ */
17
+ export interface JsonApiDocument {
18
+ data: AnyResource | AnyResource[];
19
+ included?: AnyResource[];
20
+ meta?: Record<string, unknown>;
21
+ links?: Record<string, string | undefined>;
22
+ }
23
+ /**
24
+ * Resolves relationship references in a JSON:API document by replacing
25
+ * `{ type, id }` stubs with the full resource objects from `included`.
26
+ *
27
+ * The function operates on a deep clone of the document so the original
28
+ * is never mutated.
29
+ *
30
+ * @throws {Error} If a referenced resource is not present in `included`
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const linked = linkJsonApi(response);
35
+ * // linked.data.relationships.company.data now contains the full company object
36
+ * ```
37
+ */
38
+ export declare function linkJsonApi<T extends JsonApiDocument>(doc: T): T;
39
+ export {};
40
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/json-api/link.ts"],"names":[],"mappings":"AAWA;;;GAGG;AACH,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5C;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAuBhE"}
@@ -0,0 +1,208 @@
1
+ import type { HttpClient } from '../http/http-client.js';
2
+ import type { PaginationLinks, PaginationMeta, ResolvedConfig, ResourceIdentifier } from '../types/index.js';
3
+ import { BaseResource } from './base-resource.js';
4
+ /**
5
+ * A resource with fully resolved inline relationships.
6
+ * Each entry in `relationships` holds the complete resource object(s),
7
+ * not bare `{ type, id }` references.
8
+ */
9
+ export interface ResourceLinked<T = Record<string, unknown>> {
10
+ type: string;
11
+ id: string;
12
+ attributes: T;
13
+ relationships: Record<string, {
14
+ data: ResourceLinked | ResourceLinked[] | null;
15
+ }>;
16
+ }
17
+ /**
18
+ * Single resource response from the resources endpoint.
19
+ */
20
+ export interface SingleResourceResponse<T = Record<string, unknown>> {
21
+ data: ResourceLinked<T>;
22
+ included?: ResourceLinked[];
23
+ meta?: Record<string, unknown>;
24
+ }
25
+ /**
26
+ * List resource response from the resources endpoint.
27
+ */
28
+ export interface ListResourceResponse<T = Record<string, unknown>> {
29
+ data: ResourceLinked<T>[];
30
+ included?: ResourceLinked[];
31
+ links?: PaginationLinks;
32
+ meta?: PaginationMeta;
33
+ }
34
+ /**
35
+ * Sort direction for resource list requests.
36
+ */
37
+ export type SortDirection = 'ASC' | 'DESC';
38
+ /**
39
+ * Parameters for retrieving a single resource.
40
+ */
41
+ export interface ResourceGetParams {
42
+ /** The entity type (e.g., 'meeting', 'company') */
43
+ type: string;
44
+ /** The resource ID */
45
+ id: string;
46
+ /** Relationships to include in the response */
47
+ include?: string[];
48
+ }
49
+ /**
50
+ * Parameters for listing resources.
51
+ *
52
+ * Filters support simple equality as well as operator-based filtering:
53
+ * - Simple: `{ name: 'Acme' }` → `filter[name]=Acme`
54
+ * - Operator: `{ amount: { 'Is greater than': '100' } }` → `filter[amount][Is greater than]=100`
55
+ * - Nested path: `{ 'meeting.users._id': userId }` → `filter[meeting.users._id]=userId`
56
+ */
57
+ export interface ResourceListParams {
58
+ /** The entity type (e.g., 'meeting', 'company') */
59
+ type: string;
60
+ /** Relationships to include in the response */
61
+ include?: string[];
62
+ /** Filter options */
63
+ filter?: Record<string, string | Record<string, string>>;
64
+ /** Sort order for the results */
65
+ sortOrder?: {
66
+ column: string;
67
+ dir: SortDirection;
68
+ };
69
+ /** Pagination options using offset/limit */
70
+ page?: {
71
+ offset?: number;
72
+ limit?: number;
73
+ };
74
+ }
75
+ /**
76
+ * A to-one or to-many relationship reference for use when creating a resource.
77
+ *
78
+ * - To-one: `{ data: { type: 'user', id: 'u-123' } }`
79
+ * - To-many: `{ data: [{ type: 'person', id: 'p-1' }, { type: 'person', id: 'p-2' }] }`
80
+ * - Clear to-one: `{ data: null }`
81
+ */
82
+ export interface ResourceRelationshipInput {
83
+ data: ResourceIdentifier | ResourceIdentifier[] | null;
84
+ }
85
+ /**
86
+ * Map of relationship name → relationship input, passed to `resources.create()`.
87
+ */
88
+ export type ResourceRelationshipsInput = Record<string, ResourceRelationshipInput>;
89
+ /**
90
+ * Parameters for creating a resource.
91
+ */
92
+ export interface ResourceCreateParams<T = Record<string, unknown>> {
93
+ /** The entity type (e.g., 'meeting', 'company') */
94
+ type: string;
95
+ /** The resource attributes */
96
+ attributes: T;
97
+ /**
98
+ * Relationships to set on the new resource.
99
+ * - To-one: `{ data: { type: 'user', id: 'u-123' } }`
100
+ * - To-many: `{ data: [{ type: 'person', id: 'p-1' }, { type: 'person', id: 'p-2' }] }`
101
+ * - Clear to-one: `{ data: null }`
102
+ */
103
+ relationships?: ResourceRelationshipsInput;
104
+ }
105
+ /**
106
+ * Parameters for deleting a resource.
107
+ */
108
+ export interface ResourceDeleteParams {
109
+ /** The entity type (e.g., 'meeting', 'company') */
110
+ type: string;
111
+ /** The resource ID to delete */
112
+ id: string;
113
+ }
114
+ /**
115
+ * Manages read and create operations for resources
116
+ * (objects accessed via the `/resources` endpoints).
117
+ *
118
+ * Responses include a `relationships` map with fully resolved related records.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * // List meetings with attendees included
123
+ * const response = await clarify.resources.list({
124
+ * type: 'meeting',
125
+ * include: ['users', 'people'],
126
+ * filter: { 'meeting.users._id': currentUserId },
127
+ * });
128
+ *
129
+ * const firstMeetingUsers = response.data[0].relationships.users.data;
130
+ * ```
131
+ */
132
+ export declare class ResourcesResource extends BaseResource {
133
+ constructor(httpClient: HttpClient, config: ResolvedConfig);
134
+ private getEntityPath;
135
+ /**
136
+ * Retrieves a single resource by ID.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const response = await clarify.resources.get({
141
+ * type: 'meeting',
142
+ * id: 'abc123',
143
+ * include: ['users', 'people'],
144
+ * });
145
+ *
146
+ * const attendees = response.data.relationships.users.data;
147
+ * ```
148
+ */
149
+ get<T = Record<string, unknown>>(params: ResourceGetParams): Promise<SingleResourceResponse<T>>;
150
+ /**
151
+ * Lists resources with optional filtering, includes, and pagination.
152
+ *
153
+ * Filters support simple equality as well as operator-based filtering:
154
+ * - Simple: `{ name: 'Acme' }` → `filter[name]=Acme`
155
+ * - Operator: `{ amount: { 'Is greater than': '100' } }` → `filter[amount][Is greater than]=100`
156
+ * - Nested path: `{ 'meeting.users._id': userId }` → `filter[meeting.users._id]=userId`
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const response = await clarify.resources.list({
161
+ * type: 'meeting',
162
+ * include: ['users'],
163
+ * filter: {
164
+ * 'meeting.users._id': currentUserId,
165
+ * start: { 'Is on or after': new Date().toISOString() },
166
+ * },
167
+ * sortOrder: { column: 'start', dir: 'ASC' },
168
+ * page: { limit: 50 },
169
+ * });
170
+ * ```
171
+ */
172
+ list<T = Record<string, unknown>>(params: ResourceListParams): Promise<ListResourceResponse<T>>;
173
+ /**
174
+ * Creates a new resource, optionally setting relationships at the same time.
175
+ *
176
+ * To-one and to-many relationships are both supported via `relationships`:
177
+ * - To-one: `{ data: { type: 'user', id: 'u-123' } }`
178
+ * - To-many: `{ data: [{ type: 'person', id: 'p-1' }, { type: 'person', id: 'p-2' }] }`
179
+ * - Clear to-one: `{ data: null }`
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * // Create a meeting and immediately set its attendees
184
+ * const response = await clarify.resources.create({
185
+ * type: 'meeting',
186
+ * attributes: {
187
+ * title: 'Team standup',
188
+ * start: new Date().toISOString(),
189
+ * },
190
+ * relationships: {
191
+ * users: { data: [{ type: 'user', id: 'u-1' }, { type: 'user', id: 'u-2' }] },
192
+ * people: { data: [{ type: 'person', id: 'p-1' }] },
193
+ * },
194
+ * });
195
+ * ```
196
+ */
197
+ create<T = Record<string, unknown>>(params: ResourceCreateParams<T>): Promise<SingleResourceResponse<T>>;
198
+ /**
199
+ * Deletes a resource by ID.
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * await clarify.resources.delete({ type: 'meeting', id: 'abc123' });
204
+ * ```
205
+ */
206
+ delete(params: ResourceDeleteParams): Promise<void>;
207
+ }
208
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/resources/resources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,CAAC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AAC,CAAC,CAAC;IA4CnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC9B,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAkBrC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;CAS1D"}
@@ -1,4 +1,4 @@
1
- export type { ClarifyClientConfig, ResolvedConfig, } from './config.js';
1
+ export type { ClarifyClientConfig, ResolvedConfig } from './config.js';
2
2
  export { DEFAULT_CONFIG } from './config.js';
3
3
  export type { ResourceIdentifier, Resource, ResourceCreate, ResourceUpdate, SingleResponse, ListResponse, PaginationLinks, PaginationMeta, PaginationOptions, FilterOptions, SortOptions, ListOptions, CreateBody, UpdateBody, BulkCreateBody, BulkUpdateBody, BulkDeleteBody, HttpMethod, GetRecordOptions, FieldOperationRules, UpdateRecordOptions, } from './common.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,YAAY,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,YAAY,EACV,kBAAkB,EAClB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@getclarify/nodejs-sdk",
3
- "version": "0.0.2",
4
- "private": false,
5
- "publishConfig": {
6
- "access": "public",
7
- "registry": "https://registry.npmjs.org/"
8
- },
9
3
  "description": "JavaScript/TypeScript SDK for Clarify platform",
10
- "main": "./dist/cjs/index.js",
11
- "module": "./dist/esm/index.js",
12
- "types": "./dist/types/index.d.ts",
4
+ "version": "0.0.4",
5
+ "devDependencies": {
6
+ "@vitest/coverage-v8": "^3.2.4",
7
+ "eslint": "^9.39.0",
8
+ "eslint-config-prettier": "^10.1.8",
9
+ "prettier": "^3.7.4",
10
+ "typescript": "^5.9.3",
11
+ "typescript-eslint": "^8.47.0",
12
+ "vite": "^7.3.1",
13
+ "vitest": "^3.2.4"
14
+ },
15
+ "engines": {
16
+ "node": ">=24"
17
+ },
13
18
  "exports": {
14
19
  ".": {
15
20
  "import": {
@@ -25,44 +30,39 @@
25
30
  "files": [
26
31
  "dist"
27
32
  ],
33
+ "keywords": [
34
+ "api",
35
+ "clarify",
36
+ "client",
37
+ "crm",
38
+ "sdk"
39
+ ],
40
+ "license": "MIT",
41
+ "main": "./dist/cjs/index.js",
42
+ "module": "./dist/esm/index.js",
43
+ "private": false,
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
47
+ },
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/clarify/clarify.git",
51
+ "directory": "packages/sdk/js"
52
+ },
28
53
  "scripts": {
29
54
  "build": "npm run build:esm && npm run build:cjs && npm run build:types",
30
- "build:esm": "tsc -p tsconfig.build.json --module NodeNext --moduleResolution NodeNext --outDir dist/esm",
31
55
  "build:cjs": "tsc -p tsconfig.build.json --module CommonJS --moduleResolution Node --outDir dist/cjs",
56
+ "build:esm": "tsc -p tsconfig.build.json --module NodeNext --moduleResolution NodeNext --outDir dist/esm",
32
57
  "build:types": "tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --outDir dist/types",
33
58
  "clean": "rm -rf dist",
34
59
  "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\"",
35
60
  "lint:fix": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --fix",
36
61
  "test": "vitest run",
37
- "test:watch": "vitest --watch",
38
62
  "test:cov": "vitest run --coverage",
63
+ "test:watch": "vitest --watch",
39
64
  "tsc": "tsc --noEmit",
40
65
  "tsc:watch": "tsc --noEmit --watch"
41
66
  },
42
- "devDependencies": {
43
- "@vitest/coverage-v8": "^3.1.2",
44
- "eslint": "^8.57.0",
45
- "eslint-config-prettier": "^10.1.8",
46
- "prettier": "^3.7.4",
47
- "typescript": "^5.9.3",
48
- "typescript-eslint": "^8.47.0",
49
- "vite": "^7.3.1",
50
- "vitest": "^3.0.8"
51
- },
52
- "engines": {
53
- "node": ">=18.0.0"
54
- },
55
- "keywords": [
56
- "clarify",
57
- "crm",
58
- "sdk",
59
- "api",
60
- "client"
61
- ],
62
- "license": "MIT",
63
- "repository": {
64
- "type": "git",
65
- "url": "https://github.com/clarify/clarify.git",
66
- "directory": "packages/sdk/js"
67
- }
67
+ "types": "./dist/types/index.d.ts"
68
68
  }
@@ -1,105 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/resources/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAEV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,cAAc,EACd,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;gBACpC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc;IAI1D;;;;;;;;;;;;;OAaG;IACG,IAAI,CAAC,CAAC,SAAS,iBAAiB,GAAG,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