@palantir/pack.state.core 0.1.0-beta.2 → 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 +2 -2
- 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 +33 -0
- package/build/browser/index.js +73 -0
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +73 -0
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +106 -1
- package/build/esm/index.js +73 -0
- package/build/esm/index.js.map +1 -1
- package/build/types/__tests__/Transaction.test.d.ts +1 -0
- package/build/types/__tests__/Transaction.test.d.ts.map +1 -0
- package/build/types/__tests__/testUtils.d.ts.map +1 -1
- package/build/types/service/BaseYjsDocumentService.d.ts +11 -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 +18 -1
- 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 +21 -1
- package/build/types/types/StateModule.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/Transaction.test.ts +321 -0
- package/src/__tests__/testUtils.ts +1 -2
- package/src/service/BaseYjsDocumentService.ts +41 -0
- package/src/service/InMemoryDocumentService.ts +58 -1
- package/src/types/DocumentRefImpl.ts +58 -0
- package/src/types/DocumentService.ts +43 -0
- package/src/types/RecordCollectionRefImpl.ts +23 -0
- package/src/types/RecordRefImpl.ts +25 -0
- package/src/types/StateModule.ts +78 -0
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.state.core@0.1.
|
|
3
|
-
> eslint ./src
|
|
2
|
+
> @palantir/pack.state.core@0.1.1 lint /home/runner/work/pack/pack/packages/state/core
|
|
3
|
+
> eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @palantir/pack.state.core
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eba27ae: Fix issues locating model metadata when multiple copies of the schema package are present
|
|
8
|
+
- 67df6e4: Documented public apis
|
|
9
|
+
- Updated dependencies [eba27ae]
|
|
10
|
+
- Updated dependencies [67df6e4]
|
|
11
|
+
- @palantir/pack.document-schema.model-types@0.1.1
|
|
12
|
+
- @palantir/pack.core@0.1.1
|
|
13
|
+
|
|
14
|
+
## 0.1.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 77c07c4: Add Core and State Core packages, add Refs to core model types
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 09f7acd: Add activity & presence custom event subscriptions
|
|
23
|
+
- 99d9186: Add doc transactions for grouping multiple edits, and include an optional edit description for activity/history
|
|
24
|
+
- 3ebc927: Drop packApiPath
|
|
25
|
+
- fe9891e: Add new state packages
|
|
26
|
+
- Updated dependencies [8698373]
|
|
27
|
+
- Updated dependencies [09f7acd]
|
|
28
|
+
- Updated dependencies [99d9186]
|
|
29
|
+
- Updated dependencies [77c07c4]
|
|
30
|
+
- Updated dependencies [27a3b33]
|
|
31
|
+
- Updated dependencies [511ee0c]
|
|
32
|
+
- Updated dependencies [3ebc927]
|
|
33
|
+
- @palantir/pack.core@0.1.0
|
|
34
|
+
- @palantir/pack.document-schema.model-types@0.1.0
|
|
35
|
+
|
|
3
36
|
## 0.1.0-beta.2
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/build/browser/index.js
CHANGED
|
@@ -46,15 +46,27 @@ 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
|
}
|
|
55
|
+
onActivity(docRef, callback) {
|
|
56
|
+
return this.documentService.onActivity(docRef, callback);
|
|
57
|
+
}
|
|
52
58
|
onMetadataChange(docRef, cb) {
|
|
53
59
|
return this.documentService.onMetadataChange(docRef, cb);
|
|
54
60
|
}
|
|
61
|
+
onPresence(docRef, callback, options) {
|
|
62
|
+
return this.documentService.onPresence(docRef, callback, options);
|
|
63
|
+
}
|
|
55
64
|
onStateChange(docRef, cb) {
|
|
56
65
|
return this.documentService.onStateChange(docRef, cb);
|
|
57
66
|
}
|
|
67
|
+
updateCustomPresence(docRef, model, eventData) {
|
|
68
|
+
this.documentService.updateCustomPresence(docRef, model, eventData);
|
|
69
|
+
}
|
|
58
70
|
async getRecordSnapshot(recordRef) {
|
|
59
71
|
return this.documentService.getRecordSnapshot(recordRef);
|
|
60
72
|
}
|
|
@@ -64,6 +76,9 @@ var StateModuleImpl = class {
|
|
|
64
76
|
async updateRecord(recordRef, partialState) {
|
|
65
77
|
return this.documentService.updateRecord(recordRef, partialState);
|
|
66
78
|
}
|
|
79
|
+
withTransaction(docRef, fn, description) {
|
|
80
|
+
this.documentService.withTransaction(docRef, fn, description);
|
|
81
|
+
}
|
|
67
82
|
// Collection methods
|
|
68
83
|
getCreateRecordCollectionRef(docRef, model) {
|
|
69
84
|
return this.documentService.getCreateRecordCollectionRef(docRef, model);
|
|
@@ -131,9 +146,18 @@ var INVALID_DOC_REF = Object.freeze({
|
|
|
131
146
|
getRecords: () => {
|
|
132
147
|
throw new Error("Invalid document reference");
|
|
133
148
|
},
|
|
149
|
+
onActivity: () => () => {
|
|
150
|
+
},
|
|
134
151
|
onMetadataChange: () => () => {
|
|
135
152
|
},
|
|
153
|
+
onPresence: () => () => {
|
|
154
|
+
},
|
|
136
155
|
onStateChange: () => () => {
|
|
156
|
+
},
|
|
157
|
+
updateCustomPresence: () => {
|
|
158
|
+
},
|
|
159
|
+
withTransaction: () => {
|
|
160
|
+
throw new Error("Invalid document reference");
|
|
137
161
|
}
|
|
138
162
|
});
|
|
139
163
|
var createDocRef = (app, id, schema) => {
|
|
@@ -160,12 +184,24 @@ var DocumentRefImpl = class {
|
|
|
160
184
|
getRecords(model) {
|
|
161
185
|
return this.#stateModule.getCreateRecordCollectionRef(this, model);
|
|
162
186
|
}
|
|
187
|
+
onActivity(callback) {
|
|
188
|
+
return this.#stateModule.onActivity(this, callback);
|
|
189
|
+
}
|
|
163
190
|
onMetadataChange(cb) {
|
|
164
191
|
return this.#stateModule.onMetadataChange(this, cb);
|
|
165
192
|
}
|
|
193
|
+
onPresence(callback, options) {
|
|
194
|
+
return this.#stateModule.onPresence(this, callback, options);
|
|
195
|
+
}
|
|
166
196
|
onStateChange(callback) {
|
|
167
197
|
return this.#stateModule.onStateChange(this, callback);
|
|
168
198
|
}
|
|
199
|
+
updateCustomPresence(model, eventData) {
|
|
200
|
+
this.#stateModule.updateCustomPresence(this, model, eventData);
|
|
201
|
+
}
|
|
202
|
+
withTransaction(fn, description) {
|
|
203
|
+
this.#stateModule.withTransaction(this, fn, description);
|
|
204
|
+
}
|
|
169
205
|
};
|
|
170
206
|
|
|
171
207
|
// src/types/DocumentService.ts
|
|
@@ -652,6 +688,11 @@ var BaseYjsDocumentService = class {
|
|
|
652
688
|
this.onRecordSet?.(recordRef, partialState);
|
|
653
689
|
return Promise.resolve();
|
|
654
690
|
};
|
|
691
|
+
withTransaction = (docRef, fn, description) => {
|
|
692
|
+
const internalDoc = this.documents.get(docRef.id);
|
|
693
|
+
!(internalDoc != null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Cannot start transaction as document not found: ${docRef.id}`) : invariant(false) : void 0;
|
|
694
|
+
internalDoc.yDoc.transact(fn, description);
|
|
695
|
+
};
|
|
655
696
|
onMetadataChange(docRef, callback) {
|
|
656
697
|
const {
|
|
657
698
|
internalDoc,
|
|
@@ -1212,6 +1253,28 @@ var InMemoryDocumentService = class extends BaseYjsDocumentService {
|
|
|
1212
1253
|
this.getCreateInternalDoc(docRef, metadata, yDoc);
|
|
1213
1254
|
return Promise.resolve(docRef);
|
|
1214
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
|
+
};
|
|
1215
1278
|
// Lifecycle method implementations
|
|
1216
1279
|
onMetadataSubscriptionOpened(internalDoc, docRef) {
|
|
1217
1280
|
this.updateMetadataStatus(internalDoc, docRef, {
|
|
@@ -1247,6 +1310,16 @@ var InMemoryDocumentService = class extends BaseYjsDocumentService {
|
|
|
1247
1310
|
}
|
|
1248
1311
|
onDataSubscriptionClosed(_internalDoc, _docRef) {
|
|
1249
1312
|
}
|
|
1313
|
+
onActivity(_docRef, _callback) {
|
|
1314
|
+
return () => {
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
onPresence(_docRef, _callback, _options) {
|
|
1318
|
+
return () => {
|
|
1319
|
+
};
|
|
1320
|
+
}
|
|
1321
|
+
updateCustomPresence(_docRef, _model, _eventData) {
|
|
1322
|
+
}
|
|
1250
1323
|
};
|
|
1251
1324
|
function generateDocumentId() {
|
|
1252
1325
|
return generateId();
|