@attrove/sdk 0.1.19 → 0.2.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.
- package/README.md +8 -0
- package/cjs/client.js +4 -0
- package/cjs/constants.js +1 -1
- package/cjs/resources/index.js +5 -1
- package/cjs/resources/notes.js +106 -0
- package/cjs/resources/push.js +315 -0
- package/cjs/resources/query.js +39 -2
- package/cjs/resources/webhooks.js +1 -0
- package/cjs/types/index.js +23 -3
- package/cjs/utils/index.js +3 -1
- package/cjs/utils/streaming.js +8 -0
- package/cjs/utils/validate-ref-pair.js +45 -0
- package/esm/client.d.ts +12 -0
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +4 -0
- package/esm/client.js.map +1 -1
- package/esm/constants.d.ts +1 -1
- package/esm/constants.d.ts.map +1 -1
- package/esm/constants.js +1 -1
- package/esm/constants.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/resources/index.d.ts +3 -0
- package/esm/resources/index.d.ts.map +1 -1
- package/esm/resources/index.js +2 -0
- package/esm/resources/index.js.map +1 -1
- package/esm/resources/notes.d.ts +80 -0
- package/esm/resources/notes.d.ts.map +1 -0
- package/esm/resources/notes.js +103 -0
- package/esm/resources/notes.js.map +1 -0
- package/esm/resources/push.d.ts +140 -0
- package/esm/resources/push.d.ts.map +1 -0
- package/esm/resources/push.js +312 -0
- package/esm/resources/push.js.map +1 -0
- package/esm/resources/query.d.ts.map +1 -1
- package/esm/resources/query.js +39 -2
- package/esm/resources/query.js.map +1 -1
- package/esm/resources/webhooks.d.ts +1 -1
- package/esm/resources/webhooks.d.ts.map +1 -1
- package/esm/resources/webhooks.js +1 -0
- package/esm/resources/webhooks.js.map +1 -1
- package/esm/types/index.d.ts +225 -7
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/index.js +22 -2
- package/esm/types/index.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.d.ts.map +1 -1
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/streaming.d.ts +4 -0
- package/esm/utils/streaming.d.ts.map +1 -1
- package/esm/utils/streaming.js +8 -0
- package/esm/utils/streaming.js.map +1 -1
- package/esm/utils/validate-ref-pair.d.ts +23 -0
- package/esm/utils/validate-ref-pair.d.ts.map +1 -0
- package/esm/utils/validate-ref-pair.js +42 -0
- package/esm/utils/validate-ref-pair.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ref_type / ref_id pairing validation used by NotesResource and PushResource.
|
|
3
|
+
* Ensures ref_type is a valid NoteRefType and that both fields are present or both absent.
|
|
4
|
+
*/
|
|
5
|
+
import { NoteRefType } from '../types/index.js';
|
|
6
|
+
/** Validated ref pair where both fields are present. */
|
|
7
|
+
export type ValidatedRefPairLinked = {
|
|
8
|
+
refType: NoteRefType;
|
|
9
|
+
refId: string;
|
|
10
|
+
};
|
|
11
|
+
/** Validated ref pair where both fields are absent. */
|
|
12
|
+
export type ValidatedRefPairEmpty = {
|
|
13
|
+
refType?: undefined;
|
|
14
|
+
refId?: undefined;
|
|
15
|
+
};
|
|
16
|
+
/** Result of validating a refType/refId pair — either both present or both absent. */
|
|
17
|
+
export type ValidatedRefPair = ValidatedRefPairLinked | ValidatedRefPairEmpty;
|
|
18
|
+
/**
|
|
19
|
+
* Validate refType against NOTE_REF_TYPES and enforce the refType/refId pairing constraint.
|
|
20
|
+
* Both must be provided or both omitted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateRefPair(refType: unknown, refId: unknown): ValidatedRefPair;
|
|
23
|
+
//# sourceMappingURL=validate-ref-pair.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-ref-pair.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/utils/validate-ref-pair.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAA8B,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE5E,wDAAwD;AACxD,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,sFAAsF;AACtF,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG,qBAAqB,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,GACb,gBAAgB,CAqDlB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared ref_type / ref_id pairing validation used by NotesResource and PushResource.
|
|
3
|
+
* Ensures ref_type is a valid NoteRefType and that both fields are present or both absent.
|
|
4
|
+
*/
|
|
5
|
+
import { ValidationError } from '../errors/index.js';
|
|
6
|
+
import { NOTE_REF_TYPES, ErrorCodes } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Validate refType against NOTE_REF_TYPES and enforce the refType/refId pairing constraint.
|
|
9
|
+
* Both must be provided or both omitted.
|
|
10
|
+
*/
|
|
11
|
+
export function validateRefPair(refType, refId) {
|
|
12
|
+
if (refType != null) {
|
|
13
|
+
if (typeof refType !== 'string') {
|
|
14
|
+
throw new ValidationError(`refType must be a string, received ${typeof refType}`, ErrorCodes.VALIDATION_INVALID_FORMAT, { field: 'refType', received: typeof refType });
|
|
15
|
+
}
|
|
16
|
+
const valid = NOTE_REF_TYPES;
|
|
17
|
+
if (!valid.includes(refType)) {
|
|
18
|
+
throw new ValidationError(`refType must be one of: ${valid.join(', ')}`, ErrorCodes.VALIDATION_INVALID_FORMAT, { field: 'refType', received: refType });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (refId != null) {
|
|
22
|
+
if (typeof refId !== 'string') {
|
|
23
|
+
throw new ValidationError(`refId must be a string, received ${typeof refId}`, ErrorCodes.VALIDATION_INVALID_FORMAT, { field: 'refId', received: typeof refId });
|
|
24
|
+
}
|
|
25
|
+
if (refId.trim() === '') {
|
|
26
|
+
throw new ValidationError('refId must be a non-empty string', ErrorCodes.VALIDATION_INVALID_FORMAT, { field: 'refId' });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const hasRefType = refType != null;
|
|
30
|
+
const hasRefId = refId != null;
|
|
31
|
+
if (hasRefType !== hasRefId) {
|
|
32
|
+
throw new ValidationError('refType and refId must both be provided or both omitted', ErrorCodes.VALIDATION_INVALID_FORMAT, { field: hasRefType ? 'refId' : 'refType' });
|
|
33
|
+
}
|
|
34
|
+
if (hasRefType) {
|
|
35
|
+
return {
|
|
36
|
+
refType: refType,
|
|
37
|
+
refId: refId,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=validate-ref-pair.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-ref-pair.js","sourceRoot":"","sources":["../../../../../packages/sdk/src/utils/validate-ref-pair.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAe,MAAM,mBAAmB,CAAC;AAiB5E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,KAAc;IAEd,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,eAAe,CACvB,sCAAsC,OAAO,OAAO,EAAE,EACtD,UAAU,CAAC,yBAAyB,EACpC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,E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AAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attrove/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Official TypeScript SDK for the Attrove API - AI-powered context retrieval for your apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"url": "https://github.com/attrove/attrove-js.git",
|
|
57
57
|
"directory": "packages/sdk"
|
|
58
58
|
},
|
|
59
|
-
"homepage": "https://
|
|
59
|
+
"homepage": "https://attrove.com/docs/sdk",
|
|
60
60
|
"bugs": {
|
|
61
61
|
"url": "https://github.com/attrove/attrove-js/issues"
|
|
62
62
|
},
|