@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.
Files changed (35) hide show
  1. package/.turbo/turbo-lint.log +1 -1
  2. package/.turbo/turbo-transpileBrowser.log +1 -1
  3. package/.turbo/turbo-transpileCjs.log +1 -1
  4. package/.turbo/turbo-transpileEsm.log +1 -1
  5. package/.turbo/turbo-transpileTypes.log +1 -1
  6. package/.turbo/turbo-typecheck.log +1 -1
  7. package/CHANGELOG.md +23 -0
  8. package/build/browser/index.js +29 -4
  9. package/build/browser/index.js.map +1 -1
  10. package/build/cjs/index.cjs +29 -4
  11. package/build/cjs/index.cjs.map +1 -1
  12. package/build/cjs/index.d.cts +94 -1
  13. package/build/esm/index.js +29 -4
  14. package/build/esm/index.js.map +1 -1
  15. package/build/types/service/BaseYjsDocumentService.d.ts +7 -1
  16. package/build/types/service/BaseYjsDocumentService.d.ts.map +1 -1
  17. package/build/types/service/InMemoryDocumentService.d.ts.map +1 -1
  18. package/build/types/types/DocumentRefImpl.d.ts +20 -0
  19. package/build/types/types/DocumentRefImpl.d.ts.map +1 -1
  20. package/build/types/types/DocumentService.d.ts +13 -0
  21. package/build/types/types/DocumentService.d.ts.map +1 -1
  22. package/build/types/types/RecordCollectionRefImpl.d.ts +23 -0
  23. package/build/types/types/RecordCollectionRefImpl.d.ts.map +1 -1
  24. package/build/types/types/RecordRefImpl.d.ts +25 -0
  25. package/build/types/types/RecordRefImpl.d.ts.map +1 -1
  26. package/build/types/types/StateModule.d.ts +12 -0
  27. package/build/types/types/StateModule.d.ts.map +1 -1
  28. package/package.json +4 -4
  29. package/src/service/BaseYjsDocumentService.ts +9 -2
  30. package/src/service/InMemoryDocumentService.ts +31 -3
  31. package/src/types/DocumentRefImpl.ts +20 -0
  32. package/src/types/DocumentService.ts +16 -0
  33. package/src/types/RecordCollectionRefImpl.ts +23 -0
  34. package/src/types/RecordRefImpl.ts +25 -0
  35. package/src/types/StateModule.ts +20 -0
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 lint /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 lint /home/runner/work/pack/pack/packages/state/core
3
3
  > eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files
4
4
 
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 transpileBrowser /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 transpileBrowser /home/runner/work/pack/pack/packages/state/core
3
3
  > monorepo-transpile -f esm -m bundle -t browser
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 transpileCjs /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 transpileCjs /home/runner/work/pack/pack/packages/state/core
3
3
  > monorepo-transpile -f cjs -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 transpileEsm /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 transpileEsm /home/runner/work/pack/pack/packages/state/core
3
3
  > monorepo-transpile -f esm -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 transpileTypes /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 transpileTypes /home/runner/work/pack/pack/packages/state/core
3
3
  > monorepo-transpile -f esm -m types -t node
4
4
 
5
5
  👍
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.state.core@0.1.0 typecheck /home/runner/work/pack/pack/packages/state/core
2
+ > @palantir/pack.state.core@0.2.0 typecheck /home/runner/work/pack/pack/packages/state/core
3
3
  > tsc --noEmit --emitDeclarationOnly false
4
4
 
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
@@ -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, yDoc) => {
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: yDoc || this.initializeYDoc(schema),
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, yDoc) {
1238
- return this.createBaseInternalDoc(ref, metadata, yDoc);
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, {