@palantir/pack.document-schema.model-types 0.31.0 → 0.33.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.
@@ -113,175 +113,6 @@ interface UnionModelMetadata<T = unknown> {
113
113
  }
114
114
  type ModelMetadata<T = unknown> = RecordModelMetadata<T> | UnionModelMetadata<T>;
115
115
 
116
- type UserId = Flavored<"pack:UserId">;
117
- declare const UserRefBrand: unique symbol;
118
- /**
119
- * A reference providing an API to interact with a user.
120
- *
121
- * @experimental
122
- */
123
- interface UserRef {
124
- readonly userId: UserId;
125
- readonly [UserRefBrand]: typeof UserRefBrand;
126
- readonly get: (force?: boolean) => Promise<unknown>;
127
- }
128
-
129
- type ActivityEventId = Flavored<"pack:EventId">;
130
- declare const ActivityEventDataType: {
131
- readonly CUSTOM_EVENT: "customEvent";
132
- readonly DOCUMENT_CREATE: "documentCreate";
133
- readonly DOCUMENT_DESCRIPTION_UPDATE: "documentDescriptionUpdate";
134
- readonly DOCUMENT_RENAME: "documentRename";
135
- readonly DOCUMENT_MANDATORY_SECURITY_UPDATE: "documentMandatorySecurityUpdate";
136
- readonly DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: "documentDiscretionarySecurityUpdate";
137
- readonly UNKNOWN: "unknown";
138
- };
139
- /**
140
- * Application specific custom activity event data, as described in a transaction edit,
141
- * using an application sdk's generated model types.
142
- *
143
- * @example
144
- * ```ts
145
- * const unsubscribe = docRef.onActivity((docRef, event) => {
146
- * console.log("Activity event:", event);
147
- * });
148
- * // Submit an edit with a description to generate an activity event.
149
- * docRef.withTransaction(() => {
150
- * // make some edits to the document here
151
- * }, {
152
- * model: MyEventModel,
153
- * data: {
154
- * myDataField: "some value",
155
- * foo: 42,
156
- * },
157
- * });
158
- * ```
159
- */
160
- interface ActivityEventDataCustom<M extends Model = Model> {
161
- readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
162
- readonly model: M;
163
- readonly eventType: string;
164
- readonly schemaVersion?: number;
165
- readonly data: ModelData<M>;
166
- }
167
- /**
168
- * Activity event emitted when a document is created.
169
- */
170
- interface ActivityEventDataDocumentCreate {
171
- readonly type: typeof ActivityEventDataType.DOCUMENT_CREATE;
172
- readonly initialMandatorySecurity: DocumentSecurityMandatory;
173
- readonly name: string;
174
- }
175
- /**
176
- * Activity event emitted when a document is renamed.
177
- */
178
- interface ActivityEventDataDocumentRename {
179
- readonly type: typeof ActivityEventDataType.DOCUMENT_RENAME;
180
- readonly previousName: string;
181
- readonly newName: string;
182
- }
183
- /**
184
- * Activity event emitted when a document's description is updated.
185
- */
186
- interface ActivityEventDataDocumentDescriptionUpdate {
187
- readonly type: typeof ActivityEventDataType.DOCUMENT_DESCRIPTION_UPDATE;
188
- readonly newDescription: string;
189
- /**
190
- * True if this is the first time the description is being set,
191
- * false if updating an existing description.
192
- */
193
- readonly isInitial: boolean;
194
- }
195
- /**
196
- * Activity event emitted when a document's discretionary security is updated.
197
- */
198
- interface ActivityEventDataDocumentDiscretionarySecurityUpdate {
199
- readonly type: typeof ActivityEventDataType.DOCUMENT_DISCRETIONARY_SECURITY_UPDATE;
200
- readonly principalType: "ALL_PRINCIPAL" | "USER";
201
- readonly previousDiscretionarySecurity?: DocumentSecurityDiscretionary;
202
- readonly newDiscretionarySecurity: DocumentSecurityDiscretionary;
203
- }
204
- /**
205
- * Activity event emitted when a document's mandatory security is updated.
206
- */
207
- interface ActivityEventDataDocumentMandatorySecurityUpdate {
208
- readonly type: typeof ActivityEventDataType.DOCUMENT_MANDATORY_SECURITY_UPDATE;
209
- readonly newClassification: readonly string[];
210
- readonly newMarkings: readonly string[];
211
- }
212
- /**
213
- * Fallback for unrecognized activity event types.
214
- *
215
- * This allows some flexibility with new event types added to the platform.
216
- * Likely unknown events represent a new platform event type and will be handled
217
- * in a future release of pack libraries and can be safely ignored by
218
- * applications.
219
- */
220
- interface ActivityEventDataUnknown {
221
- readonly type: typeof ActivityEventDataType.UNKNOWN;
222
- readonly rawType: string;
223
- readonly rawData: unknown;
224
- }
225
- type ActivityEventData = ActivityEventDataCustom | ActivityEventDataDocumentCreate | ActivityEventDataDocumentDescriptionUpdate | ActivityEventDataDocumentRename | ActivityEventDataDocumentMandatorySecurityUpdate | ActivityEventDataDocumentDiscretionarySecurityUpdate | ActivityEventDataUnknown;
226
- /**
227
- * An event representing an activity that has occurred on a document. This
228
- * includes standard document events as well as custom application-specific
229
- * events describing document edits.
230
- *
231
- * ActivityEvents are useful for building activity feeds, or notifications.
232
- */
233
- interface ActivityEvent {
234
- /** Multiple events with the same aggregationKey may be collapsed. */
235
- readonly aggregationKey: string;
236
- readonly createdBy: UserId;
237
- readonly createdInstant: number;
238
- readonly eventData: ActivityEventData;
239
- readonly eventId: ActivityEventId;
240
- readonly isRead: boolean;
241
- }
242
-
243
- /**
244
- * Reason a document channel (data, presence, activity) failed.
245
- * UI can branch on this to decide how to react.
246
- */
247
- declare const ChannelErrorCode: {
248
- /** Client's max supported schema version is below the document's operational version. */
249
- readonly CLIENT_VERSION_TOO_LOW: "clientVersionTooLow";
250
- /** Client's base revision is too far behind to sync. */
251
- readonly REVISION_TOO_OLD: "revisionTooOld";
252
- /** Document's operational version was bumped; client must re-subscribe. */
253
- readonly OPERATIONAL_VERSION_BUMPED: "operationalVersionBumped";
254
- /** Server-side internal error. */
255
- readonly INTERNAL_ERROR: "internalError";
256
- /** Local document updates were not acknowledged after repeated sends. */
257
- readonly UPDATE_NOT_ACKNOWLEDGED: "updateNotAcknowledged";
258
- /** Any other failure (transport error, or an unrecognized server code). */
259
- readonly UNKNOWN: "unknown";
260
- };
261
- type ChannelErrorCode = typeof ChannelErrorCode[keyof typeof ChannelErrorCode];
262
- /**
263
- * A typed error describing a document channel failure.
264
- */
265
- interface ChannelError {
266
- readonly code: ChannelErrorCode;
267
- /** Server-assigned id for correlating this error with backend logs. Empty for client-side errors. */
268
- readonly errorInstanceId: string;
269
- /** Optional human-readable detail (e.g. for UNKNOWN/client-side errors). */
270
- readonly message?: string;
271
- /** Requires a fresh document before editing can resume; reconnecting does not clear it. */
272
- readonly requiresRefresh?: boolean;
273
- }
274
- /**
275
- * Wraps an arbitrary thrown value (transport failure, client-side error) as a
276
- * ChannelError with code UNKNOWN.
277
- */
278
- declare function toUnknownChannelError(cause: unknown): ChannelError;
279
- /**
280
- * Maps a platform channel error (raw server code + instance id) to a domain
281
- * ChannelError. Unrecognized server codes collapse to ChannelErrorCode.UNKNOWN.
282
- */
283
- declare function toChannelError(serverCode: string, errorInstanceId: string): ChannelError;
284
-
285
116
  /** Type descriptor for a field, enabling recursive lens application. */
286
117
  type FieldTypeDescriptor = {
287
118
  kind: "primitive";
@@ -312,8 +143,10 @@ interface FieldDef {
312
143
  addedInVersion?: number;
313
144
  }
314
145
  interface UpgradeStepDef {
315
- /** Schema version this step upgrades to. Unique within a model's chain. */
146
+ /** Major version that added this step's fields, e.g. 3 for a step added in 3.2. */
316
147
  addedInVersion: number;
148
+ /** Minor version that added this step's fields, e.g. 2 for 3.2. Absent means 0. */
149
+ addedInMinorVersion?: number;
317
150
  fields: Record<string, FieldLensDef>;
318
151
  removedFields?: string[];
319
152
  }
@@ -342,7 +175,8 @@ type UpgradeRegistryMap = Record<string, UpgradeRegistryEntry>;
342
175
  * Runtime-supplied collection of forward upgrade functions. The application
343
176
  * passes a `DocumentUpgradeFns` value to the generated `DocumentModel(...)`
344
177
  * factory at boot; the factory installs it on the schema's metadata under
345
- * this loose shape: `fns[modelName][\`v${addedInVersion}\`][fieldName] -> fn`.
178
+ * this loose shape: `fns[modelName][stepKey][fieldName] -> fn`, where `stepKey` is
179
+ * `v2` for version 2.0 and `v2_1` for version 2.1.
346
180
  *
347
181
  * The generated `DocumentUpgradeFns` interface is a precisely-typed refinement
348
182
  * of this shape; both `BaseYjsDocumentService` and `applyReadLens` read from
@@ -380,6 +214,19 @@ interface DocumentSchemaMetadata {
380
214
  readonly upgradeFns?: UpgradeFns;
381
215
  }
382
216
 
217
+ type UserId = Flavored<"pack:UserId">;
218
+ declare const UserRefBrand: unique symbol;
219
+ /**
220
+ * A reference providing an API to interact with a user.
221
+ *
222
+ * @experimental
223
+ */
224
+ interface UserRef {
225
+ readonly userId: UserId;
226
+ readonly [UserRefBrand]: typeof UserRefBrand;
227
+ readonly get: (force?: boolean) => Promise<unknown>;
228
+ }
229
+
383
230
  declare const PresenceEventDataType: {
384
231
  readonly ARRIVED: "presenceArrived";
385
232
  readonly DEPARTED: "presenceDeparted";
@@ -926,28 +773,6 @@ interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
926
773
  deleteRecord<M extends Model>(ref: RecordRef<M>): Promise<void>;
927
774
  }
928
775
 
929
- type MediaId = Flavored<"MediaId">;
930
- declare const MediaRefBrand: unique symbol;
931
- /**
932
- * @experimental
933
- */
934
- interface MediaRef {
935
- readonly mediaId: MediaId;
936
- readonly [MediaRefBrand]: typeof MediaRefBrand;
937
- readonly subscribe?: (callback: unknown) => unknown;
938
- }
939
-
940
- type ObjectId = Flavored<"ObjectId">;
941
- declare const ObjectRefBrand: unique symbol;
942
- /**
943
- * @experimental
944
- */
945
- interface ObjectRef {
946
- readonly objectId: ObjectId;
947
- readonly [ObjectRefBrand]: typeof ObjectRefBrand;
948
- readonly subscribe?: (callback: unknown) => unknown;
949
- }
950
-
951
776
  /**
952
777
  * Server-generated identifier for a published Document version. Treat it as opaque and return it
953
778
  * unchanged; never parse or synthesize one. The server API calls it `ref`.
@@ -978,9 +803,220 @@ interface PublishedVersionDocumentRef<D extends DocumentSchema = DocumentSchema>
978
803
  readonly publishedVersion: PublishedVersion;
979
804
  }
980
805
 
806
+ type ActivityEventId = Flavored<"pack:EventId">;
807
+ declare const ActivityEventDataType: {
808
+ readonly CUSTOM_EVENT: "customEvent";
809
+ readonly DOCUMENT_CREATE: "documentCreate";
810
+ readonly DOCUMENT_DESCRIPTION_UPDATE: "documentDescriptionUpdate";
811
+ readonly DOCUMENT_RENAME: "documentRename";
812
+ readonly DOCUMENT_MANDATORY_SECURITY_UPDATE: "documentMandatorySecurityUpdate";
813
+ readonly DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: "documentDiscretionarySecurityUpdate";
814
+ readonly PUBLISHED_VERSION_CREATE: "publishedVersionCreate";
815
+ readonly PUBLISHED_VERSION_DELETE: "publishedVersionDelete";
816
+ readonly UNKNOWN: "unknown";
817
+ };
818
+ /**
819
+ * Application specific custom activity event data, as described in a transaction edit,
820
+ * using an application sdk's generated model types.
821
+ *
822
+ * @example
823
+ * ```ts
824
+ * const unsubscribe = docRef.onActivity((docRef, event) => {
825
+ * console.log("Activity event:", event);
826
+ * });
827
+ * // Submit an edit with a description to generate an activity event.
828
+ * docRef.withTransaction(() => {
829
+ * // make some edits to the document here
830
+ * }, {
831
+ * model: MyEventModel,
832
+ * data: {
833
+ * myDataField: "some value",
834
+ * foo: 42,
835
+ * },
836
+ * });
837
+ * ```
838
+ */
839
+ interface ActivityEventDataCustom<M extends Model = Model> {
840
+ readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
841
+ readonly model: M;
842
+ readonly eventType: string;
843
+ readonly schemaVersion?: number;
844
+ readonly data: ModelData<M>;
845
+ }
846
+ /**
847
+ * Activity event emitted when a document is created.
848
+ */
849
+ interface ActivityEventDataDocumentCreate {
850
+ readonly type: typeof ActivityEventDataType.DOCUMENT_CREATE;
851
+ readonly initialMandatorySecurity: DocumentSecurityMandatory;
852
+ readonly name: string;
853
+ }
854
+ /**
855
+ * Activity event emitted when a document is renamed.
856
+ */
857
+ interface ActivityEventDataDocumentRename {
858
+ readonly type: typeof ActivityEventDataType.DOCUMENT_RENAME;
859
+ readonly previousName: string;
860
+ readonly newName: string;
861
+ }
862
+ /**
863
+ * Activity event emitted when a document's description is updated.
864
+ */
865
+ interface ActivityEventDataDocumentDescriptionUpdate {
866
+ readonly type: typeof ActivityEventDataType.DOCUMENT_DESCRIPTION_UPDATE;
867
+ readonly newDescription: string;
868
+ /**
869
+ * True if this is the first time the description is being set,
870
+ * false if updating an existing description.
871
+ */
872
+ readonly isInitial: boolean;
873
+ }
874
+ /**
875
+ * Activity event emitted when a document's discretionary security is updated.
876
+ */
877
+ interface ActivityEventDataDocumentDiscretionarySecurityUpdate {
878
+ readonly type: typeof ActivityEventDataType.DOCUMENT_DISCRETIONARY_SECURITY_UPDATE;
879
+ readonly principalType: "ALL_PRINCIPAL" | "USER";
880
+ readonly previousDiscretionarySecurity?: DocumentSecurityDiscretionary;
881
+ readonly newDiscretionarySecurity: DocumentSecurityDiscretionary;
882
+ }
883
+ /**
884
+ * Activity event emitted when a document's mandatory security is updated.
885
+ */
886
+ interface ActivityEventDataDocumentMandatorySecurityUpdate {
887
+ readonly type: typeof ActivityEventDataType.DOCUMENT_MANDATORY_SECURITY_UPDATE;
888
+ readonly newClassification: readonly string[];
889
+ readonly newMarkings: readonly string[];
890
+ }
891
+ /**
892
+ * Activity event emitted when a published version of a document is created.
893
+ */
894
+ interface ActivityEventDataPublishedVersionCreate {
895
+ readonly type: typeof ActivityEventDataType.PUBLISHED_VERSION_CREATE;
896
+ readonly publishedVersionId: PublishedVersionId;
897
+ readonly name?: string;
898
+ readonly description?: string;
899
+ }
900
+ /**
901
+ * Activity event emitted when a published version of a document is deleted.
902
+ */
903
+ interface ActivityEventDataPublishedVersionDelete {
904
+ readonly type: typeof ActivityEventDataType.PUBLISHED_VERSION_DELETE;
905
+ readonly publishedVersionId: PublishedVersionId;
906
+ readonly name?: string;
907
+ readonly description?: string;
908
+ }
909
+ /**
910
+ * Fallback for unrecognized activity event types.
911
+ *
912
+ * This allows some flexibility with new event types added to the platform.
913
+ * Likely unknown events represent a new platform event type and will be handled
914
+ * in a future release of pack libraries and can be safely ignored by
915
+ * applications.
916
+ */
917
+ interface ActivityEventDataUnknown {
918
+ readonly type: typeof ActivityEventDataType.UNKNOWN;
919
+ readonly rawType: string;
920
+ readonly rawData: unknown;
921
+ }
922
+ type ActivityEventData = ActivityEventDataCustom | ActivityEventDataDocumentCreate | ActivityEventDataDocumentDescriptionUpdate | ActivityEventDataDocumentRename | ActivityEventDataDocumentMandatorySecurityUpdate | ActivityEventDataDocumentDiscretionarySecurityUpdate | ActivityEventDataPublishedVersionCreate | ActivityEventDataPublishedVersionDelete | ActivityEventDataUnknown;
923
+ /**
924
+ * An event representing an activity that has occurred on a document. This
925
+ * includes standard document events as well as custom application-specific
926
+ * events describing document edits.
927
+ *
928
+ * ActivityEvents are useful for building activity feeds, or notifications.
929
+ */
930
+ interface ActivityEvent {
931
+ /** Multiple events with the same aggregationKey may be collapsed. */
932
+ readonly aggregationKey: string;
933
+ readonly createdBy: UserId;
934
+ readonly createdInstant: number;
935
+ readonly eventData: ActivityEventData;
936
+ readonly eventId: ActivityEventId;
937
+ readonly isRead: boolean;
938
+ }
939
+
940
+ /**
941
+ * Reason a document channel (data, presence, activity) failed.
942
+ * UI can branch on this to decide how to react.
943
+ */
944
+ declare const ChannelErrorCode: {
945
+ /** Client's max supported schema version is below the document's operational version. */
946
+ readonly CLIENT_VERSION_TOO_LOW: "clientVersionTooLow";
947
+ /** Client's base revision is too far behind to sync. */
948
+ readonly REVISION_TOO_OLD: "revisionTooOld";
949
+ /** Document's operational version was bumped; client must re-subscribe. */
950
+ readonly OPERATIONAL_VERSION_BUMPED: "operationalVersionBumped";
951
+ /** Server-side internal error. */
952
+ readonly INTERNAL_ERROR: "internalError";
953
+ /** Local document updates were not acknowledged after repeated sends. */
954
+ readonly UPDATE_NOT_ACKNOWLEDGED: "updateNotAcknowledged";
955
+ /** Any other failure (transport error, or an unrecognized server code). */
956
+ readonly UNKNOWN: "unknown";
957
+ };
958
+ type ChannelErrorCode = typeof ChannelErrorCode[keyof typeof ChannelErrorCode];
959
+ /**
960
+ * A typed error describing a document channel failure.
961
+ */
962
+ interface ChannelError {
963
+ readonly code: ChannelErrorCode;
964
+ /** Server-assigned id for correlating this error with backend logs. Empty for client-side errors. */
965
+ readonly errorInstanceId: string;
966
+ /** Optional human-readable detail (e.g. for UNKNOWN/client-side errors). */
967
+ readonly message?: string;
968
+ /** Requires a fresh document before editing can resume; reconnecting does not clear it. */
969
+ readonly requiresRefresh?: boolean;
970
+ }
971
+ /**
972
+ * Wraps an arbitrary thrown value (transport failure, client-side error) as a
973
+ * ChannelError with code UNKNOWN.
974
+ */
975
+ declare function toUnknownChannelError(cause: unknown): ChannelError;
976
+ /**
977
+ * Maps a platform channel error (raw server code + instance id) to a domain
978
+ * ChannelError. Unrecognized server codes collapse to ChannelErrorCode.UNKNOWN.
979
+ */
980
+ declare function toChannelError(serverCode: string, errorInstanceId: string): ChannelError;
981
+
982
+ type MediaId = Flavored<"MediaId">;
983
+ declare const MediaRefBrand: unique symbol;
984
+ /**
985
+ * @experimental
986
+ */
987
+ interface MediaRef {
988
+ readonly mediaId: MediaId;
989
+ readonly [MediaRefBrand]: typeof MediaRefBrand;
990
+ readonly subscribe?: (callback: unknown) => unknown;
991
+ }
992
+
993
+ type ObjectId = Flavored<"ObjectId">;
994
+ declare const ObjectRefBrand: unique symbol;
995
+ /**
996
+ * @experimental
997
+ */
998
+ interface ObjectRef {
999
+ readonly objectId: ObjectId;
1000
+ readonly [ObjectRefBrand]: typeof ObjectRefBrand;
1001
+ readonly subscribe?: (callback: unknown) => unknown;
1002
+ }
1003
+
981
1004
  /** Identifies an arbitrary platform resource by RID. */
982
1005
  type ResourceRid = Flavored<"ResourceRid">;
983
1006
 
1007
+ /** The discriminant value of a union variant this SDK doesn't know. Reserved: no real variant can use it. */
1008
+ declare const UNKNOWN_UNION_VARIANT = "unknown";
1009
+ /**
1010
+ * A union value whose variant this SDK doesn't know, e.g. one added by a newer version of the app.
1011
+ * Every generated union includes this case. `rawValue` is the stored value, kept as-is: saving a
1012
+ * record or list that contains it writes it back unchanged.
1013
+ */
1014
+ type UnknownUnionVariant<D extends string> = {
1015
+ readonly [K in D]: typeof UNKNOWN_UNION_VARIANT;
1016
+ } & {
1017
+ readonly rawValue?: unknown;
1018
+ };
1019
+
984
1020
  /**
985
1021
  * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.
986
1022
  *
@@ -1122,4 +1158,4 @@ declare namespace PresenceEvents {
1122
1158
  export { PresenceEvents_isArrived as isArrived, PresenceEvents_isCustom as isCustom, PresenceEvents_isDeparted as isDeparted, PresenceEvents_isUnknown as isUnknown };
1123
1159
  }
1124
1160
 
1125
- export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, type ActivityEventDataDocumentCreate, type ActivityEventDataDocumentDescriptionUpdate, type ActivityEventDataDocumentDiscretionarySecurityUpdate, type ActivityEventDataDocumentMandatorySecurityUpdate, type ActivityEventDataDocumentRename, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, ActivityEvents, type ChannelError, ChannelErrorCode, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentOperation, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentSecurity, type DocumentSecurityDiscretionary, type DocumentSecurityMandatory, type DocumentState, type EditDescription, ExternalRefType, type FieldDef, type FieldLensDef, type FieldTypeDescriptor, 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 PresencePublishOptions, type PresenceSubscriptionOptions, type PublishedVersion, type PublishedVersionDocumentRef, type PublishedVersionId, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, RecordInvalidError, type RecordModel, type RecordRef, RecordRefBrand, type RecordValidationError, type RecordValidationIssue, type ResourceRid, type UnionModel, type UnionUpgradeRegistry, type Unsubscribe, type UpgradeFns, type UpgradeRegistry, type UpgradeRegistryEntry, type UpgradeRegistryMap, type UpgradeStepDef, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata, hasMetadata, toChannelError, toUnknownChannelError };
1161
+ export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, type ActivityEventDataDocumentCreate, type ActivityEventDataDocumentDescriptionUpdate, type ActivityEventDataDocumentDiscretionarySecurityUpdate, type ActivityEventDataDocumentMandatorySecurityUpdate, type ActivityEventDataDocumentRename, type ActivityEventDataPublishedVersionCreate, type ActivityEventDataPublishedVersionDelete, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, ActivityEvents, type ChannelError, ChannelErrorCode, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentOperation, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentSecurity, type DocumentSecurityDiscretionary, type DocumentSecurityMandatory, type DocumentState, type EditDescription, ExternalRefType, type FieldDef, type FieldLensDef, type FieldTypeDescriptor, 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 PresencePublishOptions, type PresenceSubscriptionOptions, type PublishedVersion, type PublishedVersionDocumentRef, type PublishedVersionId, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, RecordInvalidError, type RecordModel, type RecordRef, RecordRefBrand, type RecordValidationError, type RecordValidationIssue, type ResourceRid, UNKNOWN_UNION_VARIANT, type UnionModel, type UnionUpgradeRegistry, type UnknownUnionVariant, type Unsubscribe, type UpgradeFns, type UpgradeRegistry, type UpgradeRegistryEntry, type UpgradeRegistryMap, type UpgradeStepDef, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata, hasMetadata, toChannelError, toUnknownChannelError };
@@ -14,6 +14,8 @@ var ActivityEventDataType = {
14
14
  DOCUMENT_RENAME: "documentRename",
15
15
  DOCUMENT_MANDATORY_SECURITY_UPDATE: "documentMandatorySecurityUpdate",
16
16
  DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: "documentDiscretionarySecurityUpdate",
17
+ PUBLISHED_VERSION_CREATE: "publishedVersionCreate",
18
+ PUBLISHED_VERSION_DELETE: "publishedVersionDelete",
17
19
  UNKNOWN: "unknown"
18
20
  };
19
21
 
@@ -123,6 +125,9 @@ var RecordInvalidError = class extends Error {
123
125
  }
124
126
  };
125
127
 
128
+ // src/types/UnknownUnionVariant.ts
129
+ var UNKNOWN_UNION_VARIANT = "unknown";
130
+
126
131
  // src/types/UserRef.ts
127
132
  var UserRefBrand = Symbol("pack:UserRef");
128
133
 
@@ -171,6 +176,6 @@ function isUnknown2(eventData) {
171
176
  return eventData.type === PresenceEventDataType.UNKNOWN;
172
177
  }
173
178
 
174
- export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, ChannelErrorCode, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordInvalidError, RecordRefBrand, UserRefBrand, getMetadata, hasMetadata, toChannelError, toUnknownChannelError };
179
+ export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, ChannelErrorCode, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordInvalidError, RecordRefBrand, UNKNOWN_UNION_VARIANT, UserRefBrand, getMetadata, hasMetadata, toChannelError, toUnknownChannelError };
175
180
  //# sourceMappingURL=index.js.map
176
181
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/ChannelError.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/RecordValidation.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,eAAA,EAAiB,gBAAA;AAAA,EACjB,2BAAA,EAA6B,2BAAA;AAAA,EAC7B,eAAA,EAAiB,gBAAA;AAAA,EACjB,kCAAA,EAAoC,iCAAA;AAAA,EACpC,sCAAA,EAAwC,qCAAA;AAAA,EACxC,OAAA,EAAS;AACX;;;ACJO,IAAM,gBAAA,GAAmB;AAAA;AAAA,EAE9B,sBAAA,EAAwB,qBAAA;AAAA;AAAA,EAExB,gBAAA,EAAkB,gBAAA;AAAA;AAAA,EAElB,0BAAA,EAA4B,0BAAA;AAAA;AAAA,EAE5B,cAAA,EAAgB,eAAA;AAAA;AAAA,EAEhB,uBAAA,EAAyB,uBAAA;AAAA;AAAA,EAEzB,OAAA,EAAS;AACX;AAUO,SAAS,sBAAsB,KAAA,EAAO;AAC3C,EAAA,OAAO;AAAA,IACL,MAAM,gBAAA,CAAiB,OAAA;AAAA,IACvB,eAAA,EAAiB,EAAA;AAAA,IACjB,SAAS,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,OAAA,GAAU,OAAO,KAAK;AAAA,GAChE;AACF;AAGA,IAAM,qBAAA,GAAwB;AAAA,EAC5B,wBAAwB,gBAAA,CAAiB,sBAAA;AAAA,EACzC,kBAAkB,gBAAA,CAAiB,gBAAA;AAAA,EACnC,0CAA0C,gBAAA,CAAiB,0BAAA;AAAA,EAC3D,gBAAgB,gBAAA,CAAiB;AACnC,CAAA;AAMO,SAAS,cAAA,CAAe,YAAY,eAAA,EAAiB;AAC1D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA,CAAsB,UAAU,CAAA,IAAK,gBAAA,CAAiB,OAAA;AAAA,IAC5D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,SAAS,qBAAA,CAAsB,OAAA;AAClD;;;AC3FA,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 DOCUMENT_CREATE: \"documentCreate\",\n DOCUMENT_DESCRIPTION_UPDATE: \"documentDescriptionUpdate\",\n DOCUMENT_RENAME: \"documentRename\",\n DOCUMENT_MANDATORY_SECURITY_UPDATE: \"documentMandatorySecurityUpdate\",\n DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: \"documentDiscretionarySecurityUpdate\",\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/**\n * Activity event emitted when a document is created.\n */\n\n/**\n * Activity event emitted when a document is renamed.\n */\n\n/**\n * Activity event emitted when a document's description is updated.\n */\n\n/**\n * Activity event emitted when a document's discretionary security is updated.\n */\n\n/**\n * Activity event emitted when a document's mandatory security is updated.\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 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 * Reason a document channel (data, presence, activity) failed.\n * UI can branch on this to decide how to react.\n */\nexport const ChannelErrorCode = {\n /** Client's max supported schema version is below the document's operational version. */\n CLIENT_VERSION_TOO_LOW: \"clientVersionTooLow\",\n /** Client's base revision is too far behind to sync. */\n REVISION_TOO_OLD: \"revisionTooOld\",\n /** Document's operational version was bumped; client must re-subscribe. */\n OPERATIONAL_VERSION_BUMPED: \"operationalVersionBumped\",\n /** Server-side internal error. */\n INTERNAL_ERROR: \"internalError\",\n /** Local document updates were not acknowledged after repeated sends. */\n UPDATE_NOT_ACKNOWLEDGED: \"updateNotAcknowledged\",\n /** Any other failure (transport error, or an unrecognized server code). */\n UNKNOWN: \"unknown\"\n};\n\n/**\n * A typed error describing a document channel failure.\n */\n\n/**\n * Wraps an arbitrary thrown value (transport failure, client-side error) as a\n * ChannelError with code UNKNOWN.\n */\nexport function toUnknownChannelError(cause) {\n return {\n code: ChannelErrorCode.UNKNOWN,\n errorInstanceId: \"\",\n message: cause instanceof Error ? cause.message : String(cause)\n };\n}\n\n// Server (platform) error code strings → domain ChannelErrorCode.\nconst SERVER_ERROR_CODE_MAP = {\n CLIENT_VERSION_TOO_LOW: ChannelErrorCode.CLIENT_VERSION_TOO_LOW,\n REVISION_TOO_OLD: ChannelErrorCode.REVISION_TOO_OLD,\n DOCUMENT_TYPE_OPERATIONAL_VERSION_BUMPED: ChannelErrorCode.OPERATIONAL_VERSION_BUMPED,\n INTERNAL_ERROR: ChannelErrorCode.INTERNAL_ERROR\n};\n\n/**\n * Maps a platform channel error (raw server code + instance id) to a domain\n * ChannelError. Unrecognized server codes collapse to ChannelErrorCode.UNKNOWN.\n */\nexport function toChannelError(serverCode, errorInstanceId) {\n return {\n code: SERVER_ERROR_CODE_MAP[serverCode] ?? ChannelErrorCode.UNKNOWN,\n errorInstanceId\n };\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\n/**\n * Options for publishing custom presence events.\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. The one exception is a `PublishedVersionDocumentRef`: it has\n * the same id as its live draft but different data, so the id alone can't tell\n * them apart. Use the ref you're given, since a ref made from its id is the live\n * draft. If you store data per document (for example in a Map or as a React key),\n * include `publishedVersion.id` in the key.\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 RESOURCE_REF: \"resourceRef\",\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 * // Create a record via the version-narrowed setRecord on DocumentRef.\n * await docRef.setRecord(MyModel, \"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Then get the ref back.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2026 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 single schema-validation failure within a record snapshot.\n */\n\n/**\n * Describes why a record's stored data failed schema validation against its\n * model.\n *\n * Delivered to {@link RecordRef.onInvalid} subscribers and queryable per\n * document via `getInvalidRecords`. A record can become invalid when the\n * document's persisted state does not match what the model's schema promises\n * (for example, after a partial write left the document corrupted).\n */\n\n/**\n * Error used to reject promise-based snapshot reads (e.g.\n * {@link RecordRef.getSnapshot}) when the record exists but its data fails\n * schema validation.\n */\nexport class RecordInvalidError extends Error {\n validation;\n constructor(validation) {\n super(validation.message);\n this.name = \"RecordInvalidError\";\n this.validation = validation;\n }\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 */\n/**\n * @deprecated Narrow the document ref by version and use\n * `doc.describeEdit(model, data)` instead.\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}"]}
1
+ {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/ChannelError.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/RecordValidation.ts","../../src/types/UnknownUnionVariant.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,eAAA,EAAiB,gBAAA;AAAA,EACjB,2BAAA,EAA6B,2BAAA;AAAA,EAC7B,eAAA,EAAiB,gBAAA;AAAA,EACjB,kCAAA,EAAoC,iCAAA;AAAA,EACpC,sCAAA,EAAwC,qCAAA;AAAA,EACxC,wBAAA,EAA0B,wBAAA;AAAA,EAC1B,wBAAA,EAA0B,wBAAA;AAAA,EAC1B,OAAA,EAAS;AACX;;;ACNO,IAAM,gBAAA,GAAmB;AAAA;AAAA,EAE9B,sBAAA,EAAwB,qBAAA;AAAA;AAAA,EAExB,gBAAA,EAAkB,gBAAA;AAAA;AAAA,EAElB,0BAAA,EAA4B,0BAAA;AAAA;AAAA,EAE5B,cAAA,EAAgB,e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AAA,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 DOCUMENT_CREATE: \"documentCreate\",\n DOCUMENT_DESCRIPTION_UPDATE: \"documentDescriptionUpdate\",\n DOCUMENT_RENAME: \"documentRename\",\n DOCUMENT_MANDATORY_SECURITY_UPDATE: \"documentMandatorySecurityUpdate\",\n DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: \"documentDiscretionarySecurityUpdate\",\n PUBLISHED_VERSION_CREATE: \"publishedVersionCreate\",\n PUBLISHED_VERSION_DELETE: \"publishedVersionDelete\",\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/**\n * Activity event emitted when a document is created.\n */\n\n/**\n * Activity event emitted when a document is renamed.\n */\n\n/**\n * Activity event emitted when a document's description is updated.\n */\n\n/**\n * Activity event emitted when a document's discretionary security is updated.\n */\n\n/**\n * Activity event emitted when a document's mandatory security is updated.\n */\n\n/**\n * Activity event emitted when a published version of a document is created.\n */\n\n/**\n * Activity event emitted when a published version of a document is deleted.\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 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 * Reason a document channel (data, presence, activity) failed.\n * UI can branch on this to decide how to react.\n */\nexport const ChannelErrorCode = {\n /** Client's max supported schema version is below the document's operational version. */\n CLIENT_VERSION_TOO_LOW: \"clientVersionTooLow\",\n /** Client's base revision is too far behind to sync. */\n REVISION_TOO_OLD: \"revisionTooOld\",\n /** Document's operational version was bumped; client must re-subscribe. */\n OPERATIONAL_VERSION_BUMPED: \"operationalVersionBumped\",\n /** Server-side internal error. */\n INTERNAL_ERROR: \"internalError\",\n /** Local document updates were not acknowledged after repeated sends. */\n UPDATE_NOT_ACKNOWLEDGED: \"updateNotAcknowledged\",\n /** Any other failure (transport error, or an unrecognized server code). */\n UNKNOWN: \"unknown\"\n};\n\n/**\n * A typed error describing a document channel failure.\n */\n\n/**\n * Wraps an arbitrary thrown value (transport failure, client-side error) as a\n * ChannelError with code UNKNOWN.\n */\nexport function toUnknownChannelError(cause) {\n return {\n code: ChannelErrorCode.UNKNOWN,\n errorInstanceId: \"\",\n message: cause instanceof Error ? cause.message : String(cause)\n };\n}\n\n// Server (platform) error code strings → domain ChannelErrorCode.\nconst SERVER_ERROR_CODE_MAP = {\n CLIENT_VERSION_TOO_LOW: ChannelErrorCode.CLIENT_VERSION_TOO_LOW,\n REVISION_TOO_OLD: ChannelErrorCode.REVISION_TOO_OLD,\n DOCUMENT_TYPE_OPERATIONAL_VERSION_BUMPED: ChannelErrorCode.OPERATIONAL_VERSION_BUMPED,\n INTERNAL_ERROR: ChannelErrorCode.INTERNAL_ERROR\n};\n\n/**\n * Maps a platform channel error (raw server code + instance id) to a domain\n * ChannelError. Unrecognized server codes collapse to ChannelErrorCode.UNKNOWN.\n */\nexport function toChannelError(serverCode, errorInstanceId) {\n return {\n code: SERVER_ERROR_CODE_MAP[serverCode] ?? ChannelErrorCode.UNKNOWN,\n errorInstanceId\n };\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\n/**\n * Options for publishing custom presence events.\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. The one exception is a `PublishedVersionDocumentRef`: it has\n * the same id as its live draft but different data, so the id alone can't tell\n * them apart. Use the ref you're given, since a ref made from its id is the live\n * draft. If you store data per document (for example in a Map or as a React key),\n * include `publishedVersion.id` in the key.\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 RESOURCE_REF: \"resourceRef\",\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 * // Create a record via the version-narrowed setRecord on DocumentRef.\n * await docRef.setRecord(MyModel, \"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Then get the ref back.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2026 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 single schema-validation failure within a record snapshot.\n */\n\n/**\n * Describes why a record's stored data failed schema validation against its\n * model.\n *\n * Delivered to {@link RecordRef.onInvalid} subscribers and queryable per\n * document via `getInvalidRecords`. A record can become invalid when the\n * document's persisted state does not match what the model's schema promises\n * (for example, after a partial write left the document corrupted).\n */\n\n/**\n * Error used to reject promise-based snapshot reads (e.g.\n * {@link RecordRef.getSnapshot}) when the record exists but its data fails\n * schema validation.\n */\nexport class RecordInvalidError extends Error {\n validation;\n constructor(validation) {\n super(validation.message);\n this.name = \"RecordInvalidError\";\n this.validation = validation;\n }\n}","/*\n * Copyright 2026 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/** The discriminant value of a union variant this SDK doesn't know. Reserved: no real variant can use it. */\nexport const UNKNOWN_UNION_VARIANT = \"unknown\";\n\n/**\n * A union value whose variant this SDK doesn't know, e.g. one added by a newer version of the app.\n * Every generated union includes this case. `rawValue` is the stored value, kept as-is: saving a\n * record or list that contains it writes it back unchanged.\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 */\n/**\n * @deprecated Narrow the document ref by version and use\n * `doc.describeEdit(model, data)` instead.\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}"]}