@getclarify/nodejs-sdk 0.0.3 → 0.0.5

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 (52) hide show
  1. package/README.md +24 -24
  2. package/dist/cjs/client.d.ts +6 -0
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +7 -0
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/index.d.ts +1 -0
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +3 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/json-api/link.d.ts +40 -0
  11. package/dist/cjs/json-api/link.d.ts.map +1 -0
  12. package/dist/cjs/json-api/link.js +68 -0
  13. package/dist/cjs/json-api/link.js.map +1 -0
  14. package/dist/cjs/resources/resources.d.ts +208 -0
  15. package/dist/cjs/resources/resources.d.ts.map +1 -0
  16. package/dist/cjs/resources/resources.js +172 -0
  17. package/dist/cjs/resources/resources.js.map +1 -0
  18. package/dist/cjs/types/config.d.ts +2 -2
  19. package/dist/cjs/types/config.d.ts.map +1 -1
  20. package/dist/cjs/types/config.js +1 -1
  21. package/dist/cjs/types/config.js.map +1 -1
  22. package/dist/esm/client.d.ts +6 -0
  23. package/dist/esm/client.d.ts.map +1 -1
  24. package/dist/esm/client.js +7 -0
  25. package/dist/esm/client.js.map +1 -1
  26. package/dist/esm/index.d.ts +1 -0
  27. package/dist/esm/index.d.ts.map +1 -1
  28. package/dist/esm/index.js +3 -1
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/json-api/link.d.ts +40 -0
  31. package/dist/esm/json-api/link.d.ts.map +1 -0
  32. package/dist/esm/json-api/link.js +68 -0
  33. package/dist/esm/json-api/link.js.map +1 -0
  34. package/dist/esm/resources/resources.d.ts +208 -0
  35. package/dist/esm/resources/resources.d.ts.map +1 -0
  36. package/dist/esm/resources/resources.js +172 -0
  37. package/dist/esm/resources/resources.js.map +1 -0
  38. package/dist/esm/types/config.d.ts +2 -2
  39. package/dist/esm/types/config.d.ts.map +1 -1
  40. package/dist/esm/types/config.js +1 -1
  41. package/dist/esm/types/config.js.map +1 -1
  42. package/dist/types/client.d.ts +6 -0
  43. package/dist/types/client.d.ts.map +1 -1
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/index.d.ts.map +1 -1
  46. package/dist/types/json-api/link.d.ts +40 -0
  47. package/dist/types/json-api/link.d.ts.map +1 -0
  48. package/dist/types/resources/resources.d.ts +208 -0
  49. package/dist/types/resources/resources.d.ts.map +1 -0
  50. package/dist/types/types/config.d.ts +2 -2
  51. package/dist/types/types/config.d.ts.map +1 -1
  52. package/package.json +34 -38
package/README.md CHANGED
@@ -5,14 +5,14 @@ JavaScript/TypeScript SDK for the Clarify platform.
5
5
  ## Prerequisites
6
6
 
7
7
  - Node.js >= 18.0.0
8
- - npm
8
+ - pnpm
9
9
 
10
10
  ## Development
11
11
 
12
12
  ### Install dependencies
13
13
 
14
14
  ```bash
15
- npm install
15
+ pnpm install
16
16
  ```
17
17
 
18
18
  ### Build
@@ -20,43 +20,43 @@ npm install
20
20
  Build ESM, CJS, and type definitions:
21
21
 
22
22
  ```bash
23
- npm run build
23
+ pnpm run build
24
24
  ```
25
25
 
26
26
  Individual build targets:
27
27
 
28
28
  ```bash
29
- npm run build:esm # ES modules
30
- npm run build:cjs # CommonJS
31
- npm run build:types # TypeScript declarations
29
+ pnpm run build:esm # ES modules
30
+ pnpm run build:cjs # CommonJS
31
+ pnpm run build:types # TypeScript declarations
32
32
  ```
33
33
 
34
34
  Clean build artifacts:
35
35
 
36
36
  ```bash
37
- npm run clean
37
+ pnpm run clean
38
38
  ```
39
39
 
40
40
  ### Lint
41
41
 
42
42
  ```bash
43
- npm run lint # Check for issues
44
- npm run lint:fix # Auto-fix issues
43
+ pnpm run lint # Check for issues
44
+ pnpm run lint:fix # Auto-fix issues
45
45
  ```
46
46
 
47
47
  ### Test
48
48
 
49
49
  ```bash
50
- npm run test # Run tests once
51
- npm run test:watch # Watch mode
52
- npm run test:cov # With coverage
50
+ pnpm run test # Run tests once
51
+ pnpm run test:watch # Watch mode
52
+ pnpm run test:cov # With coverage
53
53
  ```
54
54
 
55
55
  ### Type check
56
56
 
57
57
  ```bash
58
- npm run tsc # One-time check
59
- npm run tsc:watch # Watch mode
58
+ pnpm run tsc # One-time check
59
+ pnpm run tsc:watch # Watch mode
60
60
  ```
61
61
 
62
62
  ## Publishing
@@ -64,29 +64,29 @@ npm run tsc:watch # Watch mode
64
64
  ### 1. Ensure tests pass and code is clean
65
65
 
66
66
  ```bash
67
- npm run lint
68
- npm run test
69
- npm run build
67
+ pnpm run lint
68
+ pnpm run test
69
+ pnpm run build
70
70
  ```
71
71
 
72
72
  ### 2. Update version
73
73
 
74
74
  ```bash
75
- npm version patch # 0.0.1 -> 0.0.2
76
- npm version minor # 0.0.1 -> 0.1.0
77
- npm version major # 0.0.1 -> 1.0.0
75
+ pnpm version patch # 0.0.1 -> 0.0.2
76
+ pnpm version minor # 0.0.1 -> 0.1.0
77
+ pnpm version major # 0.0.1 -> 1.0.0
78
78
  ```
79
79
 
80
80
  ### 3. Verify package contents
81
81
 
82
82
  ```bash
83
- npm publish --dry-run
83
+ pnpm publish --dry-run
84
84
  ```
85
85
 
86
86
  ### 4. Publish
87
87
 
88
88
  ```bash
89
- npm publish
89
+ pnpm publish
90
90
  ```
91
91
 
92
92
  ### Authentication
@@ -94,11 +94,11 @@ npm publish
94
94
  If not logged in:
95
95
 
96
96
  ```bash
97
- npm login
97
+ pnpm login
98
98
  ```
99
99
 
100
100
  Or set a token for CI:
101
101
 
102
102
  ```bash
103
- npm config set //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
103
+ pnpm config set //registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN
104
104
  ```
@@ -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.
@@ -26,6 +27,11 @@ import type { ClarifyClientConfig } from './types/index.js';
26
27
  export declare class ClarifyClient {
27
28
  /** Resource for managing records */
28
29
  readonly records: RecordsResource;
30
+ /**
31
+ * Resource for querying and creating resources via the `/resources` endpoints.
32
+ * Responses include a `relationships` map with fully resolved related records.
33
+ */
34
+ readonly resources: ResourcesResource;
29
35
  private readonly config;
30
36
  private readonly httpClient;
31
37
  /**
@@ -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;;;;;;;;;;;;;;;;;;;;;;GAsBG;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;;;OAGG;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"}
@@ -4,6 +4,7 @@ exports.ClarifyClient = void 0;
4
4
  const index_js_1 = require("./errors/index.js");
5
5
  const http_client_js_1 = require("./http/http-client.js");
6
6
  const records_js_1 = require("./resources/records.js");
7
+ const resources_js_1 = require("./resources/resources.js");
7
8
  const index_js_2 = require("./types/index.js");
8
9
  /**
9
10
  * The main client for interacting with the Clarify API.
@@ -31,6 +32,11 @@ const index_js_2 = require("./types/index.js");
31
32
  class ClarifyClient {
32
33
  /** Resource for managing records */
33
34
  records;
35
+ /**
36
+ * Resource for querying and creating resources via the `/resources` endpoints.
37
+ * Responses include a `relationships` map with fully resolved related records.
38
+ */
39
+ resources;
34
40
  config;
35
41
  httpClient;
36
42
  /**
@@ -43,6 +49,7 @@ class ClarifyClient {
43
49
  this.config = this.resolveConfig(config);
44
50
  this.httpClient = new http_client_js_1.HttpClient(this.config);
45
51
  this.records = new records_js_1.RecordsResource(this.httpClient, this.config);
52
+ this.resources = new resources_js_1.ResourcesResource(this.httpClient, this.config);
46
53
  }
47
54
  /**
48
55
  * Resolves configuration with defaults and validates required fields.
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,gDAA2D;AAC3D,0DAAmD;AACnD,uDAAyD;AAEzD,+CAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,aAAa;IACxB,oCAAoC;IAC3B,OAAO,CAAkB;IAEjB,MAAM,CAAiB;IACvB,UAAU,CAAa;IAExC;;;;;OAKG;IACH,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,IAAI,2BAAU,CAAC,IA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,EAAE,MAAM,CAAC,OAAO;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,yBAAc,CAAC,OAAO;YACjD,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,yBAAc,CAAC,OAAO;YACjD,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC;SACzD,CAAC;IACJ,CAAC;CACF;AA1DD,sCA0DC"}
@@ -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"}
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RecordsResource = exports.ClarifyNetworkError = exports.ClarifyTimeoutError = exports.ClarifyValidationError = exports.ClarifyApiError = exports.ClarifyError = exports.ClarifyClient = void 0;
3
+ exports.ResourcesResource = exports.RecordsResource = exports.ClarifyNetworkError = exports.ClarifyTimeoutError = exports.ClarifyValidationError = exports.ClarifyApiError = exports.ClarifyError = exports.ClarifyClient = void 0;
4
4
  // Main client export
5
5
  var client_js_1 = require("./client.js");
6
6
  Object.defineProperty(exports, "ClarifyClient", { enumerable: true, get: function () { return client_js_1.ClarifyClient; } });
@@ -14,4 +14,6 @@ Object.defineProperty(exports, "ClarifyNetworkError", { enumerable: true, get: f
14
14
  // Resource exports for advanced usage
15
15
  var records_js_1 = require("./resources/records.js");
16
16
  Object.defineProperty(exports, "RecordsResource", { enumerable: true, get: function () { return records_js_1.RecordsResource; } });
17
+ var resources_js_1 = require("./resources/resources.js");
18
+ Object.defineProperty(exports, "ResourcesResource", { enumerable: true, get: function () { return resources_js_1.ResourcesResource; } });
17
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AAEtB,gBAAgB;AAChB,8CAM2B;AALzB,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AAwBrB,sCAAsC;AACtC,qDAAyD;AAAhD,6GAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qBAAqB;AACrB,yCAA4C;AAAnC,0GAAA,aAAa,OAAA;AAEtB,gBAAgB;AAChB,8CAM2B;AALzB,wGAAA,YAAY,OAAA;AACZ,2GAAA,eAAe,OAAA;AACf,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AAwBrB,sCAAsC;AACtC,qDAAyD;AAAhD,6GAAA,eAAe,OAAA;AACxB,yDAYkC;AAXhC,iHAAA,iBAAiB,OAAA"}
@@ -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,68 @@
1
+ "use strict";
2
+ // NOTE: This is a standalone adaptation of the shared implementation at
3
+ // packages/shared/src/json-api/link.ts. If you update the core linking logic
4
+ // here, apply the same change there (and vice versa).
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.linkJsonApi = linkJsonApi;
7
+ function makeKey(r) {
8
+ return `${r.type}:${r.id}`;
9
+ }
10
+ /**
11
+ * Resolves relationship references in a JSON:API document by replacing
12
+ * `{ type, id }` stubs with the full resource objects from `included`.
13
+ *
14
+ * The function operates on a deep clone of the document so the original
15
+ * is never mutated.
16
+ *
17
+ * @throws {Error} If a referenced resource is not present in `included`
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const linked = linkJsonApi(response);
22
+ * // linked.data.relationships.company.data now contains the full company object
23
+ * ```
24
+ */
25
+ function linkJsonApi(doc) {
26
+ const document = structuredClone(doc);
27
+ const resourceMap = new Map();
28
+ const items = Array.isArray(document.data)
29
+ ? document.data
30
+ : [document.data];
31
+ for (const r of items) {
32
+ resourceMap.set(makeKey(r), r);
33
+ }
34
+ if (document.included) {
35
+ for (const r of document.included) {
36
+ resourceMap.set(makeKey(r), r);
37
+ }
38
+ }
39
+ for (const r of resourceMap.values()) {
40
+ linkResource(r, resourceMap);
41
+ }
42
+ return document;
43
+ }
44
+ function linkResource(resource, resourceMap) {
45
+ if (!resource.relationships) {
46
+ return;
47
+ }
48
+ for (const rel of Object.values(resource.relationships)) {
49
+ if (!rel.data) {
50
+ continue;
51
+ }
52
+ if (Array.isArray(rel.data)) {
53
+ rel.data = rel.data.map((ref) => resolveRef(ref, resourceMap));
54
+ }
55
+ else {
56
+ rel.data = resolveRef(rel.data, resourceMap);
57
+ }
58
+ }
59
+ }
60
+ function resolveRef(ref, resourceMap) {
61
+ const key = makeKey(ref);
62
+ const resource = resourceMap.get(key);
63
+ if (!resource) {
64
+ throw new Error(`JSON:API payload is malformed: "${key}" was referenced in a relationship but not found in included`);
65
+ }
66
+ return resource;
67
+ }
68
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/json-api/link.ts"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,6EAA6E;AAC7E,sDAAsD;;AAkDtD,kCAuBC;AA1CD,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,WAAW,CAA4B,GAAM;IAC3D,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAM,CAAC;IAC3C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAC;IAExD,MAAM,KAAK,GAAkB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QACvD,CAAC,CAAE,QAAQ,CAAC,IAAsB;QAClC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAmB,CAAC,CAAC;IAEnC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAClC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;QACrC,YAAY,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CACnB,QAAqB,EACrB,WAA0C;IAE1C,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC5B,OAAO;IACT,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACd,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,IAAgB,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CACnD,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAC7B,CAAC;QACJ,CAAC;aAAM,CAAC;YACL,GAAG,CAAC,IAAgB,GAAG,UAAU,CAAC,GAAG,CAAC,IAAc,EAAE,WAAW,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CACjB,GAAW,EACX,WAA0C;IAE1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACzB,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEtC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,mCAAmC,GAAG,8DAA8D,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -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":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,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,CAAC;IACd,aAAa,EAAE,MAAM,CACnB,MAAM,EACN;QAAE,IAAI,EAAE,cAAc,GAAG,cAAc,EAAE,GAAG,IAAI,CAAA;KAAE,CACnD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,IAAI,CAAC,EAAE,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