@palantir/pack.state.core 0.1.0 → 0.2.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.
- 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 +23 -0
- package/build/browser/index.js +29 -4
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +29 -4
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +94 -1
- package/build/esm/index.js +29 -4
- package/build/esm/index.js.map +1 -1
- package/build/types/service/BaseYjsDocumentService.d.ts +7 -1
- package/build/types/service/BaseYjsDocumentService.d.ts.map +1 -1
- package/build/types/service/InMemoryDocumentService.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 +9 -2
- package/src/service/InMemoryDocumentService.ts +31 -3
- 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
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @palantir/pack.state.core
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- dfeaeb0: Fix bug in core, where multiple yDocs could get created, causing the initial update to be dropped
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [dfeaeb0]
|
|
12
|
+
- @palantir/pack.document-schema.model-types@0.2.0
|
|
13
|
+
- @palantir/pack.core@0.2.0
|
|
14
|
+
|
|
15
|
+
## 0.1.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- eba27ae: Fix issues locating model metadata when multiple copies of the schema package are present
|
|
20
|
+
- 67df6e4: Documented public apis
|
|
21
|
+
- Updated dependencies [eba27ae]
|
|
22
|
+
- Updated dependencies [67df6e4]
|
|
23
|
+
- @palantir/pack.document-schema.model-types@0.1.1
|
|
24
|
+
- @palantir/pack.core@0.1.1
|
|
25
|
+
|
|
3
26
|
## 0.1.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/build/browser/index.js
CHANGED
|
@@ -46,6 +46,9 @@ var StateModuleImpl = class {
|
|
|
46
46
|
async createDocument(metadata, schema) {
|
|
47
47
|
return this.documentService.createDocument(metadata, schema);
|
|
48
48
|
}
|
|
49
|
+
async searchDocuments(documentTypeName, schema, options) {
|
|
50
|
+
return this.documentService.searchDocuments(documentTypeName, schema, options);
|
|
51
|
+
}
|
|
49
52
|
async getDocumentSnapshot(docRef) {
|
|
50
53
|
return this.documentService.getDocumentSnapshot(docRef);
|
|
51
54
|
}
|
|
@@ -527,7 +530,7 @@ var BaseYjsDocumentService = class {
|
|
|
527
530
|
* Called when the last data subscription is closed for a document.
|
|
528
531
|
* Implementation should clean up any resources related to data synchronization.
|
|
529
532
|
*/
|
|
530
|
-
createBaseInternalDoc = (ref, metadata
|
|
533
|
+
createBaseInternalDoc = (ref, metadata) => {
|
|
531
534
|
const schema = ref.schema;
|
|
532
535
|
return {
|
|
533
536
|
ref: new WeakRef(ref),
|
|
@@ -552,7 +555,7 @@ var BaseYjsDocumentService = class {
|
|
|
552
555
|
docStateSubscribers: /* @__PURE__ */ new Set(),
|
|
553
556
|
metadataSubscribers: /* @__PURE__ */ new Set(),
|
|
554
557
|
recordSubscriptions: /* @__PURE__ */ new Map(),
|
|
555
|
-
yDoc:
|
|
558
|
+
yDoc: this.initializeYDoc(schema),
|
|
556
559
|
yDocUpdateHandler: void 0,
|
|
557
560
|
yjsCollectionHandlers: /* @__PURE__ */ new Map()
|
|
558
561
|
};
|
|
@@ -1234,8 +1237,8 @@ var InMemoryDocumentService = class extends BaseYjsDocumentService {
|
|
|
1234
1237
|
}));
|
|
1235
1238
|
this.config = config;
|
|
1236
1239
|
}
|
|
1237
|
-
createInternalDoc(ref, metadata
|
|
1238
|
-
return this.createBaseInternalDoc(ref, metadata
|
|
1240
|
+
createInternalDoc(ref, metadata) {
|
|
1241
|
+
return this.createBaseInternalDoc(ref, metadata);
|
|
1239
1242
|
}
|
|
1240
1243
|
get hasMetadataSubscriptions() {
|
|
1241
1244
|
return Array.from(this.documents.values()).some((doc) => this.hasSubscriptions(doc) && doc.metadataSubscribers.size > 0);
|
|
@@ -1250,6 +1253,28 @@ var InMemoryDocumentService = class extends BaseYjsDocumentService {
|
|
|
1250
1253
|
this.getCreateInternalDoc(docRef, metadata, yDoc);
|
|
1251
1254
|
return Promise.resolve(docRef);
|
|
1252
1255
|
};
|
|
1256
|
+
searchDocuments = (documentTypeName, schema, options) => {
|
|
1257
|
+
const results = [];
|
|
1258
|
+
const {
|
|
1259
|
+
documentName,
|
|
1260
|
+
limit
|
|
1261
|
+
} = options ?? {};
|
|
1262
|
+
for (const [docId, internalDoc] of this.documents.entries()) {
|
|
1263
|
+
if (internalDoc.metadata?.documentTypeName === documentTypeName) {
|
|
1264
|
+
if (documentName && !internalDoc.metadata.name.includes(documentName)) {
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
results.push({
|
|
1268
|
+
...internalDoc.metadata,
|
|
1269
|
+
id: docId
|
|
1270
|
+
});
|
|
1271
|
+
if (limit && results.length >= limit) {
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
return Promise.resolve(results);
|
|
1277
|
+
};
|
|
1253
1278
|
// Lifecycle method implementations
|
|
1254
1279
|
onMetadataSubscriptionOpened(internalDoc, docRef) {
|
|
1255
1280
|
this.updateMetadataStatus(internalDoc, docRef, {
|