@palantir/pack.state.core 0.1.0 → 0.1.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/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-transpileBrowser.log +1 -1
- package/.turbo/turbo-transpileCjs.log +1 -1
- package/.turbo/turbo-transpileEsm.log +1 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +11 -0
- package/build/browser/index.js +25 -0
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +25 -0
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +93 -0
- package/build/esm/index.js +25 -0
- package/build/esm/index.js.map +1 -1
- package/build/types/service/BaseYjsDocumentService.d.ts +6 -0
- package/build/types/service/BaseYjsDocumentService.d.ts.map +1 -1
- package/build/types/types/DocumentRefImpl.d.ts +20 -0
- package/build/types/types/DocumentRefImpl.d.ts.map +1 -1
- package/build/types/types/DocumentService.d.ts +13 -0
- package/build/types/types/DocumentService.d.ts.map +1 -1
- package/build/types/types/RecordCollectionRefImpl.d.ts +23 -0
- package/build/types/types/RecordCollectionRefImpl.d.ts.map +1 -1
- package/build/types/types/RecordRefImpl.d.ts +25 -0
- package/build/types/types/RecordRefImpl.d.ts.map +1 -1
- package/build/types/types/StateModule.d.ts +12 -0
- package/build/types/types/StateModule.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/service/BaseYjsDocumentService.ts +8 -0
- package/src/service/InMemoryDocumentService.ts +30 -0
- package/src/types/DocumentRefImpl.ts +20 -0
- package/src/types/DocumentService.ts +16 -0
- package/src/types/RecordCollectionRefImpl.ts +23 -0
- package/src/types/RecordRefImpl.ts +25 -0
- package/src/types/StateModule.ts +20 -0
|
@@ -31,10 +31,23 @@ export type DocumentStateChangeCallback<T extends DocumentSchema = DocumentSchem
|
|
|
31
31
|
export type RecordCollectionChangeCallback<M extends Model = Model> = (items: readonly RecordRef<M>[]) => void;
|
|
32
32
|
export type RecordChangeCallback<M extends Model = Model> = (snapshot: ModelData<M>, record: RecordRef<M>) => void;
|
|
33
33
|
export type RecordDeleteCallback<M extends Model = Model> = (record: RecordRef<M>) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Base interface for specific document service implementations.
|
|
36
|
+
* The DocumentService is responsible for persisting document state,
|
|
37
|
+
* metadata, and providing methods to subscribe and interact with documents.
|
|
38
|
+
*
|
|
39
|
+
* The main implementation communicates with the Foundry platform (see @palantir/pack.state.foundry).
|
|
40
|
+
*/
|
|
34
41
|
export interface DocumentService {
|
|
35
42
|
readonly hasMetadataSubscriptions: boolean;
|
|
36
43
|
readonly hasStateSubscriptions: boolean;
|
|
37
44
|
readonly createDocument: <T extends DocumentSchema>(metadata: DocumentMetadata, schema: T) => Promise<DocumentRef<T>>;
|
|
45
|
+
readonly searchDocuments: <T extends DocumentSchema>(documentTypeName: string, schema: T, options?: {
|
|
46
|
+
documentName?: string;
|
|
47
|
+
limit?: number;
|
|
48
|
+
}) => Promise<ReadonlyArray<DocumentMetadata & {
|
|
49
|
+
readonly id: DocumentId;
|
|
50
|
+
}>>;
|
|
38
51
|
readonly createDocRef: <const T extends DocumentSchema>(id: DocumentId, schema: T) => DocumentRef<T>;
|
|
39
52
|
readonly getCreateRecordCollectionRef: <const M extends Model>(docRef: DocumentRef, model: M) => RecordCollectionRef<M>;
|
|
40
53
|
readonly getCreateRecordRef: <const M extends Model>(docRef: DocumentRef, id: RecordId, model: M) => RecordRef<M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,mBAAmB;AACjC,cACE,eACA,YACA,kBACA,aACA,gBACA,eACA,iBACA,OACA,WACA,eACA,6BACA,qBACA,UACA,iBACK;AAEP,OAAO,cAAM;UACX,UAAU;UACV,SAAS;UACT,QAAQ;UACR,OAAO;;AAET,YAAY,4BAA4B,gCAAgC;AAExE,OAAO,cAAM;UACX,cAAc;UACd,YA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B,OACtC;UAEI,aAAa,UAAU,gBAC9B,QAAQ,YAAY,IACpB,WAAW,QAAQ,YAAY,IAAI,OAAO,2BACvC;UAEI,mBAAmB,UAAU,gBACpC,QAAQ,YAAY,IACpB,UAAU,+BAA+B,OACtC;UAEI,aAAa,UAAU,gBAC9B,QAAQ,YAAY,IACpB,WAAW,QAAQ,YAAY,IAAI,OAAO,wBAC1C,UAAU,gCACP;UAEI,gBAAgB,UAAU,gBACjC,QAAQ,YAAY,IACpB,UAAU,4BAA4B,OACnC;UAEI,uBAAuB,UAAU,OACxC,QAAQ,aACR,OAAO,GACP,WAAW,UAAU;UAGd,kBAAkB,UAAU,OACnC,QAAQ,UAAU,IAClB,UAAU,qBAAqB,OAC5B;UAEI,kBAAkB,UAAU,OACnC,QAAQ,UAAU,IAClB,UAAU,qBAAqB,OAC5B;UAGI,oBAAoB,UAAU,gBACrC,QAAQ,YAAY,OACjB;UAEI,iBAAiB,UAAU,gBAClC,QAAQ,YAAY,IACpB,UAAU,iCACP;UAEI,sBAAsB,UAAU,gBACvC,QAAQ,YAAY,OACjB;UAEI,kBAAkB,UAAU,gBACnC,QAAQ,YAAY,OACjB","names":[],"sources":["../../../src/types/DocumentService.ts"],"version":3,"file":"DocumentService.d.ts"}
|
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
import type { DocumentRef, Model, RecordCollectionRef } from "@palantir/pack.document-schema.model-types";
|
|
2
2
|
import type { DocumentService } from "./DocumentService.js";
|
|
3
3
|
export declare const createRecordCollectionRef: <const M extends Model>(documentService: DocumentService, docRef: DocumentRef, model: M) => RecordCollectionRef<M>;
|
|
4
|
+
/**
|
|
5
|
+
* Get an invalid record collection reference. This is a stable reference that
|
|
6
|
+
* can be used to represent an invalid record collection.
|
|
7
|
+
*
|
|
8
|
+
* Not to be confused with a valid reference to a non-existent record
|
|
9
|
+
* collection, an invalid reference is one that is not properly initialized. For
|
|
10
|
+
* example, code that initializes with an undefined or empty model might produce
|
|
11
|
+
* an invalid record collection reference rather than propagate nullish types.
|
|
12
|
+
*
|
|
13
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
14
|
+
* recommended to check for validity using {@link isValidRecordCollectionRef}
|
|
15
|
+
* before performing operations.
|
|
16
|
+
*/
|
|
4
17
|
export declare function invalidRecordCollectionRef<M extends Model = Model>(): RecordCollectionRef<M>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a record collection reference is a valid reference.
|
|
20
|
+
*
|
|
21
|
+
* Not to be confused with a valid reference to a non-existent record
|
|
22
|
+
* collection, an invalid reference is one that is not properly initialized.
|
|
23
|
+
*
|
|
24
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
25
|
+
* recommended to check for validity using this function before performing
|
|
26
|
+
* operations.
|
|
27
|
+
*/
|
|
5
28
|
export declare function isValidRecordCollectionRef<M extends Model = Model>(collectionRef: RecordCollectionRef<M>): collectionRef is RecordCollectionRef<M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,aACA,OAEA,2BAIK;AAGP,cAAc,uBAAuB;AAqBrC,OAAO,cAAM,kCAAmC,UAAU,OACxD,iBAAiB,iBACjB,QAAQ,aACR,OAAO,MACN,oBAAoB
|
|
1
|
+
{"mappings":"AAgBA,cACE,aACA,OAEA,2BAIK;AAGP,cAAc,uBAAuB;AAqBrC,OAAO,cAAM,kCAAmC,UAAU,OACxD,iBAAiB,iBACjB,QAAQ,aACR,OAAO,MACN,oBAAoB;;;;;;;;;;;;;;AAiBvB,OAAO,iBAAS,2BAA2B,UAAU,QAAQ,UAAU,oBAAoB;;;;;;;;;;;AAc3F,OAAO,iBAAS,2BAA2B,UAAU,QAAQ,OAC3D,eAAe,oBAAoB,KAClC,iBAAiB,oBAAoB","names":[],"sources":["../../../src/types/RecordCollectionRefImpl.ts"],"version":3,"file":"RecordCollectionRefImpl.d.ts"}
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import type { DocumentRef, Model, RecordId, RecordRef } from "@palantir/pack.document-schema.model-types";
|
|
2
2
|
import type { DocumentService } from "./DocumentService.js";
|
|
3
3
|
export declare const createRecordRef: <const M extends Model>(documentService: DocumentService, docRef: DocumentRef, id: RecordId, model: M) => RecordRef<M>;
|
|
4
|
+
/**
|
|
5
|
+
* Get an invalid record reference. This is a stable reference that can be used
|
|
6
|
+
* to represent an invalid record.
|
|
7
|
+
*
|
|
8
|
+
* Not to be confused with a valid reference to a non-existent record, an
|
|
9
|
+
* invalid reference is one that is not properly initialized. For example, code
|
|
10
|
+
* that initializes with an undefined or empty recordId might produce an
|
|
11
|
+
* invalid record reference rather than propagate nullish types.
|
|
12
|
+
*
|
|
13
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
14
|
+
* recommended to check for validity using {@link isValidRecordRef} before
|
|
15
|
+
* performing operations.
|
|
16
|
+
*/
|
|
4
17
|
export declare function invalidRecordRef<M extends Model = Model>(): RecordRef<M>;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a record reference is a valid reference.
|
|
20
|
+
*
|
|
21
|
+
* Not to be confused with a valid reference to a non-existent record, an
|
|
22
|
+
* invalid reference is one that is not properly initialized.
|
|
23
|
+
*
|
|
24
|
+
* For example, code that initializes with an undefined or empty recordId might
|
|
25
|
+
* produce an invalid record reference rather than propagate nullish types, as
|
|
26
|
+
* most operations on an invalid reference are no-ops. For the rest, it is
|
|
27
|
+
* recommended to check for validity using this function before performing
|
|
28
|
+
* operations.
|
|
29
|
+
*/
|
|
5
30
|
export declare function isValidRecordRef<M extends Model = Model>(recordRef: RecordRef<M>): recordRef is RecordRef<M>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,aACA,OAEA,UACA,iBAEK;AAGP,cAAc,uBAAuB;AAgBrC,OAAO,cAAM,wBAAyB,UAAU,OAC9C,iBAAiB,iBACjB,QAAQ,aACR,IAAI,UACJ,OAAO,MACN,UAAU
|
|
1
|
+
{"mappings":"AAgBA,cACE,aACA,OAEA,UACA,iBAEK;AAGP,cAAc,uBAAuB;AAgBrC,OAAO,cAAM,wBAAyB,UAAU,OAC9C,iBAAiB,iBACjB,QAAQ,aACR,IAAI,UACJ,OAAO,MACN,UAAU;;;;;;;;;;;;;;AAiBb,OAAO,iBAAS,iBAAiB,UAAU,QAAQ,UAAU,UAAU;;;;;;;;;;;;;AAgBvE,OAAO,iBAAS,iBAAiB,UAAU,QAAQ,OACjD,WAAW,UAAU,KACpB,aAAa,UAAU","names":[],"sources":["../../../src/types/RecordRefImpl.ts"],"version":3,"file":"RecordRefImpl.d.ts"}
|
|
@@ -10,6 +10,12 @@ export interface StateModule {
|
|
|
10
10
|
readonly createDocRef: <const T extends DocumentSchema>(id: DocumentId, schema: T) => DocumentRef<T>;
|
|
11
11
|
readonly createRecordRef: <const M extends Model>(docRef: DocumentRef, id: RecordId, model: M) => RecordRef<M>;
|
|
12
12
|
readonly createDocument: <T extends DocumentSchema>(metadata: DocumentMetadata, schema: T) => Promise<DocumentRef<T>>;
|
|
13
|
+
readonly searchDocuments: <T extends DocumentSchema>(documentTypeName: string, schema: T, options?: {
|
|
14
|
+
documentName?: string;
|
|
15
|
+
limit?: number;
|
|
16
|
+
}) => Promise<ReadonlyArray<DocumentMetadata & {
|
|
17
|
+
readonly id: DocumentId;
|
|
18
|
+
}>>;
|
|
13
19
|
readonly getDocumentSnapshot: <T extends DocumentSchema>(docRef: DocumentRef<T>) => Promise<DocumentState<T>>;
|
|
14
20
|
readonly onActivity: <T extends DocumentSchema>(docRef: DocumentRef<T>, callback: (docRef: DocumentRef<T>, event: ActivityEvent) => void) => Unsubscribe;
|
|
15
21
|
readonly onMetadataChange: <T extends DocumentSchema>(docRef: DocumentRef<T>, cb: (docRef: DocumentRef<T>, metadata: DocumentMetadata) => void) => Unsubscribe;
|
|
@@ -37,6 +43,12 @@ export declare class StateModuleImpl implements StateModule {
|
|
|
37
43
|
createDocRef<const T extends DocumentSchema>(id: DocumentId, schema: T): DocumentRef<T>;
|
|
38
44
|
createRecordRef<const M extends Model>(docRef: DocumentRef, id: RecordId, model: M): RecordRef<M>;
|
|
39
45
|
createDocument<T extends DocumentSchema>(metadata: DocumentMetadata, schema: T): Promise<DocumentRef<T>>;
|
|
46
|
+
searchDocuments<T extends DocumentSchema>(documentTypeName: string, schema: T, options?: {
|
|
47
|
+
documentName?: string;
|
|
48
|
+
limit?: number;
|
|
49
|
+
}): Promise<ReadonlyArray<DocumentMetadata & {
|
|
50
|
+
readonly id: DocumentId;
|
|
51
|
+
}>>;
|
|
40
52
|
getDocumentSnapshot<T extends DocumentSchema>(docRef: DocumentRef<T>): Promise<DocumentState<T>>;
|
|
41
53
|
onActivity<T extends DocumentSchema>(docRef: DocumentRef<T>, callback: (docRef: DocumentRef<T>, event: ActivityEvent) => void): Unsubscribe;
|
|
42
54
|
onMetadataChange<T extends DocumentSchema>(docRef: DocumentRef<T>, cb: (doc: DocumentRef<T>, metadata: DocumentMetadata) => void): Unsubscribe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAEO,gBACA,sBACA,mBACA;AACP,cACE,eACA,YACA,kBACA,aACA,gBACA,eACA,iBACA,OACA,WACA,eACA,6BACA,qBACA,UACA,iBACK;AAEP,cACE,iBACA,sBACA,gCACA,4BACK;AAGP,OAAO,cAAM,wBAAwB;AACrC,OAAO,cAAMA,kBAAkB,UAAU;AAQzC,YAAY,gBAAgB,KAAK,IAAI;WAAY,wBAAwB;;AAEzE,iBAAiB,YAAY;UAClB,qBAAqB,UAAU,gBACtC,IAAI,YACJ,QAAQ,MACL,YAAY;UAER,wBAAwB,UAAU,OACzC,QAAQ,aACR,IAAI,UACJ,OAAO,MACJ,UAAU;UAEN,iBAAiB,UAAU,gBAClC,UAAU,kBACV,QAAQ,MACL,QAAQ,YAAY;UAEhB,sBAAsB,UAAU,gBACvC,QAAQ,YAAY,OACjB,QAAQ,cAAc;UAElB,aAAa,UAAU,gBAC9B,QAAQ,YAAY,IACpB,WAAW,QAAQ,YAAY,IAA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UAAU,OAC7B,YAAY,oBAAoB,KAC/B,UAAU;CAIb,gBAAgB,UAAU,OACxB,QAAQ,UAAU,IAClB,UAAU,qBAAqB,KAC9B;CAIH,gBAAgB,UAAU,OACxB,QAAQ,UAAU,IAClB,UAAU,qBAAqB,KAC9B;CAIH,uBAAuB,UAAU,OAC/B,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAIH,yBAAyB,UAAU,OACjC,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAIH,yBAAyB,UAAU,OACjC,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAKH,kBAAkB,UAAU,gBAC1B,QAAQ,YAAY,KACnB,WAAW,gBAAgB;CAI9B,eAAe,UAAU,gBACvB,QAAQ,YAAY,IACpB,UAAU,WAAW,gBAAgB,mBAAmB,KACvD;CAIH,AAAM,oBAAoB,UAAU,gBAClC,QAAQ,YAAY,KACnB;CAIH,AAAM,gBAAgB,UAAU,gBAC9B,QAAQ,YAAY,KACnB;CAIH,AAAM,aAAa,UAAU,OAC3B,QAAQ,UAAU,KACjB;;AAKL,OAAO,iBAAS,eAAe,KAAK,kBAAkB","names":["STATE_MODULE_KEY: ModuleKey<StateModuleImpl>","documentService: DocumentService"],"sources":["../../../src/types/StateModule.ts"],"version":3,"file":"StateModule.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,cAEO,gBACA,sBACA,mBACA;AACP,cACE,eACA,YACA,kBACA,aACA,gBACA,eACA,iBACA,OACA,WACA,eACA,6BACA,qBACA,UACA,iBACK;AAEP,cACE,iBACA,sBACA,gCACA,4BACK;AAGP,OAAO,cAAM,wBAAwB;AACrC,OAAO,cAAMA,kBAAkB,UAAU;AAQzC,YAAY,gBAAgB,KAAK,IAAI;WAAY,wBAAwB;;AAEzE,iBAAiB,YAAY;UAClB,qBAAqB,UAAU,gBACtC,IAAI,YACJ,QAAQ,MACL,YAAY;UAER,wBAAwB,UAAU,OACzC,QAAQ,aACR,IAAI,UACJ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B;CAIH,AAAM,aAAa,UAAU,OAC3B,WAAW,UAAU,IACrB,cAAc,QAAQ,UAAU,MAC/B;CAIH,gBACE,QAAQ,aACR,gBACA,cAAc;CAMhB,6BAA6B,UAAU,OACrC,QAAQ,aACR,OAAO,IACN,oBAAoB;CAKvB,UAAU,UAAU,OAClB,YAAY,oBAAoB,IAChC,IAAI,WACH,UAAU;CAIb,UAAU,UAAU,OAClB,YAAY,oBAAoB,IAChC,IAAI;CAKN,AAAM,oBAAoB,UAAU,OAClC,YAAY,oBAAoB,IAChC,IAAI,UACJ,OAAO,UAAU,KAChB;CAIH,kBAAkB,UAAU,OAC1B,YAAY,oBAAoB;CAKlC,qBAAqB,UAAU,OAC7B,YAAY,oBAAoB,KAC/B,UAAU;CAIb,gBAAgB,UAAU,OACxB,QAAQ,UAAU,IAClB,UAAU,qBAAqB,KAC9B;CAIH,gBAAgB,UAAU,OACxB,QAAQ,UAAU,IAClB,UAAU,qBAAqB,KAC9B;CAIH,uBAAuB,UAAU,OAC/B,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAIH,yBAAyB,UAAU,OACjC,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAIH,yBAAyB,UAAU,OACjC,YAAY,oBAAoB,IAChC,UAAU,+BAA+B,KACxC;CAKH,kBAAkB,UAAU,gBAC1B,QAAQ,YAAY,KACnB,WAAW,gBAAgB;CAI9B,eAAe,UAAU,gBACvB,QAAQ,YAAY,IACpB,UAAU,WAAW,gBAAgB,mBAAmB,KACvD;CAIH,AAAM,oBAAoB,UAAU,gBAClC,QAAQ,YAAY,KACnB;CAIH,AAAM,gBAAgB,UAAU,gBAC9B,QAAQ,YAAY,KACnB;CAIH,AAAM,aAAa,UAAU,OAC3B,QAAQ,UAAU,KACjB;;AAKL,OAAO,iBAAS,eAAe,KAAK,kBAAkB","names":["STATE_MODULE_KEY: ModuleKey<StateModuleImpl>","documentService: DocumentService"],"sources":["../../../src/types/StateModule.ts"],"version":3,"file":"StateModule.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palantir/pack.state.core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "PACK State logic and utilities",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"remeda": "^2.32.0",
|
|
33
33
|
"tiny-invariant": "^1.3.3",
|
|
34
34
|
"yjs": "^13.6.27",
|
|
35
|
-
"@palantir/pack.document-schema.model-types": "0.1.
|
|
36
|
-
"@palantir/pack.core": "0.1.
|
|
35
|
+
"@palantir/pack.document-schema.model-types": "0.1.1",
|
|
36
|
+
"@palantir/pack.core": "0.1.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"zod": "^4.1.0"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"tslib": "^2.8.1",
|
|
45
45
|
"typescript": "^5.9.2",
|
|
46
46
|
"vitest-mock-extended": "^3.1.0",
|
|
47
|
-
"@palantir/pack.monorepo.tsconfig": "~0.4.
|
|
47
|
+
"@palantir/pack.monorepo.tsconfig": "~0.4.3"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
@@ -127,6 +127,14 @@ export abstract class BaseYjsDocumentService<TDoc extends InternalYjsDoc = Inter
|
|
|
127
127
|
metadata: DocumentMetadata,
|
|
128
128
|
schema: T,
|
|
129
129
|
) => Promise<DocumentRef<T>>;
|
|
130
|
+
abstract readonly searchDocuments: <T extends DocumentSchema>(
|
|
131
|
+
documentTypeName: string,
|
|
132
|
+
schema: T,
|
|
133
|
+
options?: {
|
|
134
|
+
documentName?: string;
|
|
135
|
+
limit?: number;
|
|
136
|
+
},
|
|
137
|
+
) => Promise<ReadonlyArray<DocumentMetadata & { readonly id: DocumentId }>>;
|
|
130
138
|
|
|
131
139
|
readonly createDocRef = <const T extends DocumentSchema>(
|
|
132
140
|
id: DocumentId,
|
|
@@ -104,6 +104,36 @@ class InMemoryDocumentService extends BaseYjsDocumentService {
|
|
|
104
104
|
return Promise.resolve(docRef);
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
+
readonly searchDocuments = <T extends DocumentSchema>(
|
|
108
|
+
documentTypeName: string,
|
|
109
|
+
schema: T,
|
|
110
|
+
options?: {
|
|
111
|
+
documentName?: string;
|
|
112
|
+
limit?: number;
|
|
113
|
+
},
|
|
114
|
+
): Promise<ReadonlyArray<DocumentMetadata & { readonly id: DocumentId }>> => {
|
|
115
|
+
const results: Array<DocumentMetadata & { readonly id: DocumentId }> = [];
|
|
116
|
+
const { documentName, limit } = options ?? {};
|
|
117
|
+
|
|
118
|
+
for (const [docId, internalDoc] of this.documents.entries()) {
|
|
119
|
+
if (internalDoc.metadata?.documentTypeName === documentTypeName) {
|
|
120
|
+
if (documentName && !internalDoc.metadata.name.includes(documentName)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
results.push({
|
|
124
|
+
...internalDoc.metadata,
|
|
125
|
+
id: docId as DocumentId,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (limit && results.length >= limit) {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return Promise.resolve(results);
|
|
135
|
+
};
|
|
136
|
+
|
|
107
137
|
// Lifecycle method implementations
|
|
108
138
|
protected onMetadataSubscriptionOpened(
|
|
109
139
|
internalDoc: InternalYjsDoc,
|
|
@@ -63,10 +63,30 @@ export const createDocRef = <const D extends DocumentSchema>(
|
|
|
63
63
|
return new DocumentRefImpl(app, id, schema);
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Get an invalid document reference. This is a stable reference that can be
|
|
68
|
+
* used to represent a non-existent or invalid document.
|
|
69
|
+
*
|
|
70
|
+
* Not to be confused with a valid reference to a non-existent document, an
|
|
71
|
+
* invalid reference is one that is not properly initialized. For example, code
|
|
72
|
+
* that initializes with an undefined or empty documentId might produce an
|
|
73
|
+
* invalid document reference rather than propagate nullish types.
|
|
74
|
+
*
|
|
75
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
76
|
+
* recommended to check for validity using {@link isValidDocRef} before
|
|
77
|
+
* performing operations.
|
|
78
|
+
*/
|
|
66
79
|
export function invalidDocRef<D extends DocumentSchema = DocumentSchema>(): DocumentRef<D> {
|
|
67
80
|
return INVALID_DOC_REF as DocumentRef<D>;
|
|
68
81
|
}
|
|
69
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Check if a document reference is an invalid reference.
|
|
85
|
+
* Not to be confused with a valid reference to a non-existent document, an invalid reference is one that is not properly initialized.
|
|
86
|
+
* For example, code that initializes with an undefined or empty documentId might produce an invalid document reference rather than
|
|
87
|
+
* propagate nullish types, as most operations on an invalid reference are no-ops. For the rest, it is recommended to check for
|
|
88
|
+
* validity using this function before performing operations.
|
|
89
|
+
*/
|
|
70
90
|
export function isValidDocRef<D extends DocumentSchema = DocumentSchema>(
|
|
71
91
|
docRef: DocumentRef<D>,
|
|
72
92
|
): docRef is DocumentRef<D> {
|
|
@@ -87,6 +87,13 @@ export type RecordDeleteCallback<M extends Model = Model> = (
|
|
|
87
87
|
record: RecordRef<M>,
|
|
88
88
|
) => void;
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Base interface for specific document service implementations.
|
|
92
|
+
* The DocumentService is responsible for persisting document state,
|
|
93
|
+
* metadata, and providing methods to subscribe and interact with documents.
|
|
94
|
+
*
|
|
95
|
+
* The main implementation communicates with the Foundry platform (see @palantir/pack.state.foundry).
|
|
96
|
+
*/
|
|
90
97
|
export interface DocumentService {
|
|
91
98
|
readonly hasMetadataSubscriptions: boolean;
|
|
92
99
|
readonly hasStateSubscriptions: boolean;
|
|
@@ -96,6 +103,15 @@ export interface DocumentService {
|
|
|
96
103
|
schema: T,
|
|
97
104
|
) => Promise<DocumentRef<T>>;
|
|
98
105
|
|
|
106
|
+
readonly searchDocuments: <T extends DocumentSchema>(
|
|
107
|
+
documentTypeName: string,
|
|
108
|
+
schema: T,
|
|
109
|
+
options?: {
|
|
110
|
+
documentName?: string;
|
|
111
|
+
limit?: number;
|
|
112
|
+
},
|
|
113
|
+
) => Promise<ReadonlyArray<DocumentMetadata & { readonly id: DocumentId }>>;
|
|
114
|
+
|
|
99
115
|
readonly createDocRef: <const T extends DocumentSchema>(
|
|
100
116
|
id: DocumentId,
|
|
101
117
|
schema: T,
|
|
@@ -54,10 +54,33 @@ export const createRecordCollectionRef = <const M extends Model>(
|
|
|
54
54
|
return new RecordCollectionRefImpl(documentService, docRef, model);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Get an invalid record collection reference. This is a stable reference that
|
|
59
|
+
* can be used to represent an invalid record collection.
|
|
60
|
+
*
|
|
61
|
+
* Not to be confused with a valid reference to a non-existent record
|
|
62
|
+
* collection, an invalid reference is one that is not properly initialized. For
|
|
63
|
+
* example, code that initializes with an undefined or empty model might produce
|
|
64
|
+
* an invalid record collection reference rather than propagate nullish types.
|
|
65
|
+
*
|
|
66
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
67
|
+
* recommended to check for validity using {@link isValidRecordCollectionRef}
|
|
68
|
+
* before performing operations.
|
|
69
|
+
*/
|
|
57
70
|
export function invalidRecordCollectionRef<M extends Model = Model>(): RecordCollectionRef<M> {
|
|
58
71
|
return INVALID_RECORD_COLLECTION_REF as RecordCollectionRef<M>;
|
|
59
72
|
}
|
|
60
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Check if a record collection reference is a valid reference.
|
|
76
|
+
*
|
|
77
|
+
* Not to be confused with a valid reference to a non-existent record
|
|
78
|
+
* collection, an invalid reference is one that is not properly initialized.
|
|
79
|
+
*
|
|
80
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
81
|
+
* recommended to check for validity using this function before performing
|
|
82
|
+
* operations.
|
|
83
|
+
*/
|
|
61
84
|
export function isValidRecordCollectionRef<M extends Model = Model>(
|
|
62
85
|
collectionRef: RecordCollectionRef<M>,
|
|
63
86
|
): collectionRef is RecordCollectionRef<M> {
|
|
@@ -49,10 +49,35 @@ export const createRecordRef = <const M extends Model>(
|
|
|
49
49
|
return new RecordRefImpl(documentService, docRef, id, model);
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Get an invalid record reference. This is a stable reference that can be used
|
|
54
|
+
* to represent an invalid record.
|
|
55
|
+
*
|
|
56
|
+
* Not to be confused with a valid reference to a non-existent record, an
|
|
57
|
+
* invalid reference is one that is not properly initialized. For example, code
|
|
58
|
+
* that initializes with an undefined or empty recordId might produce an
|
|
59
|
+
* invalid record reference rather than propagate nullish types.
|
|
60
|
+
*
|
|
61
|
+
* Most operations on an invalid reference are no-ops. For the rest, it is
|
|
62
|
+
* recommended to check for validity using {@link isValidRecordRef} before
|
|
63
|
+
* performing operations.
|
|
64
|
+
*/
|
|
52
65
|
export function invalidRecordRef<M extends Model = Model>(): RecordRef<M> {
|
|
53
66
|
return INVALID_RECORD_REF as RecordRef<M>;
|
|
54
67
|
}
|
|
55
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Check if a record reference is a valid reference.
|
|
71
|
+
*
|
|
72
|
+
* Not to be confused with a valid reference to a non-existent record, an
|
|
73
|
+
* invalid reference is one that is not properly initialized.
|
|
74
|
+
*
|
|
75
|
+
* For example, code that initializes with an undefined or empty recordId might
|
|
76
|
+
* produce an invalid record reference rather than propagate nullish types, as
|
|
77
|
+
* most operations on an invalid reference are no-ops. For the rest, it is
|
|
78
|
+
* recommended to check for validity using this function before performing
|
|
79
|
+
* operations.
|
|
80
|
+
*/
|
|
56
81
|
export function isValidRecordRef<M extends Model = Model>(
|
|
57
82
|
recordRef: RecordRef<M>,
|
|
58
83
|
): recordRef is RecordRef<M> {
|
package/src/types/StateModule.ts
CHANGED
|
@@ -73,6 +73,15 @@ export interface StateModule {
|
|
|
73
73
|
schema: T,
|
|
74
74
|
) => Promise<DocumentRef<T>>;
|
|
75
75
|
|
|
76
|
+
readonly searchDocuments: <T extends DocumentSchema>(
|
|
77
|
+
documentTypeName: string,
|
|
78
|
+
schema: T,
|
|
79
|
+
options?: {
|
|
80
|
+
documentName?: string;
|
|
81
|
+
limit?: number;
|
|
82
|
+
},
|
|
83
|
+
) => Promise<ReadonlyArray<DocumentMetadata & { readonly id: DocumentId }>>;
|
|
84
|
+
|
|
76
85
|
readonly getDocumentSnapshot: <T extends DocumentSchema>(
|
|
77
86
|
docRef: DocumentRef<T>,
|
|
78
87
|
) => Promise<DocumentState<T>>;
|
|
@@ -199,6 +208,17 @@ export class StateModuleImpl implements StateModule {
|
|
|
199
208
|
return this.documentService.createDocument(metadata, schema);
|
|
200
209
|
}
|
|
201
210
|
|
|
211
|
+
async searchDocuments<T extends DocumentSchema>(
|
|
212
|
+
documentTypeName: string,
|
|
213
|
+
schema: T,
|
|
214
|
+
options?: {
|
|
215
|
+
documentName?: string;
|
|
216
|
+
limit?: number;
|
|
217
|
+
},
|
|
218
|
+
): Promise<ReadonlyArray<DocumentMetadata & { readonly id: DocumentId }>> {
|
|
219
|
+
return this.documentService.searchDocuments(documentTypeName, schema, options);
|
|
220
|
+
}
|
|
221
|
+
|
|
202
222
|
async getDocumentSnapshot<T extends DocumentSchema>(
|
|
203
223
|
docRef: DocumentRef<T>,
|
|
204
224
|
): Promise<DocumentState<T>> {
|