@palantir/pack.document-schema.model-types 0.2.0 → 0.2.2

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 (39) 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 +12 -0
  8. package/build/browser/index.js +67 -5
  9. package/build/browser/index.js.map +1 -1
  10. package/build/cjs/index.cjs +69 -4
  11. package/build/cjs/index.cjs.map +1 -1
  12. package/build/cjs/index.d.cts +174 -13
  13. package/build/esm/index.js +67 -5
  14. package/build/esm/index.js.map +1 -1
  15. package/build/types/index.d.ts +4 -2
  16. package/build/types/index.d.ts.map +1 -1
  17. package/build/types/types/ActivityEvent.d.ts +1 -1
  18. package/build/types/types/ActivityEvent.d.ts.map +1 -1
  19. package/build/types/types/DocumentRef.d.ts +3 -6
  20. package/build/types/types/DocumentRef.d.ts.map +1 -1
  21. package/build/types/types/Metadata.d.ts +3 -1
  22. package/build/types/types/Metadata.d.ts.map +1 -1
  23. package/build/types/types/PresenceEvent.d.ts +3 -3
  24. package/build/types/types/PresenceEvent.d.ts.map +1 -1
  25. package/build/types/types/RecordRef.d.ts +26 -1
  26. package/build/types/types/RecordRef.d.ts.map +1 -1
  27. package/build/types/utils/ActivityEvents.d.ts +59 -0
  28. package/build/types/utils/ActivityEvents.d.ts.map +1 -0
  29. package/build/types/utils/PresenceEvents.d.ts +66 -0
  30. package/build/types/utils/PresenceEvents.d.ts.map +1 -0
  31. package/package.json +1 -1
  32. package/src/index.ts +4 -2
  33. package/src/types/ActivityEvent.ts +1 -1
  34. package/src/types/DocumentRef.ts +3 -6
  35. package/src/types/Metadata.ts +23 -2
  36. package/src/types/PresenceEvent.ts +3 -3
  37. package/src/types/RecordRef.ts +28 -1
  38. package/src/utils/ActivityEvents.ts +105 -0
  39. package/src/utils/PresenceEvents.ts +113 -0
@@ -5,7 +5,9 @@ declare const Metadata: symbol;
5
5
  interface WithMetadata<T> {
6
6
  readonly [Metadata]: T;
7
7
  }
8
- declare function getMetadata<T>(obj: WithMetadata<T>): T;
8
+ declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing?: true): T;
9
+ declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing: false): T | undefined;
10
+ declare function hasMetadata(obj: unknown): obj is WithMetadata<unknown>;
9
11
 
10
12
  /**
11
13
  * A Model defines the structure of a document record or union.
@@ -95,7 +97,7 @@ interface ActivityEventDataCustom<M extends Model = Model> {
95
97
  * applications.
96
98
  */
97
99
  interface ActivityEventDataUnknown {
98
- readonly type: "unknown";
100
+ readonly type: typeof ActivityEventDataType.UNKNOWN;
99
101
  readonly rawType: string;
100
102
  readonly rawData: unknown;
101
103
  }
@@ -216,12 +218,12 @@ interface PresenceEventDataCustom<M extends Model = Model> {
216
218
  * in a future release of pack libraries and can be safely ignored by
217
219
  * applications.
218
220
  */
219
- interface PresenceEventUnknown {
220
- readonly type: "unknown";
221
+ interface PresenceEventDataUnknown {
222
+ readonly type: typeof PresenceEventDataType.UNKNOWN;
221
223
  readonly rawType: string;
222
224
  readonly rawData: unknown;
223
225
  }
224
- type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom | PresenceEventUnknown;
226
+ type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom | PresenceEventDataUnknown;
225
227
  /**
226
228
  * An event representing a transient awareness or presence change for a user on this document.
227
229
  * The presence channel is intended for ephemeral data such as user cursors, selections, or
@@ -306,10 +308,21 @@ interface RecordRef<M extends Model = Model> {
306
308
  * });
307
309
  *
308
310
  * // Trigger the deletion
309
- * docRef.getRecords(MyModel).delete(recordRef.id);
311
+ * recordRef.delete();
310
312
  * ```
311
313
  */
312
314
  onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
315
+ /**
316
+ * Delete the record from the document.
317
+ *
318
+ * @returns An ignorable promise that resolves when the record is deleted.
319
+ *
320
+ * @example
321
+ * ```ts
322
+ * await recordRef.delete();
323
+ * ```
324
+ */
325
+ delete(): Promise<void>;
313
326
  /**
314
327
  * Set the data for the record (creating it if it doesn't exist).
315
328
  *
@@ -324,6 +337,20 @@ interface RecordRef<M extends Model = Model> {
324
337
  * ```
325
338
  */
326
339
  set(record: ModelData<M>): Promise<void>;
340
+ /**
341
+ * Update specific fields of the record.
342
+ *
343
+ * @see {onChange} to subscribe to changes to the record.
344
+ *
345
+ * @param partialRecord - A partial plain object with the fields to update.
346
+ * @returns An ignorable promise that resolves when the record is published.
347
+ *
348
+ * @example
349
+ * ```ts
350
+ * await recordRef.update({ field: "new value" });
351
+ * ```
352
+ */
353
+ update(record: Partial<ModelData<M>>): Promise<void>;
327
354
  }
328
355
 
329
356
  declare const RecordCollectionRefBrand: unique symbol;
@@ -589,12 +616,9 @@ interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
589
616
  * const myRecords = docRef.getRecords(MyModel);
590
617
  * myRecords.set("record-1", { field: "new value" });
591
618
  * myRecords.delete("record-2");
592
- * }, {
593
- * model: MyEditEventModel,
594
- * data: {
595
- * summary: "Updated record-1 and deleted record-2",
596
- * },
597
- * });
619
+ * }, ActivityEvents.describeEdit(MyEditEventModel, {
620
+ * summary: "Updated record-1 and deleted record-2",
621
+ * }));
598
622
  * ```
599
623
  */
600
624
  withTransaction(fn: () => void, description?: EditDescription): void;
@@ -622,4 +646,141 @@ interface ObjectRef {
622
646
  readonly subscribe?: (callback: unknown) => unknown;
623
647
  }
624
648
 
625
- export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentState, type EditDescription, ExternalRefType, type MediaId, type MediaRef, MediaRefBrand, Metadata, type Model, type ModelData, type ModelMetadata, type ObjectId, type ObjectRef, ObjectRefBrand, type PresenceEvent, type PresenceEventData, type PresenceEventDataArrived, type PresenceEventDataCustom, type PresenceEventDataDeparted, PresenceEventDataType, type PresenceEventUnknown, type PresenceSubscriptionOptions, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, type RecordRef, RecordRefBrand, type Unsubscribe, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata };
649
+ /**
650
+ * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.
651
+ *
652
+ * @param model The model to edit.
653
+ * @param data The data to apply to the model.
654
+ * @returns An edit description for the model.
655
+ *
656
+ * @example
657
+ * ```ts
658
+ * docRef.withTransaction(() => {
659
+ * // make some edits to the document here
660
+ * }, ActivityEvents.describeEdit(MyEventModel, {
661
+ * myEventDataField: "some value",
662
+ * foo: 42,
663
+ * }));
664
+ * ```
665
+ */
666
+ declare function describeEdit<M extends Model>(model: M, data: ModelData<M>): EditDescription<M>;
667
+ /**
668
+ * Type guard for custom event data.
669
+ *
670
+ * @param eventData The event data to check.
671
+ * @returns true if the event data is a custom event, false otherwise.
672
+ */
673
+ declare function isCustom$1(eventData: ActivityEventData): eventData is ActivityEventDataCustom;
674
+ /**
675
+ * Type guard for custom event data for a specific model.
676
+ *
677
+ * @param eventData The event data from a {@link ActivityEvent} to check.
678
+ * @param model The model to check for.
679
+ * @returns true if the event data is a custom event for the given model, false otherwise.
680
+ *
681
+ * @example
682
+ * ```ts
683
+ * docRef.onActivity((docRef, event) => {
684
+ * if (!ActivityEvents.isEdit(event.eventData, MyEventModel)) {
685
+ * return;
686
+ * }
687
+ *
688
+ * console.log("Got event", event.eventData.eventData.myField);
689
+ * });
690
+ * ```
691
+ */
692
+ declare function isEdit<M extends Model>(eventData: ActivityEventData, model: M): eventData is ActivityEventDataCustom<M>;
693
+ /**
694
+ * Type guard for unknown activity event data. These are fired when a user
695
+ * performs an action that is not recognized by this client.
696
+ *
697
+ * This may be due to application version mismatch, or new platform features for
698
+ * example, and should generally be ignorable.
699
+ *
700
+ * @experimental
701
+ *
702
+ * @param eventData The event data to check.
703
+ * @returns true if the event data is an unknown event, false otherwise.
704
+ */
705
+ declare function isUnknown$1(eventData: ActivityEventData): eventData is ActivityEventDataUnknown;
706
+
707
+ declare const ActivityEvents_describeEdit: typeof describeEdit;
708
+ declare const ActivityEvents_isEdit: typeof isEdit;
709
+ declare namespace ActivityEvents {
710
+ export { ActivityEvents_describeEdit as describeEdit, isCustom$1 as isCustom, ActivityEvents_isEdit as isEdit, isUnknown$1 as isUnknown };
711
+ }
712
+
713
+ /**
714
+ * Type guard for Arrived presence events. These are fired when a user comes online on a document.
715
+ * @param eventData The event data from a {@link PresenceEvent} to check.
716
+ *
717
+ * @example
718
+ * ```ts
719
+ * if (PresenceEvents.isArrived(event.eventData)) {
720
+ * console.log(`User ${event.userId} has arrived on the document.`);
721
+ * }
722
+ * ```
723
+ */
724
+ declare function isArrived(eventData: PresenceEventData): eventData is PresenceEventDataArrived;
725
+ /**
726
+ * Type guard for custom presence events.
727
+ * @param eventData The event data from a {@link PresenceEvent} to check.
728
+ * @param model The model to check for.
729
+ * @returns true if the event data is a custom event for the given model, false otherwise.
730
+ *
731
+ * @example
732
+ * ```ts
733
+ * if (PresenceEvents.isCustom(event.eventData, MyEventModel)) {
734
+ * console.log("Got event", event.eventData.data.myField);
735
+ * }
736
+ * ```
737
+ */
738
+ declare function isCustom<M extends Model>(eventData: PresenceEventData, model: M): eventData is PresenceEventDataCustom<M>;
739
+ /**
740
+ * Type guard for custom presence events.
741
+ * @param eventData The event data from a {@link PresenceEvent} to check.
742
+ * @returns true if the event data is a custom event of some type, false otherwise.
743
+ *
744
+ * @example
745
+ * ```ts
746
+ * if (PresenceEvents.isCustom(event.eventData)) {
747
+ * console.log("Got a custom event:", event.eventData.model);
748
+ * }
749
+ * ```
750
+ */
751
+ declare function isCustom(eventData: PresenceEventData): eventData is PresenceEventDataCustom;
752
+ /**
753
+ * Type guard for Departed presence events. These are fired when a user goes offline from a document.
754
+ * @param eventData The event data from a {@link PresenceEvent} to check.
755
+ * @returns true if the event data is a departed event, false otherwise.
756
+ *
757
+ * @example
758
+ * ```ts
759
+ * if (PresenceEvents.isDeparted(event.eventData)) {
760
+ * console.log(`User ${event.userId} has departed from the document.`);
761
+ * }
762
+ * ```
763
+ */
764
+ declare function isDeparted(eventData: PresenceEventData): eventData is PresenceEventDataDeparted;
765
+ /**
766
+ * Type guard for unknown presence events. These are fired when a user performs an action that is not
767
+ * recognized.
768
+ * This may be due to application version mismatch, or new platform features for example, and should
769
+ * generally be ignorable.
770
+ *
771
+ * @experimental
772
+ *
773
+ * @param eventData The event data from a {@link PresenceEvent} to check.
774
+ * @returns true if the event data is an unknown event, false otherwise.
775
+ */
776
+ declare function isUnknown(eventData: PresenceEventData): eventData is PresenceEventDataUnknown;
777
+
778
+ declare const PresenceEvents_isArrived: typeof isArrived;
779
+ declare const PresenceEvents_isCustom: typeof isCustom;
780
+ declare const PresenceEvents_isDeparted: typeof isDeparted;
781
+ declare const PresenceEvents_isUnknown: typeof isUnknown;
782
+ declare namespace PresenceEvents {
783
+ export { PresenceEvents_isArrived as isArrived, PresenceEvents_isCustom as isCustom, PresenceEvents_isDeparted as isDeparted, PresenceEvents_isUnknown as isUnknown };
784
+ }
785
+
786
+ export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, ActivityEvents, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentState, type EditDescription, ExternalRefType, type MediaId, type MediaRef, MediaRefBrand, Metadata, type Model, type ModelData, type ModelMetadata, type ObjectId, type ObjectRef, ObjectRefBrand, type PresenceEvent, type PresenceEventData, type PresenceEventDataArrived, type PresenceEventDataCustom, type PresenceEventDataDeparted, PresenceEventDataType, type PresenceEventDataUnknown, PresenceEvents, type PresenceSubscriptionOptions, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, type RecordRef, RecordRefBrand, type Unsubscribe, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata, hasMetadata };
@@ -1,3 +1,11 @@
1
+ import { justOnce } from '@palantir/pack.core';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __export = (target, all) => {
5
+ for (var name in all)
6
+ __defProp(target, name, { get: all[name], enumerable: true });
7
+ };
8
+
1
9
  // src/types/ActivityEvent.ts
2
10
  var ActivityEventDataType = {
3
11
  CUSTOM_EVENT: "customEvent",
@@ -9,10 +17,8 @@ var DocumentRefBrand = Symbol("pack:DocumentRef");
9
17
 
10
18
  // src/types/MediaRef.ts
11
19
  var MediaRefBrand = Symbol("pack:MediaRef");
12
-
13
- // src/types/Metadata.ts
14
20
  var Metadata = Symbol("@palantir/pack.document-schema/metadata");
15
- function getMetadata(obj) {
21
+ function getMetadata(obj, throwIfMissing = true) {
16
22
  const directMetadata = obj[Metadata];
17
23
  if (directMetadata != null) {
18
24
  return directMetadata;
@@ -23,11 +29,22 @@ function getMetadata(obj) {
23
29
  if (symbolKey.toString() === metadataString) {
24
30
  const fallbackMetadata = obj[symbolKey];
25
31
  if (fallbackMetadata != null) {
32
+ justOnce("getMetadata-fallback-warning", () => {
33
+ console.warn("Warning: Retrieved metadata using fallback symbol lookup. This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.");
34
+ });
26
35
  return fallbackMetadata;
27
36
  }
28
37
  }
29
38
  }
30
- throw new Error("Object does not have metadata");
39
+ if (throwIfMissing) {
40
+ throw new Error("Object does not have metadata");
41
+ }
42
+ }
43
+ function hasMetadata(obj) {
44
+ if (obj == null || typeof obj !== "object") {
45
+ return false;
46
+ }
47
+ return getMetadata(obj, false) != null;
31
48
  }
32
49
 
33
50
  // src/types/Model.ts
@@ -58,6 +75,51 @@ var RecordRefBrand = Symbol("pack:RecordRef");
58
75
  // src/types/UserRef.ts
59
76
  var UserRefBrand = Symbol("pack:UserRef");
60
77
 
61
- export { ActivityEventDataType, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata };
78
+ // src/utils/ActivityEvents.ts
79
+ var ActivityEvents_exports = {};
80
+ __export(ActivityEvents_exports, {
81
+ describeEdit: () => describeEdit,
82
+ isCustom: () => isCustom,
83
+ isEdit: () => isEdit,
84
+ isUnknown: () => isUnknown
85
+ });
86
+ function describeEdit(model, data) {
87
+ return {
88
+ data,
89
+ model
90
+ };
91
+ }
92
+ function isCustom(eventData) {
93
+ return eventData.type === ActivityEventDataType.CUSTOM_EVENT;
94
+ }
95
+ function isEdit(eventData, model) {
96
+ return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;
97
+ }
98
+ function isUnknown(eventData) {
99
+ return eventData.type === ActivityEventDataType.UNKNOWN;
100
+ }
101
+
102
+ // src/utils/PresenceEvents.ts
103
+ var PresenceEvents_exports = {};
104
+ __export(PresenceEvents_exports, {
105
+ isArrived: () => isArrived,
106
+ isCustom: () => isCustom2,
107
+ isDeparted: () => isDeparted,
108
+ isUnknown: () => isUnknown2
109
+ });
110
+ function isArrived(eventData) {
111
+ return eventData.type === PresenceEventDataType.ARRIVED;
112
+ }
113
+ function isCustom2(eventData, model) {
114
+ return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);
115
+ }
116
+ function isDeparted(eventData) {
117
+ return eventData.type === PresenceEventDataType.DEPARTED;
118
+ }
119
+ function isUnknown2(eventData) {
120
+ return eventData.type === PresenceEventDataType.UNKNOWN;
121
+ }
122
+
123
+ export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata, hasMetadata };
62
124
  //# sourceMappingURL=index.js.map
63
125
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AACjD;;;ACVO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n// TODO: add standard document activity events (need to be added to api types)\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n return fallbackMetadata;\n }\n }\n }\n throw new Error(\"Object does not have metadata\");\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */"]}
1
+ {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts","../../src/utils/ActivityEvents.ts","../../src/utils/PresenceEvents.ts"],"names":["isCustom","isUnknown"],"mappings":";;;;;;;;;AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;ACC5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,WAAA,CAAY,GAAA,EAAK,cAAA,GAAiB,IAAA,EAAM;AAEtD,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,QAAA,CAAS,gCAAgC,MAAM;AAE7C,UAAA,OAAA,CAAQ,KAAK,+QAAyR,CAAA;AAAA,QACxS,CAAC,CAAA;AACD,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,IAAI,cAAA,EAAgB;AAClB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACF;AACO,SAAS,YAAY,GAAA,EAAK;AAC/B,EAAA,IAAI,GAAA,IAAO,IAAA,IAAQ,OAAO,GAAA,KAAQ,QAAA,EAAU;AAC1C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,WAAA,CAAY,GAAA,EAAK,KAAK,CAAA,IAAK,IAAA;AACpC;;;ACvBO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc;;;AChBjD,IAAA,sBAAA,GAAA;AAAA,QAAA,CAAA,sBAAA,EAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,QAAA,EAAA,MAAA,QAAA;AAAA,EAAA,MAAA,EAAA,MAAA,MAAA;AAAA,EAAA,SAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkCO,SAAS,YAAA,CAAa,OAAO,IAAA,EAAM;AACxC,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA;AAAA,GACF;AACF;AAQO,SAAS,SAAS,SAAA,EAAW;AAClC,EAAA,OAAO,SAAA,CAAU,SAAS,qBAAA,CAAsB,YAAA;AAClD;AAoBO,SAAS,MAAA,CAAO,WAAW,KAAA,EAAO;AACvC,EAAA,OAAO,SAAA,CAAU,IAAA,KAAS,qBAAA,CAAsB,YAAA,IAAgB,UAAU,KAAA,KAAU,KAAA;AACtF;AAcO,SAAS,UAAU,SAAA,EAAW;AACnC,EAAA,OAAO,SAAA,CAAU,SAAS,qBAAA,CAAsB,OAAA;AAClD;;;ACvFA,IAAA,sBAAA,GAAA;AAAA,QAAA,CAAA,sBAAA,EAAA;AAAA,EAAA,SAAA,EAAA,MAAA,SAAA;AAAA,EAAA,QAAA,EAAA,MAAAA,SAAAA;AAAA,EAAA,UAAA,EAAA,MAAA,UAAA;AAAA,EAAA,SAAA,EAAA,MAAAC;AAAA,CAAA,CAAA;AA6BO,SAAS,UAAU,SAAA,EAAW;AACnC,EAAA,OAAO,SAAA,CAAU,SAAS,qBAAA,CAAsB,OAAA;AAClD;AA6BO,SAASD,SAAAA,CAAS,WAAW,KAAA,EAAO;AACzC,EAAA,OAAO,UAAU,IAAA,KAAS,qBAAA,CAAsB,iBAAiB,KAAA,IAAS,IAAA,IAAQ,UAAU,KAAA,KAAU,KAAA,CAAA;AACxG;AAcO,SAAS,WAAW,SAAA,EAAW;AACpC,EAAA,OAAO,SAAA,CAAU,SAAS,qBAAA,CAAsB,QAAA;AAClD;AAaO,SAASC,WAAU,SAAA,EAAW;AACnC,EAAA,OAAO,SAAA,CAAU,SAAS,qBAAA,CAAsB,OAAA;AAClD","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n// TODO: add standard document activity events (need to be added to api types)\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { justOnce } from \"@palantir/pack.core\";\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj, throwIfMissing = true) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n justOnce(\"getMetadata-fallback-warning\", () => {\n // eslint-disable-next-line no-console\n console.warn(\"Warning: Retrieved metadata using fallback symbol lookup. \" + \"This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. \" + \"Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.\");\n });\n return fallbackMetadata;\n }\n }\n }\n if (throwIfMissing) {\n throw new Error(\"Object does not have metadata\");\n }\n}\nexport function hasMetadata(obj) {\n if (obj == null || typeof obj !== \"object\") {\n return false;\n }\n return getMetadata(obj, false) != null;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActivityEventDataType } from \"../types/ActivityEvent.js\";\n/**\n * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.\n *\n * @param model The model to edit.\n * @param data The data to apply to the model.\n * @returns An edit description for the model.\n *\n * @example\n * ```ts\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, ActivityEvents.describeEdit(MyEventModel, {\n * myEventDataField: \"some value\",\n * foo: 42,\n * }));\n * ```\n */\nexport function describeEdit(model, data) {\n return {\n data,\n model\n };\n}\n\n/**\n * Type guard for custom event data.\n *\n * @param eventData The event data to check.\n * @returns true if the event data is a custom event, false otherwise.\n */\nexport function isCustom(eventData) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT;\n}\n\n/**\n * Type guard for custom event data for a specific model.\n *\n * @param eventData The event data from a {@link ActivityEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * docRef.onActivity((docRef, event) => {\n * if (!ActivityEvents.isEdit(event.eventData, MyEventModel)) {\n * return;\n * }\n *\n * console.log(\"Got event\", event.eventData.eventData.myField);\n * });\n * ```\n */\nexport function isEdit(eventData, model) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;\n}\n\n/**\n * Type guard for unknown activity event data. These are fired when a user\n * performs an action that is not recognized by this client.\n *\n * This may be due to application version mismatch, or new platform features for\n * example, and should generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === ActivityEventDataType.UNKNOWN;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PresenceEventDataType } from \"../types/PresenceEvent.js\";\n\n/**\n * Type guard for Arrived presence events. These are fired when a user comes online on a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isArrived(event.eventData)) {\n * console.log(`User ${event.userId} has arrived on the document.`);\n * }\n * ```\n */\nexport function isArrived(eventData) {\n return eventData.type === PresenceEventDataType.ARRIVED;\n}\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData, MyEventModel)) {\n * console.log(\"Got event\", event.eventData.data.myField);\n * }\n * ```\n */\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a custom event of some type, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData)) {\n * console.log(\"Got a custom event:\", event.eventData.model);\n * }\n * ```\n */\n\nexport function isCustom(eventData, model) {\n return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);\n}\n\n/**\n * Type guard for Departed presence events. These are fired when a user goes offline from a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a departed event, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isDeparted(event.eventData)) {\n * console.log(`User ${event.userId} has departed from the document.`);\n * }\n * ```\n */\nexport function isDeparted(eventData) {\n return eventData.type === PresenceEventDataType.DEPARTED;\n}\n\n/**\n * Type guard for unknown presence events. These are fired when a user performs an action that is not\n * recognized.\n * This may be due to application version mismatch, or new platform features for example, and should\n * generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === PresenceEventDataType.UNKNOWN;\n}"]}
@@ -6,14 +6,14 @@ export type { DocumentId, DocumentRef, PresenceSubscriptionOptions } from "./typ
6
6
  export type { DocumentSchema, DocumentSchemaMetadata, DocumentState } from "./types/DocumentSchema.js";
7
7
  export { MediaRefBrand } from "./types/MediaRef.js";
8
8
  export type { MediaId, MediaRef } from "./types/MediaRef.js";
9
- export { getMetadata, Metadata } from "./types/Metadata.js";
9
+ export { getMetadata, hasMetadata, Metadata } from "./types/Metadata.js";
10
10
  export type { WithMetadata } from "./types/Metadata.js";
11
11
  export { ExternalRefType } from "./types/Model.js";
12
12
  export type { EditDescription, Model, ModelData, ModelMetadata } from "./types/Model.js";
13
13
  export { ObjectRefBrand } from "./types/ObjectRef.js";
14
14
  export type { ObjectId, ObjectRef } from "./types/ObjectRef.js";
15
15
  export { PresenceEventDataType } from "./types/PresenceEvent.js";
16
- export type { PresenceEvent, PresenceEventData, PresenceEventDataArrived, PresenceEventDataCustom, PresenceEventDataDeparted, PresenceEventUnknown } from "./types/PresenceEvent.js";
16
+ export type { PresenceEvent, PresenceEventData, PresenceEventDataArrived, PresenceEventDataCustom, PresenceEventDataDeparted, PresenceEventDataUnknown } from "./types/PresenceEvent.js";
17
17
  export { RecordCollectionRefBrand } from "./types/RecordCollectionRef.js";
18
18
  export type { RecordCollectionRef } from "./types/RecordCollectionRef.js";
19
19
  export { RecordRefBrand } from "./types/RecordRef.js";
@@ -21,3 +21,5 @@ export type { RecordId, RecordRef } from "./types/RecordRef.js";
21
21
  export type { Unsubscribe } from "./types/Unsubscribe.js";
22
22
  export { UserRefBrand } from "./types/UserRef.js";
23
23
  export type { UserId, UserRef } from "./types/UserRef.js";
24
+ export * as ActivityEvents from "./utils/ActivityEvents.js";
25
+ export * as PresenceEvents from "./utils/PresenceEvents.js";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,wBACK;AACP,SAAS,wBAAwB;AACjC,cAAc,YAAY,aAAa,mCAAmC;AAC1E,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,gBAAgB;AACtC,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cAAc,iBAAiB,OAAO,WAAW,qBAAqB;AACtE,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,0BACA,yBACA,2BACA,4BACK;AACP,SAAS,gCAAgC;AACzC,cAAc,2BAA2B;AACzC,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,cAAc,mBAAmB;AACjC,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
1
+ {"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,wBACK;AACP,SAAS,wBAAwB;AACjC,cAAc,YAAY,aAAa,mCAAmC;AAC1E,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,aAAa,gBAAgB;AACnD,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cAAc,iBAAiB,OAAO,WAAW,qBAAqB;AACtE,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,0BACA,yBACA,2BACA,gCACK;AACP,SAAS,gCAAgC;AACzC,cAAc,2BAA2B;AACzC,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,cAAc,mBAAmB;AACjC,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe;AACrC,YAAY,oBAAoB;AAChC,YAAY,oBAAoB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -41,7 +41,7 @@ export interface ActivityEventDataCustom<M extends Model = Model> {
41
41
  * applications.
42
42
  */
43
43
  export interface ActivityEventDataUnknown {
44
- readonly type: "unknown";
44
+ readonly type: typeof ActivityEventDataType.UNKNOWN;
45
45
  readonly rawType: string;
46
46
  readonly rawData: unknown;
47
47
  }
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP,WAAW,UAAU;;;;;;;;;;AAahC,iBAAiB,yBAAyB;UAC/B,MAAM;UACN;UACA;;AAGX,YAAY,oBAAoB,0BAA0B;;;;;;;;AAS1D,iBAAiB,cAAc;;UAEpB;UACA,WAAW;UACX;UACA,WAAW;UACX,SAAS;UACT","names":[],"sources":["../../../src/types/ActivityEvent.ts"],"version":3,"file":"ActivityEvent.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP,WAAW,UAAU;;;;;;;;;;AAahC,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;UACnC;UACA;;AAGX,YAAY,oBAAoB,0BAA0B;;;;;;;;AAS1D,iBAAiB,cAAc;;UAEpB;UACA,WAAW;UACX;UACA,WAAW;UACX,SAAS;UACT","names":[],"sources":["../../../src/types/ActivityEvent.ts"],"version":3,"file":"ActivityEvent.d.ts"}
@@ -199,12 +199,9 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
199
199
  * const myRecords = docRef.getRecords(MyModel);
200
200
  * myRecords.set("record-1", { field: "new value" });
201
201
  * myRecords.delete("record-2");
202
- * }, {
203
- * model: MyEditEventModel,
204
- * data: {
205
- * summary: "Updated record-1 and deleted record-2",
206
- * },
207
- * });
202
+ * }, ActivityEvents.describeEdit(MyEditEventModel, {
203
+ * summary: "Updated record-1 and deleted record-2",
204
+ * }));
208
205
  * ```
209
206
  */
210
207
  withTransaction(fn: () => void, description?: EditDescription): void;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,gBAAgB,qBAAqB;AACnD,cAAc,iBAAiB,OAAO,iBAAiB;AACvD,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,mBAAmB;AAEjC,YAAY,aAAa,SAAS;;;;AAKlC,iBAAiB,4BAA4B;;;;;;UAMlC;;AAGX,OAAO,cAAMA;;;;;;;;;;;;AAab,iBAAiB,YAAY,UAAU,iBAAiB,gBAAgB;UAC7D,IAAI;UACJ,QAAQ;WACP,0BAA0B;;;;;;;;CASpC,kBAAkB,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;;;CAuBxC,WAAW,UAAU,OAAO,OAAO,IAAI,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC3D,WACE,WAAW,QAAQ,YAAY,IAAI,OAAO,yBACzC;;;;;;;;;;;;;;;CAgBH,iBACE,WAAW,QAAQ,YAAY,IAAI,UAAU,4BAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCH,WACE,WAAW,QAAQ,YAAY,IAAI,OAAO,wBAC1C,UAAU,8BACT;;;;;;;;;;;;;;;;;;;CAoBH,cACE,WAAW,QAAQ,YAAY,cAC9B;;;;;;;;;;;;;;;CAgBH,qBAAqB,UAAU,QAAQ,OACrC,OAAO,GACP,WAAW,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCvB,gBAAgB,gBAAgB,cAAc","names":["DocumentRefBrand: unique symbol"],"sources":["../../../src/types/DocumentRef.ts"],"version":3,"file":"DocumentRef.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,gBAAgB,qBAAqB;AACnD,cAAc,iBAAiB,OAAO,iBAAiB;AACvD,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,mBAAmB;AAEjC,YAAY,aAAa,SAAS;;;;AAKlC,iBAAiB,4BAA4B;;;;;;UAMlC;;AAGX,OAAO,cAAMA;;;;;;;;;;;;AAab,iBAAiB,YAAY,UAAU,iBAAiB,gBAAgB;UAC7D,IAAI;UACJ,QAAQ;WACP,0BAA0B;;;;;;;;CASpC,kBAAkB,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;;;CAuBxC,WAAW,UAAU,OAAO,OAAO,IAAI,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC3D,WACE,WAAW,QAAQ,YAAY,IAAI,OAAO,yBACzC;;;;;;;;;;;;;;;CAgBH,iBACE,WAAW,QAAQ,YAAY,IAAI,UAAU,4BAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCH,WACE,WAAW,QAAQ,YAAY,IAAI,OAAO,wBAC1C,UAAU,8BACT;;;;;;;;;;;;;;;;;;;CAoBH,cACE,WAAW,QAAQ,YAAY,cAC9B;;;;;;;;;;;;;;;CAgBH,qBAAqB,UAAU,QAAQ,OACrC,OAAO,GACP,WAAW,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BvB,gBAAgB,gBAAgB,cAAc","names":["DocumentRefBrand: unique symbol"],"sources":["../../../src/types/DocumentRef.ts"],"version":3,"file":"DocumentRef.d.ts"}
@@ -2,4 +2,6 @@ export declare const Metadata: symbol;
2
2
  export interface WithMetadata<T> {
3
3
  readonly [Metadata]: T;
4
4
  }
5
- export declare function getMetadata<T>(obj: WithMetadata<T>): T;
5
+ export declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing?: true): T;
6
+ export declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing: false): T | undefined;
7
+ export declare function hasMetadata(obj: unknown): obj is WithMetadata<unknown>;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,OAAO,cAAMA;AAEb,iBAAiB,aAAa,GAAG;WACrB,WAAW;;AAGvB,OAAO,iBAAS,YAAY,GAAG,KAAK,aAAa,KAAK","names":["Metadata: symbol"],"sources":["../../../src/types/Metadata.ts"],"version":3,"file":"Metadata.d.ts"}
1
+ {"mappings":"AAkBA,OAAO,cAAMA;AAEb,iBAAiB,aAAa,GAAG;WACrB,WAAW;;AAGvB,OAAO,iBAAS,YAAY,GAAG,KAAK,aAAa,IAAI,iBAAiB,OAAO;AAC7E,OAAO,iBAAS,YAAY,GAAG,KAAK,aAAa,IAAI,gBAAgB,QAAQ;AAmC7E,OAAO,iBAAS,YAAY,eAAe,OAAO","names":["Metadata: symbol"],"sources":["../../../src/types/Metadata.ts"],"version":3,"file":"Metadata.d.ts"}
@@ -51,12 +51,12 @@ export interface PresenceEventDataCustom<M extends Model = Model> {
51
51
  * in a future release of pack libraries and can be safely ignored by
52
52
  * applications.
53
53
  */
54
- export interface PresenceEventUnknown {
55
- readonly type: "unknown";
54
+ export interface PresenceEventDataUnknown {
55
+ readonly type: typeof PresenceEventDataType.UNKNOWN;
56
56
  readonly rawType: string;
57
57
  readonly rawData: unknown;
58
58
  }
59
- export type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom | PresenceEventUnknown;
59
+ export type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom | PresenceEventDataUnknown;
60
60
  /**
61
61
  * An event representing a transient awareness or presence change for a user on this document.
62
62
  * The presence channel is intended for ephemeral data such as user cursors, selections, or
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,OAAO,cAAM;UACX,SAAS;UACT,UAAU;UACV,cAAc;UACd,SAAS;;AAGX,YAAY,+BACH,mCAAmC;;;;;;;AAQ5C,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;;;;;;;;AAS9C,iBAAiB,0BAA0B;UAChC,aAAa,sBAAsB;;;;;;;;;;;;;;;AAgB9C,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,WAAW,UAAU;UACrB,OAAO;;;;;;;;;;AAWlB,iBAAiB,qBAAqB;UAC3B,MAAM;UACN;UACA;;AAGX,YAAY,oBACR,2BACA,4BACA,0BACA;;;;;;;;;;;AAYJ,iBAAiB,cAAc;UACpB,QAAQ;UACR,WAAW","names":[],"sources":["../../../src/types/PresenceEvent.ts"],"version":3,"file":"PresenceEvent.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,OAAO,cAAM;UACX,SAAS;UACT,UAAU;UACV,cAAc;UACd,SAAS;;AAGX,YAAY,+BACH,mCAAmC;;;;;;;AAQ5C,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;;;;;;;;AAS9C,iBAAiB,0BAA0B;UAChC,aAAa,sBAAsB;;;;;;;;;;;;;;;AAgB9C,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,WAAW,UAAU;UACrB,OAAO;;;;;;;;;;AAWlB,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;UACnC;UACA;;AAGX,YAAY,oBACR,2BACA,4BACA,0BACA;;;;;;;;;;;AAYJ,iBAAiB,cAAc;UACpB,QAAQ;UACR,WAAW","names":[],"sources":["../../../src/types/PresenceEvent.ts"],"version":3,"file":"PresenceEvent.d.ts"}
@@ -66,11 +66,22 @@ export interface RecordRef<M extends Model = Model> {
66
66
  * });
67
67
  *
68
68
  * // Trigger the deletion
69
- * docRef.getRecords(MyModel).delete(recordRef.id);
69
+ * recordRef.delete();
70
70
  * ```
71
71
  */
72
72
  onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
73
73
  /**
74
+ * Delete the record from the document.
75
+ *
76
+ * @returns An ignorable promise that resolves when the record is deleted.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * await recordRef.delete();
81
+ * ```
82
+ */
83
+ delete(): Promise<void>;
84
+ /**
74
85
  * Set the data for the record (creating it if it doesn't exist).
75
86
  *
76
87
  * @see {onChange} to subscribe to changes to the record.
@@ -84,4 +95,18 @@ export interface RecordRef<M extends Model = Model> {
84
95
  * ```
85
96
  */
86
97
  set(record: ModelData<M>): Promise<void>;
98
+ /**
99
+ * Update specific fields of the record.
100
+ *
101
+ * @see {onChange} to subscribe to changes to the record.
102
+ *
103
+ * @param partialRecord - A partial plain object with the fields to update.
104
+ * @returns An ignorable promise that resolves when the record is published.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * await recordRef.update({ field: "new value" });
109
+ * ```
110
+ */
111
+ update(record: Partial<ModelData<M>>): Promise<void>;
87
112
  }
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,mBAAmB;AAEjC,YAAY,WAAW,SAAS;AAEhC,OAAO,cAAMA;;;;;;;;;;;;;;;;;;;;;;AAuBb,iBAAiB,UAAU,UAAU,QAAQ,OAAO;UACzC,QAAQ;UACR,IAAI;UACJ,OAAO;WACN,wBAAwB;;;;;;CAOlC,eAAe,QAAQ,UAAU;;;;;;;;;;;;;;;;;CAkBjC,SAAS,WAAW,UAAU,UAAU,IAAI,WAAW,UAAU,cAAc;;;;;;;;;;;;;;;;;CAkB/E,UAAU,WAAW,WAAW,UAAU,cAAc;;;;;;;;;;;;;;CAexD,IAAI,QAAQ,UAAU,KAAK","names":["RecordRefBrand: unique symbol"],"sources":["../../../src/types/RecordRef.ts"],"version":3,"file":"RecordRef.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,mBAAmB;AAEjC,YAAY,WAAW,SAAS;AAEhC,OAAO,cAAMA;;;;;;;;;;;;;;;;;;;;;;AAuBb,iBAAiB,UAAU,UAAU,QAAQ,OAAO;UACzC,QAAQ;UACR,IAAI;UACJ,OAAO;WACN,wBAAwB;;;;;;CAOlC,eAAe,QAAQ,UAAU;;;;;;;;;;;;;;;;;CAkBjC,SAAS,WAAW,UAAU,UAAU,IAAI,WAAW,UAAU,cAAc;;;;;;;;;;;;;;;;;CAkB/E,UAAU,WAAW,WAAW,UAAU,cAAc;;;;;;;;;;;CAYxD,UAAU;;;;;;;;;;;;;;CAeV,IAAI,QAAQ,UAAU,KAAK;;;;;;;;;;;;;;CAe3B,OAAO,QAAQ,QAAQ,UAAU,MAAM","names":["RecordRefBrand: unique symbol"],"sources":["../../../src/types/RecordRef.ts"],"version":3,"file":"RecordRef.d.ts"}