@palantir/pack.state.core 0.1.0-beta.2 → 0.1.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 +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 +22 -0
- package/build/browser/index.js +48 -0
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +48 -0
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +13 -1
- package/build/esm/index.js +48 -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 +5 -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.map +1 -1
- package/build/types/types/DocumentService.d.ts +5 -1
- package/build/types/types/DocumentService.d.ts.map +1 -1
- package/build/types/types/StateModule.d.ts +9 -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 +33 -0
- package/src/service/InMemoryDocumentService.ts +28 -1
- package/src/types/DocumentRefImpl.ts +38 -0
- package/src/types/DocumentService.ts +27 -0
- package/src/types/StateModule.ts +58 -0
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.state.core@0.1.0
|
|
3
|
-
> eslint ./src
|
|
2
|
+
> @palantir/pack.state.core@0.1.0 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,27 @@
|
|
|
1
1
|
# @palantir/pack.state.core
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 77c07c4: Add Core and State Core packages, add Refs to core model types
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 09f7acd: Add activity & presence custom event subscriptions
|
|
12
|
+
- 99d9186: Add doc transactions for grouping multiple edits, and include an optional edit description for activity/history
|
|
13
|
+
- 3ebc927: Drop packApiPath
|
|
14
|
+
- fe9891e: Add new state packages
|
|
15
|
+
- Updated dependencies [8698373]
|
|
16
|
+
- Updated dependencies [09f7acd]
|
|
17
|
+
- Updated dependencies [99d9186]
|
|
18
|
+
- Updated dependencies [77c07c4]
|
|
19
|
+
- Updated dependencies [27a3b33]
|
|
20
|
+
- Updated dependencies [511ee0c]
|
|
21
|
+
- Updated dependencies [3ebc927]
|
|
22
|
+
- @palantir/pack.core@0.1.0
|
|
23
|
+
- @palantir/pack.document-schema.model-types@0.1.0
|
|
24
|
+
|
|
3
25
|
## 0.1.0-beta.2
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/build/browser/index.js
CHANGED
|
@@ -49,12 +49,21 @@ var StateModuleImpl = class {
|
|
|
49
49
|
async getDocumentSnapshot(docRef) {
|
|
50
50
|
return this.documentService.getDocumentSnapshot(docRef);
|
|
51
51
|
}
|
|
52
|
+
onActivity(docRef, callback) {
|
|
53
|
+
return this.documentService.onActivity(docRef, callback);
|
|
54
|
+
}
|
|
52
55
|
onMetadataChange(docRef, cb) {
|
|
53
56
|
return this.documentService.onMetadataChange(docRef, cb);
|
|
54
57
|
}
|
|
58
|
+
onPresence(docRef, callback, options) {
|
|
59
|
+
return this.documentService.onPresence(docRef, callback, options);
|
|
60
|
+
}
|
|
55
61
|
onStateChange(docRef, cb) {
|
|
56
62
|
return this.documentService.onStateChange(docRef, cb);
|
|
57
63
|
}
|
|
64
|
+
updateCustomPresence(docRef, model, eventData) {
|
|
65
|
+
this.documentService.updateCustomPresence(docRef, model, eventData);
|
|
66
|
+
}
|
|
58
67
|
async getRecordSnapshot(recordRef) {
|
|
59
68
|
return this.documentService.getRecordSnapshot(recordRef);
|
|
60
69
|
}
|
|
@@ -64,6 +73,9 @@ var StateModuleImpl = class {
|
|
|
64
73
|
async updateRecord(recordRef, partialState) {
|
|
65
74
|
return this.documentService.updateRecord(recordRef, partialState);
|
|
66
75
|
}
|
|
76
|
+
withTransaction(docRef, fn, description) {
|
|
77
|
+
this.documentService.withTransaction(docRef, fn, description);
|
|
78
|
+
}
|
|
67
79
|
// Collection methods
|
|
68
80
|
getCreateRecordCollectionRef(docRef, model) {
|
|
69
81
|
return this.documentService.getCreateRecordCollectionRef(docRef, model);
|
|
@@ -131,9 +143,18 @@ var INVALID_DOC_REF = Object.freeze({
|
|
|
131
143
|
getRecords: () => {
|
|
132
144
|
throw new Error("Invalid document reference");
|
|
133
145
|
},
|
|
146
|
+
onActivity: () => () => {
|
|
147
|
+
},
|
|
134
148
|
onMetadataChange: () => () => {
|
|
135
149
|
},
|
|
150
|
+
onPresence: () => () => {
|
|
151
|
+
},
|
|
136
152
|
onStateChange: () => () => {
|
|
153
|
+
},
|
|
154
|
+
updateCustomPresence: () => {
|
|
155
|
+
},
|
|
156
|
+
withTransaction: () => {
|
|
157
|
+
throw new Error("Invalid document reference");
|
|
137
158
|
}
|
|
138
159
|
});
|
|
139
160
|
var createDocRef = (app, id, schema) => {
|
|
@@ -160,12 +181,24 @@ var DocumentRefImpl = class {
|
|
|
160
181
|
getRecords(model) {
|
|
161
182
|
return this.#stateModule.getCreateRecordCollectionRef(this, model);
|
|
162
183
|
}
|
|
184
|
+
onActivity(callback) {
|
|
185
|
+
return this.#stateModule.onActivity(this, callback);
|
|
186
|
+
}
|
|
163
187
|
onMetadataChange(cb) {
|
|
164
188
|
return this.#stateModule.onMetadataChange(this, cb);
|
|
165
189
|
}
|
|
190
|
+
onPresence(callback, options) {
|
|
191
|
+
return this.#stateModule.onPresence(this, callback, options);
|
|
192
|
+
}
|
|
166
193
|
onStateChange(callback) {
|
|
167
194
|
return this.#stateModule.onStateChange(this, callback);
|
|
168
195
|
}
|
|
196
|
+
updateCustomPresence(model, eventData) {
|
|
197
|
+
this.#stateModule.updateCustomPresence(this, model, eventData);
|
|
198
|
+
}
|
|
199
|
+
withTransaction(fn, description) {
|
|
200
|
+
this.#stateModule.withTransaction(this, fn, description);
|
|
201
|
+
}
|
|
169
202
|
};
|
|
170
203
|
|
|
171
204
|
// src/types/DocumentService.ts
|
|
@@ -652,6 +685,11 @@ var BaseYjsDocumentService = class {
|
|
|
652
685
|
this.onRecordSet?.(recordRef, partialState);
|
|
653
686
|
return Promise.resolve();
|
|
654
687
|
};
|
|
688
|
+
withTransaction = (docRef, fn, description) => {
|
|
689
|
+
const internalDoc = this.documents.get(docRef.id);
|
|
690
|
+
!(internalDoc != null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Cannot start transaction as document not found: ${docRef.id}`) : invariant(false) : void 0;
|
|
691
|
+
internalDoc.yDoc.transact(fn, description);
|
|
692
|
+
};
|
|
655
693
|
onMetadataChange(docRef, callback) {
|
|
656
694
|
const {
|
|
657
695
|
internalDoc,
|
|
@@ -1247,6 +1285,16 @@ var InMemoryDocumentService = class extends BaseYjsDocumentService {
|
|
|
1247
1285
|
}
|
|
1248
1286
|
onDataSubscriptionClosed(_internalDoc, _docRef) {
|
|
1249
1287
|
}
|
|
1288
|
+
onActivity(_docRef, _callback) {
|
|
1289
|
+
return () => {
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
onPresence(_docRef, _callback, _options) {
|
|
1293
|
+
return () => {
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
updateCustomPresence(_docRef, _model, _eventData) {
|
|
1297
|
+
}
|
|
1250
1298
|
};
|
|
1251
1299
|
function generateDocumentId() {
|
|
1252
1300
|
return generateId();
|