@papr/memory 1.20.0 → 2.0.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.
Files changed (128) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +1 -1
  3. package/README.md +13 -1
  4. package/client.d.mts +37 -9
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +37 -9
  7. package/client.d.ts.map +1 -1
  8. package/client.js +17 -2
  9. package/client.js.map +1 -1
  10. package/client.mjs +17 -2
  11. package/client.mjs.map +1 -1
  12. package/internal/parse.d.mts.map +1 -1
  13. package/internal/parse.d.ts.map +1 -1
  14. package/internal/parse.js +5 -0
  15. package/internal/parse.js.map +1 -1
  16. package/internal/parse.mjs +5 -0
  17. package/internal/parse.mjs.map +1 -1
  18. package/internal/tslib.js +22 -22
  19. package/package.json +1 -1
  20. package/resources/document.d.mts +16 -3
  21. package/resources/document.d.mts.map +1 -1
  22. package/resources/document.d.ts +16 -3
  23. package/resources/document.d.ts.map +1 -1
  24. package/resources/index.d.mts +6 -3
  25. package/resources/index.d.mts.map +1 -1
  26. package/resources/index.d.ts +6 -3
  27. package/resources/index.d.ts.map +1 -1
  28. package/resources/index.js +7 -1
  29. package/resources/index.js.map +1 -1
  30. package/resources/index.mjs +3 -0
  31. package/resources/index.mjs.map +1 -1
  32. package/resources/memory.d.mts +498 -119
  33. package/resources/memory.d.mts.map +1 -1
  34. package/resources/memory.d.ts +498 -119
  35. package/resources/memory.d.ts.map +1 -1
  36. package/resources/memory.js +8 -4
  37. package/resources/memory.js.map +1 -1
  38. package/resources/memory.mjs +8 -4
  39. package/resources/memory.mjs.map +1 -1
  40. package/resources/messages/index.d.mts +3 -0
  41. package/resources/messages/index.d.mts.map +1 -0
  42. package/resources/messages/index.d.ts +3 -0
  43. package/resources/messages/index.d.ts.map +1 -0
  44. package/resources/messages/index.js +9 -0
  45. package/resources/messages/index.js.map +1 -0
  46. package/resources/messages/index.mjs +4 -0
  47. package/resources/messages/index.mjs.map +1 -0
  48. package/resources/messages/messages.d.mts +160 -0
  49. package/resources/messages/messages.d.mts.map +1 -0
  50. package/resources/messages/messages.d.ts +160 -0
  51. package/resources/messages/messages.d.ts.map +1 -0
  52. package/resources/messages/messages.js +54 -0
  53. package/resources/messages/messages.js.map +1 -0
  54. package/resources/messages/messages.mjs +49 -0
  55. package/resources/messages/messages.mjs.map +1 -0
  56. package/resources/messages/sessions.d.mts +262 -0
  57. package/resources/messages/sessions.d.mts.map +1 -0
  58. package/resources/messages/sessions.d.ts +262 -0
  59. package/resources/messages/sessions.d.ts.map +1 -0
  60. package/resources/messages/sessions.js +122 -0
  61. package/resources/messages/sessions.js.map +1 -0
  62. package/resources/messages/sessions.mjs +118 -0
  63. package/resources/messages/sessions.mjs.map +1 -0
  64. package/resources/messages.d.mts +2 -0
  65. package/resources/messages.d.mts.map +1 -0
  66. package/resources/messages.d.ts +2 -0
  67. package/resources/messages.d.ts.map +1 -0
  68. package/resources/messages.js +6 -0
  69. package/resources/messages.js.map +1 -0
  70. package/resources/messages.mjs +3 -0
  71. package/resources/messages.mjs.map +1 -0
  72. package/resources/omo.d.mts +98 -0
  73. package/resources/omo.d.mts.map +1 -0
  74. package/resources/omo.d.ts +98 -0
  75. package/resources/omo.d.ts.map +1 -0
  76. package/resources/omo.js +36 -0
  77. package/resources/omo.js.map +1 -0
  78. package/resources/omo.mjs +32 -0
  79. package/resources/omo.mjs.map +1 -0
  80. package/resources/schemas.d.mts +667 -76
  81. package/resources/schemas.d.mts.map +1 -1
  82. package/resources/schemas.d.ts +667 -76
  83. package/resources/schemas.d.ts.map +1 -1
  84. package/resources/schemas.js.map +1 -1
  85. package/resources/schemas.mjs.map +1 -1
  86. package/resources/shared.d.mts +671 -0
  87. package/resources/shared.d.mts.map +1 -1
  88. package/resources/shared.d.ts +671 -0
  89. package/resources/shared.d.ts.map +1 -1
  90. package/resources/sync.d.mts +142 -0
  91. package/resources/sync.d.mts.map +1 -0
  92. package/resources/sync.d.ts +142 -0
  93. package/resources/sync.d.ts.map +1 -0
  94. package/resources/sync.js +36 -0
  95. package/resources/sync.js.map +1 -0
  96. package/resources/sync.mjs +32 -0
  97. package/resources/sync.mjs.map +1 -0
  98. package/resources/user.d.mts +18 -1
  99. package/resources/user.d.mts.map +1 -1
  100. package/resources/user.d.ts +18 -1
  101. package/resources/user.d.ts.map +1 -1
  102. package/resources/user.js +11 -0
  103. package/resources/user.js.map +1 -1
  104. package/resources/user.mjs +11 -0
  105. package/resources/user.mjs.map +1 -1
  106. package/src/client.ts +80 -8
  107. package/src/internal/parse.ts +6 -0
  108. package/src/resources/document.ts +17 -4
  109. package/src/resources/index.ts +21 -0
  110. package/src/resources/memory.ts +548 -163
  111. package/src/resources/messages/index.ts +11 -0
  112. package/src/resources/messages/messages.ts +193 -0
  113. package/src/resources/messages/sessions.ts +315 -0
  114. package/src/resources/messages.ts +3 -0
  115. package/src/resources/omo.ts +132 -0
  116. package/src/resources/schemas.ts +701 -95
  117. package/src/resources/shared.ts +752 -0
  118. package/src/resources/sync.ts +179 -0
  119. package/src/resources/user.ts +23 -0
  120. package/src/version.ts +1 -1
  121. package/version.d.mts +1 -1
  122. package/version.d.mts.map +1 -1
  123. package/version.d.ts +1 -1
  124. package/version.d.ts.map +1 -1
  125. package/version.js +1 -1
  126. package/version.js.map +1 -1
  127. package/version.mjs +1 -1
  128. package/version.mjs.map +1 -1
package/src/client.ts CHANGED
@@ -49,6 +49,7 @@ import {
49
49
  MemoryDeleteAllParams,
50
50
  MemoryDeleteParams,
51
51
  MemoryDeleteResponse,
52
+ MemoryGetParams,
52
53
  MemoryMetadata,
53
54
  MemorySearchParams,
54
55
  MemoryType,
@@ -58,6 +59,16 @@ import {
58
59
  SearchResponse,
59
60
  } from './resources/memory';
60
61
  import {
62
+ Omo,
63
+ OmoExportMemoriesAsJsonParams,
64
+ OmoExportMemoriesAsJsonResponse,
65
+ OmoExportMemoriesParams,
66
+ OmoExportMemoriesResponse,
67
+ OmoImportMemoriesParams,
68
+ OmoImportMemoriesResponse,
69
+ } from './resources/omo';
70
+ import {
71
+ PropertyDefinition,
61
72
  SchemaCreateParams,
62
73
  SchemaCreateResponse,
63
74
  SchemaDeleteResponse,
@@ -67,8 +78,16 @@ import {
67
78
  SchemaUpdateParams,
68
79
  SchemaUpdateResponse,
69
80
  Schemas,
81
+ SearchConfigOutput,
70
82
  UserGraphSchemaOutput,
71
83
  } from './resources/schemas';
84
+ import {
85
+ Sync,
86
+ SyncGetDeltaParams,
87
+ SyncGetDeltaResponse,
88
+ SyncGetTiersParams,
89
+ SyncGetTiersResponse,
90
+ } from './resources/sync';
72
91
  import {
73
92
  User,
74
93
  UserCreateBatchParams,
@@ -80,7 +99,9 @@ import {
80
99
  UserListResponse,
81
100
  UserResponse,
82
101
  UserType,
102
+ UserUpdateParams,
83
103
  } from './resources/user';
104
+ import { MessageStoreParams, MessageStoreResponse, Messages } from './resources/messages/messages';
84
105
  import { type Fetch } from './internal/builtin-types';
85
106
  import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
86
107
  import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -597,9 +618,10 @@ export class Papr {
597
618
  controller: AbortController,
598
619
  ): Promise<Response> {
599
620
  const { signal, method, ...options } = init || {};
600
- if (signal) signal.addEventListener('abort', () => controller.abort());
621
+ const abort = this._makeAbort(controller);
622
+ if (signal) signal.addEventListener('abort', abort, { once: true });
601
623
 
602
- const timeout = setTimeout(() => controller.abort(), ms);
624
+ const timeout = setTimeout(abort, ms);
603
625
 
604
626
  const isReadableBody =
605
627
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -766,6 +788,12 @@ export class Papr {
766
788
  return headers.values;
767
789
  }
768
790
 
791
+ private _makeAbort(controller: AbortController) {
792
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
793
+ // would capture all request options, and cause a memory leak.
794
+ return () => controller.abort();
795
+ }
796
+
769
797
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
770
798
  bodyHeaders: HeadersLike;
771
799
  body: BodyInit | undefined;
@@ -822,12 +850,25 @@ export class Papr {
822
850
 
823
851
  static toFile = Uploads.toFile;
824
852
 
853
+ static User: typeof User;
854
+ static Memory: typeof Memory;
855
+ static Feedback: typeof Feedback;
856
+ static Document: typeof Document;
857
+ static Schemas: typeof Schemas;
858
+ static Graphql: typeof Graphql;
859
+ static Messages: typeof Messages;
860
+ static Omo: typeof Omo;
861
+ static Sync: typeof Sync;
862
+
825
863
  user: API.User = new API.User(this);
826
864
  memory: API.Memory = new API.Memory(this);
827
865
  feedback: API.Feedback = new API.Feedback(this);
828
866
  document: API.Document = new API.Document(this);
829
867
  schemas: API.Schemas = new API.Schemas(this);
830
868
  graphql: API.Graphql = new API.Graphql(this);
869
+ messages: API.Messages = new API.Messages(this);
870
+ omo: API.Omo = new API.Omo(this);
871
+ sync: API.Sync = new API.Sync(this);
831
872
  }
832
873
 
833
874
  Papr.User = User;
@@ -836,25 +877,27 @@ Papr.Feedback = Feedback;
836
877
  Papr.Document = Document;
837
878
  Papr.Schemas = Schemas;
838
879
  Papr.Graphql = Graphql;
880
+ Papr.Messages = Messages;
881
+ Papr.Omo = Omo;
882
+ Papr.Sync = Sync;
839
883
 
840
884
  export declare namespace Papr {
841
885
  export type RequestOptions = Opts.RequestOptions;
842
886
 
843
887
  export {
844
- User as User,
845
888
  type UserResponse as UserResponse,
846
889
  type UserType as UserType,
847
890
  type UserListResponse as UserListResponse,
848
891
  type UserDeleteResponse as UserDeleteResponse,
849
892
  type UserCreateBatchResponse as UserCreateBatchResponse,
850
893
  type UserCreateParams as UserCreateParams,
894
+ type UserUpdateParams as UserUpdateParams,
851
895
  type UserListParams as UserListParams,
852
896
  type UserDeleteParams as UserDeleteParams,
853
897
  type UserCreateBatchParams as UserCreateBatchParams,
854
898
  };
855
899
 
856
900
  export {
857
- Memory as Memory,
858
901
  type AddMemory as AddMemory,
859
902
  type AddMemoryResponse as AddMemoryResponse,
860
903
  type AutoGraphGeneration as AutoGraphGeneration,
@@ -874,11 +917,11 @@ export declare namespace Papr {
874
917
  type MemoryAddParams as MemoryAddParams,
875
918
  type MemoryAddBatchParams as MemoryAddBatchParams,
876
919
  type MemoryDeleteAllParams as MemoryDeleteAllParams,
920
+ type MemoryGetParams as MemoryGetParams,
877
921
  type MemorySearchParams as MemorySearchParams,
878
922
  };
879
923
 
880
924
  export {
881
- Feedback as Feedback,
882
925
  type BatchRequest as BatchRequest,
883
926
  type BatchResponse as BatchResponse,
884
927
  type FeedbackRequest as FeedbackRequest,
@@ -889,7 +932,6 @@ export declare namespace Papr {
889
932
  };
890
933
 
891
934
  export {
892
- Document as Document,
893
935
  type DocumentCancelProcessingResponse as DocumentCancelProcessingResponse,
894
936
  type DocumentGetStatusResponse as DocumentGetStatusResponse,
895
937
  type DocumentUploadResponse as DocumentUploadResponse,
@@ -897,7 +939,8 @@ export declare namespace Papr {
897
939
  };
898
940
 
899
941
  export {
900
- Schemas as Schemas,
942
+ type PropertyDefinition as PropertyDefinition,
943
+ type SearchConfigOutput as SearchConfigOutput,
901
944
  type UserGraphSchemaOutput as UserGraphSchemaOutput,
902
945
  type SchemaCreateResponse as SchemaCreateResponse,
903
946
  type SchemaRetrieveResponse as SchemaRetrieveResponse,
@@ -910,10 +953,39 @@ export declare namespace Papr {
910
953
  };
911
954
 
912
955
  export {
913
- Graphql as Graphql,
914
956
  type GraphqlPlaygroundResponse as GraphqlPlaygroundResponse,
915
957
  type GraphqlQueryResponse as GraphqlQueryResponse,
916
958
  };
917
959
 
960
+ export {
961
+ type MessageStoreResponse as MessageStoreResponse,
962
+ type MessageStoreParams as MessageStoreParams,
963
+ };
964
+
965
+ export {
966
+ type OmoExportMemoriesResponse as OmoExportMemoriesResponse,
967
+ type OmoExportMemoriesAsJsonResponse as OmoExportMemoriesAsJsonResponse,
968
+ type OmoImportMemoriesResponse as OmoImportMemoriesResponse,
969
+ type OmoExportMemoriesParams as OmoExportMemoriesParams,
970
+ type OmoExportMemoriesAsJsonParams as OmoExportMemoriesAsJsonParams,
971
+ type OmoImportMemoriesParams as OmoImportMemoriesParams,
972
+ };
973
+
974
+ export {
975
+ type SyncGetDeltaResponse as SyncGetDeltaResponse,
976
+ type SyncGetTiersResponse as SyncGetTiersResponse,
977
+ type SyncGetDeltaParams as SyncGetDeltaParams,
978
+ type SyncGetTiersParams as SyncGetTiersParams,
979
+ };
980
+
981
+ export type ACLConfig = API.ACLConfig;
918
982
  export type AddMemoryItem = API.AddMemoryItem;
983
+ export type EdgeConstraintInput = API.EdgeConstraintInput;
984
+ export type Memory = API.Memory;
985
+ export type MemoryPolicy = API.MemoryPolicy;
986
+ export type NodeConstraintInput = API.NodeConstraintInput;
987
+ export type NodeSpec = API.NodeSpec;
988
+ export type PropertyValue = API.PropertyValue;
989
+ export type RelationshipSpec = API.RelationshipSpec;
990
+ export type SearchConfigInput = API.SearchConfigInput;
919
991
  }
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Papr, props: APIResponsePr
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -126,15 +126,26 @@ export namespace DocumentUploadResponse {
126
126
  export interface DocumentUploadParams {
127
127
  file: Uploadable;
128
128
 
129
- end_user_id?: string | null;
129
+ /**
130
+ * Your application's user identifier. This is the primary way to identify users.
131
+ * Also accepts legacy 'end_user_id'.
132
+ */
133
+ external_user_id?: string | null;
130
134
 
131
135
  graph_override?: string | null;
132
136
 
133
137
  hierarchical_enabled?: boolean;
134
138
 
139
+ /**
140
+ * JSON-encoded memory policy. Includes mode ('auto'/'manual'), schema_id,
141
+ * node_constraints (applied in auto mode when present), and OMO fields (consent,
142
+ * risk, acl). This is the recommended way to configure memory processing.
143
+ */
144
+ memory_policy?: string | null;
145
+
135
146
  metadata?: string | null;
136
147
 
137
- namespace?: string | null;
148
+ namespace_id?: string | null;
138
149
 
139
150
  /**
140
151
  * Preferred provider for document processing.
@@ -145,8 +156,10 @@ export interface DocumentUploadParams {
145
156
 
146
157
  schema_id?: string | null;
147
158
 
148
- simple_schema_mode?: boolean;
149
-
159
+ /**
160
+ * DEPRECATED: Internal Papr Parse user ID. Most developers should use
161
+ * external_user_id.
162
+ */
150
163
  user_id?: string | null;
151
164
 
152
165
  webhook_secret?: string | null;
@@ -40,10 +40,23 @@ export {
40
40
  type MemoryAddParams,
41
41
  type MemoryAddBatchParams,
42
42
  type MemoryDeleteAllParams,
43
+ type MemoryGetParams,
43
44
  type MemorySearchParams,
44
45
  } from './memory';
46
+ export { Messages, type MessageStoreResponse, type MessageStoreParams } from './messages/messages';
47
+ export {
48
+ Omo,
49
+ type OmoExportMemoriesResponse,
50
+ type OmoExportMemoriesAsJsonResponse,
51
+ type OmoImportMemoriesResponse,
52
+ type OmoExportMemoriesParams,
53
+ type OmoExportMemoriesAsJsonParams,
54
+ type OmoImportMemoriesParams,
55
+ } from './omo';
45
56
  export {
46
57
  Schemas,
58
+ type PropertyDefinition,
59
+ type SearchConfigOutput,
47
60
  type UserGraphSchemaOutput,
48
61
  type SchemaCreateResponse,
49
62
  type SchemaRetrieveResponse,
@@ -54,6 +67,13 @@ export {
54
67
  type SchemaUpdateParams,
55
68
  type SchemaListParams,
56
69
  } from './schemas';
70
+ export {
71
+ Sync,
72
+ type SyncGetDeltaResponse,
73
+ type SyncGetTiersResponse,
74
+ type SyncGetDeltaParams,
75
+ type SyncGetTiersParams,
76
+ } from './sync';
57
77
  export {
58
78
  User,
59
79
  type UserResponse,
@@ -62,6 +82,7 @@ export {
62
82
  type UserDeleteResponse,
63
83
  type UserCreateBatchResponse,
64
84
  type UserCreateParams,
85
+ type UserUpdateParams,
65
86
  type UserListParams,
66
87
  type UserDeleteParams,
67
88
  type UserCreateBatchParams,