@palantir/pack.document-schema.model-types 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) 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 +39 -0
  8. package/build/browser/index.js.map +1 -1
  9. package/build/cjs/index.cjs.map +1 -1
  10. package/build/cjs/index.d.cts +65 -71
  11. package/build/esm/index.js.map +1 -1
  12. package/build/types/index.d.ts +0 -1
  13. package/build/types/index.d.ts.map +1 -1
  14. package/build/types/types/ActivityEvent.d.ts +1 -0
  15. package/build/types/types/ActivityEvent.d.ts.map +1 -1
  16. package/build/types/types/DocumentMetadata.d.ts +2 -3
  17. package/build/types/types/DocumentMetadata.d.ts.map +1 -1
  18. package/build/types/types/DocumentRef.d.ts +40 -7
  19. package/build/types/types/DocumentRef.d.ts.map +1 -1
  20. package/build/types/types/Model.d.ts +1 -0
  21. package/build/types/types/Model.d.ts.map +1 -1
  22. package/build/types/types/PresenceEvent.d.ts +1 -0
  23. package/build/types/types/PresenceEvent.d.ts.map +1 -1
  24. package/build/types/types/RecordCollectionRef.d.ts +4 -15
  25. package/build/types/types/RecordCollectionRef.d.ts.map +1 -1
  26. package/build/types/types/RecordRef.d.ts +8 -32
  27. package/build/types/types/RecordRef.d.ts.map +1 -1
  28. package/build/types/types/UpgradeLens.d.ts +5 -6
  29. package/build/types/types/UpgradeLens.d.ts.map +1 -1
  30. package/build/types/utils/ActivityEvents.d.ts +6 -2
  31. package/build/types/utils/ActivityEvents.d.ts.map +1 -1
  32. package/package.json +2 -2
  33. package/src/index.ts +0 -1
  34. package/src/types/ActivityEvent.ts +1 -0
  35. package/src/types/DocumentMetadata.ts +2 -3
  36. package/src/types/DocumentRef.ts +47 -9
  37. package/src/types/Model.ts +1 -0
  38. package/src/types/PresenceEvent.ts +1 -0
  39. package/src/types/RecordCollectionRef.ts +4 -15
  40. package/src/types/RecordRef.ts +8 -34
  41. package/src/types/UpgradeLens.ts +5 -7
  42. package/src/utils/ActivityEvents.ts +6 -2
  43. package/build/types/types/JsonValue.d.ts +0 -8
  44. package/build/types/types/JsonValue.d.ts.map +0 -1
  45. package/src/types/JsonValue.ts +0 -28
@@ -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","../../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;;;ACAO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACRlD,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;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O,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 * 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.\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}"]}
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,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;;;ACAO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACRlD,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;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KAAU,KAAA;AACtF;AAcO,SAAS,UAAU,SAAA,EAAW;AACnC,EAAA,OAAO,SAAA,CAAU,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 * 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.\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 * // 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 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}"]}
@@ -4,7 +4,6 @@ export type { DiscretionaryPrincipal, DiscretionaryPrincipal_All, DiscretionaryP
4
4
  export { DocumentRefBrand } from "./types/DocumentRef.js";
5
5
  export type { DocumentId, DocumentRef, PresencePublishOptions, PresenceSubscriptionOptions } from "./types/DocumentRef.js";
6
6
  export type { DocumentSchema, DocumentSchemaMetadata, DocumentState } from "./types/DocumentSchema.js";
7
- export type { JsonValue } from "./types/JsonValue.js";
8
7
  export { MediaRefBrand } from "./types/MediaRef.js";
9
8
  export type { MediaId, MediaRef } from "./types/MediaRef.js";
10
9
  export { getMetadata, hasMetadata, Metadata } from "./types/Metadata.js";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,iCACA,4CACA,sDACA,kDACA,iCACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,kBACA,mBACA,kBACA,+BACA,iCACK;AACP,SAAS,wBAAwB;AACjC,cACE,YACA,aACA,wBACA,mCACK;AACP,cACE,gBACA,wBACA,qBACK;AACP,cAAc,iBAAiB;AAC/B,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,aAAa,gBAAgB;AACnD,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cACE,iBACA,OACA,WACA,eACA,aACA,kBACK;AACP,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,cACE,UACA,cACA,qBACA,sBACA,YACA,iBACA,sBACA,oBACA,sBACK;AACP,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe;AACrC,YAAY,oBAAoB;AAChC,YAAY,oBAAoB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
1
+ {"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,iCACA,4CACA,sDACA,kDACA,iCACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,kBACA,mBACA,kBACA,+BACA,iCACK;AACP,SAAS,wBAAwB;AACjC,cACE,YACA,aACA,wBACA,mCACK;AACP,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,aAAa,gBAAgB;AACnD,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cACE,iBACA,OACA,WACA,eACA,aACA,kBACK;AACP,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,cACE,UACA,cACA,qBACA,sBACA,YACA,iBACA,sBACA,oBACA,sBACK;AACP,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe;AACrC,YAAY,oBAAoB;AAChC,YAAY,oBAAoB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -37,6 +37,7 @@ export interface ActivityEventDataCustom<M extends Model = Model> {
37
37
  readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
38
38
  readonly model: M;
39
39
  readonly eventType: string;
40
+ readonly schemaVersion?: number;
40
41
  readonly data: ModelData<M>;
41
42
  }
42
43
  /**
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cACE,+BACA,iCACK;AACP,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,iBAAiB;UACjB,6BAA6B;UAC7B,iBAAiB;UACjB,oCAAoC;UACpC,wCAAwC;UACxC,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP;UACA,MAAM,UAAU;;;;;AAM3B,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC,0BAA0B;UAC1B;;;;;AAMX,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC;UACA;;;;;AAMX,iBAAiB,2CAA2C;UACjD,aAAa,sBAAsB;UACnC;;;;;UAKA;;;;;AAMX,iBAAiB,qDAAqD;UAC3D,aAAa,sBAAsB;UACnC,eAAe,kBAAkB;UACjC,gCAAgC;UAChC,0BAA0B;;;;;AAMrC,iBAAiB,iDAAiD;UACvD,aAAa,sBAAsB;UACnC;UACA;;;;;;;;;;AAWX,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;UACnC;UACA;;AAGX,YAAY,oBACR,0BACA,kCACA,6CACA,kCACA,mDACA,uDACA;;;;;;;;AASJ,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,cACE,+BACA,iCACK;AACP,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,iBAAiB;UACjB,6BAA6B;UAC7B,iBAAiB;UACjB,oCAAoC;UACpC,wCAAwC;UACxC,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP;UACA;UACA,MAAM,UAAU;;;;;AAM3B,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC,0BAA0B;UAC1B;;;;;AAMX,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC;UACA;;;;;AAMX,iBAAiB,2CAA2C;UACjD,aAAa,sBAAsB;UACnC;;;;;UAKA;;;;;AAMX,iBAAiB,qDAAqD;UAC3D,aAAa,sBAAsB;UACnC,eAAe,kBAAkB;UACjC,gCAAgC;UAChC,0BAA0B;;;;;AAMrC,iBAAiB,iDAAiD;UACvD,aAAa,sBAAsB;UACnC;UACA;;;;;;;;;;AAWX,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;UACnC;UACA;;AAGX,YAAY,oBACR,0BACA,kCACA,6CACA,kCACA,mDACA,uDACA;;;;;;;;AASJ,iBAAiB,cAAc;;UAEpB;UACA,WAAW;UACX;UACA,WAAW;UACX,SAAS;UACT","names":[],"sources":["../../../src/types/ActivityEvent.ts"],"version":3,"file":"ActivityEvent.d.ts"}
@@ -34,10 +34,9 @@ export interface DocumentMetadata {
34
34
  readonly ontologyRid: string;
35
35
  /**
36
36
  * The schema version this document is currently operating at.
37
- * All connected clients must read and write at this version.
38
- * Set by the backend; only increases (one-way ratchet).
37
+ * Calculated and set by the backend; only increases (one-way ratchet).
39
38
  */
40
- readonly schemaVersion?: number;
39
+ readonly operationalVersion?: number;
41
40
  readonly security: DocumentSecurity;
42
41
  readonly updatedBy?: string;
43
42
  readonly updatedTime?: string;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,iBAAiB,2BAA2B;CAC1C,QAAQ;;AAEV,iBAAiB,8BAA8B;CAC7C,QAAQ;CACR;;AAEF,iBAAiB,+BAA+B;CAC9C;CACA,QAAQ;;AAGV,YAAY,yBACR,6BACA,iCACA;AAEJ,iBAAiB,8BAA8B;UACpC,mBAAmB;UACnB,kBAAkB;UAClB,mBAAmB;;AAG9B,iBAAiB,0BAA0B;UAChC;UACA;;AAGX,iBAAiB,iBAAiB;UACvB,eAAe;UACf,WAAW;;AAGtB,YAAY,oBAAoB,SAAS,SAAS,QAAQ;AAE1D,iBAAiB,iBAAiB;UACvB;UACA;UACA;UACA;UACA;UACA,sBAAsB;UACtB;;;;;;UAMA;UACA,UAAU;UACV;UACA","names":[],"sources":["../../../src/types/DocumentMetadata.ts"],"version":3,"file":"DocumentMetadata.d.ts"}
1
+ {"mappings":"AAgBA,iBAAiB,2BAA2B;CAC1C,QAAQ;;AAEV,iBAAiB,8BAA8B;CAC7C,QAAQ;CACR;;AAEF,iBAAiB,+BAA+B;CAC9C;CACA,QAAQ;;AAGV,YAAY,yBACR,6BACA,iCACA;AAEJ,iBAAiB,8BAA8B;UACpC,mBAAmB;UACnB,kBAAkB;UAClB,mBAAmB;;AAG9B,iBAAiB,0BAA0B;UAChC;UACA;;AAGX,iBAAiB,iBAAiB;UACvB,eAAe;UACf,WAAW;;AAGtB,YAAY,oBAAoB,SAAS,SAAS,QAAQ;AAE1D,iBAAiB,iBAAiB;UACvB;UACA;UACA;UACA;UACA;UACA,sBAAsB;UACtB;;;;;UAKA;UACA,UAAU;UACV;UACA","names":[],"sources":["../../../src/types/DocumentMetadata.ts"],"version":3,"file":"DocumentMetadata.d.ts"}
@@ -2,9 +2,10 @@ import type { Flavored } from "@palantir/pack.core";
2
2
  import type { ActivityEvent } from "./ActivityEvent.js";
3
3
  import type { DocumentMetadata } from "./DocumentMetadata.js";
4
4
  import type { DocumentSchema, DocumentState } from "./DocumentSchema.js";
5
- import type { EditDescription, Model, ModelData } from "./Model.js";
5
+ import type { EditDescription, Model } from "./Model.js";
6
6
  import type { PresenceEvent } from "./PresenceEvent.js";
7
7
  import type { RecordCollectionRef } from "./RecordCollectionRef.js";
8
+ import type { RecordId, RecordRef } from "./RecordRef.js";
8
9
  import type { Unsubscribe } from "./Unsubscribe.js";
9
10
  export type DocumentId = Flavored<"DocumentId">;
10
11
  /**
@@ -111,6 +112,10 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
111
112
  /**
112
113
  * Subscribe to metadata changes for the document.
113
114
  *
115
+ * In Foundry, metadata update events are sent for metadata edits/deletion.
116
+ * Name and description changes are not identified in the event payload, and
117
+ * operational-version-only changes do not currently trigger this callback.
118
+ *
114
119
  * @returns An unsubscribe function.
115
120
  * @example
116
121
  * ```ts
@@ -144,10 +149,7 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
144
149
  * }
145
150
  * }, { ignoreSelfUpdates: true });
146
151
  *
147
- * // Broadcast a presence update
148
- * docRef.updateCustomPresence(MyPresenceModel, {
149
- * cursorPosition: [42, 7],
150
- * });
152
+ * // Broadcast a presence update after narrowing to a generated versioned doc ref.
151
153
  *
152
154
  * // Later, to unsubscribe:
153
155
  * unsubscribe();
@@ -188,7 +190,14 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
188
190
  * @param eventData The new presence data for the model.
189
191
  * @param options Options for presence publishing.
190
192
  */
191
- updateCustomPresence<M extends Model = Model>(model: M, eventData: ModelData<M>, options?: PresencePublishOptions): void;
193
+ updateCustomPresence(model: Model, eventData: never, options?: PresencePublishOptions): void;
194
+ /**
195
+ * Create a custom activity edit description.
196
+ *
197
+ * The data parameter is `never` on the base interface — narrow to a
198
+ * version-specific type before calling this method.
199
+ */
200
+ describeEdit(model: Model, data: never): EditDescription;
192
201
  /**
193
202
  * Execute one or more document edits within a transaction, optionally providing
194
203
  * a description of the edit for activity tracking.
@@ -212,10 +221,34 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
212
221
  * const myRecords = docRef.getRecords(MyModel);
213
222
  * myRecords.set("record-1", { field: "new value" });
214
223
  * myRecords.delete("record-2");
215
- * }, ActivityEvents.describeEdit(MyEditEventModel, {
224
+ * }, doc.describeEdit(MyEditEventModel, {
216
225
  * summary: "Updated record-1 and deleted record-2",
217
226
  * }));
218
227
  * ```
219
228
  */
220
229
  withTransaction(fn: () => void, description?: EditDescription): void;
230
+ /**
231
+ * The document's current schema operational version.
232
+ *
233
+ * The backend determines the highest schema version this document currently
234
+ * accepts. This may change during a session.
235
+ */
236
+ readonly version: number;
237
+ /**
238
+ * Update fields on an existing record.
239
+ *
240
+ * The data parameter is `never` on the base interface — narrow the ref to a
241
+ * version-specific type (via the generated SDK's `asVersioned` +
242
+ * `switch (doc.version)`) before calling this method.
243
+ */
244
+ updateRecord(ref: RecordRef, data: never): Promise<void>;
245
+ /**
246
+ * Create or replace a record in a collection.
247
+ *
248
+ * The data parameter is `never` on the base interface — narrow to a
249
+ * version-specific type before calling this method.
250
+ */
251
+ setRecord(model: Model, id: RecordId, data: never): Promise<void>;
252
+ /** Delete a record. Version-agnostic — callable without narrowing. */
253
+ deleteRecord<M extends Model>(ref: RecordRef<M>): Promise<void>;
221
254
  }
@@ -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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B;;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;;;;;;;;;;;;;;;;;;;CAoBH,iBACE,WAAW,QAAQ,YAAY,IAAI,UAAU,4BAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BH,WACE,WAAW,QAAQ,YAAY,IAAI,OAAO,wBAC1C,UAAU,8BACT;;;;;;;;;;;;;;;;;;;CAoBH,cACE,WAAW,QAAQ,YAAY,cAC9B;;;;;;;;;;;;;;;;CAiBH,qBACE,OAAO,OACP,kBACA,UAAU;;;;;;;CASZ,aAAa,OAAO,OAAO,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BzC,gBAAgB,gBAAgB,cAAc;;;;;;;UAQrC;;;;;;;;CAST,aAAa,KAAK,WAAW,cAAc;;;;;;;CAQ3C,UAAU,OAAO,OAAO,IAAI,UAAU,cAAc;;CAGpD,aAAa,UAAU,OAAO,KAAK,UAAU,KAAK","names":["DocumentRefBrand: unique symbol"],"sources":["../../../src/types/DocumentRef.ts"],"version":3,"file":"DocumentRef.d.ts"}
@@ -28,6 +28,7 @@ export type ModelData<M extends Model> = M["__type"];
28
28
  export interface EditDescription<M extends Model = Model> {
29
29
  readonly data: ModelData<M>;
30
30
  readonly model: M;
31
+ readonly schemaVersion?: number;
31
32
  }
32
33
  export declare const ExternalRefType: {
33
34
  readonly DOC_REF: "docRef";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,eAAe;AAC7B,cAAc,oBAAoB;;;;;;AAQlC,iBAAiB;CACf;CACA,UAAU,QAAQ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ACZ,UAAU;;AAGZ,YAAY,yBAAyB,6BAA6B;AAElE,iBAAiB,oBAAoB,aAAa;;;;UAIvC,wBAAwB,SAAS,aAAa,GAAG;;;;UAIjD;;AAGX,iBAAiB,mBAAmB,aAAa;;;;UAItC,oBAAoB;;;;UAIpB;;AAGX,YAAY,cAAc,eAAe,oBAAoB,KAAK,mBAAmB","names":[],"sources":["../../../src/types/Model.ts"],"version":3,"file":"Model.d.ts"}
@@ -42,6 +42,7 @@ export interface PresenceEventDataCustom<M extends Model = Model> {
42
42
  readonly type: typeof PresenceEventDataType.CUSTOM_EVENT;
43
43
  readonly eventData: ModelData<M>;
44
44
  readonly model: M;
45
+ readonly schemaVersion?: number;
45
46
  }
46
47
  /**
47
48
  * Fallback for unrecognized activity event types.
@@ -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,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"}
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;UACP;;;;;;;;;;AAWX,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"}
@@ -1,5 +1,5 @@
1
1
  import type { DocumentRef } from "./DocumentRef.js";
2
- import type { Model, ModelData } from "./Model.js";
2
+ import type { Model } from "./Model.js";
3
3
  import type { RecordId, RecordRef } from "./RecordRef.js";
4
4
  export declare const RecordCollectionRefBrand: unique symbol;
5
5
  /**
@@ -12,6 +12,9 @@ export interface RecordCollectionRef<M extends Model = Model> {
12
12
  /**
13
13
  * Delete a record from the collection (and the document).
14
14
  *
15
+ * Version-agnostic: deletion needs only the record's identity, not its
16
+ * payload shape, so this is safe to call without narrowing to a version.
17
+ *
15
18
  * @param id - The ID of the record to delete.
16
19
  * @returns A promise that resolves when the record is deleted.
17
20
  */
@@ -32,20 +35,6 @@ export interface RecordCollectionRef<M extends Model = Model> {
32
35
  * @returns True if the record exists, false otherwise.
33
36
  */
34
37
  has(id: RecordId): boolean;
35
- /**
36
- * Set the data for a record in the collection (creating it if it doesn't exist).
37
- *
38
- * @param id - The ID of the record to set.
39
- * @param state - The data to set for the record.
40
- * @returns A promise that resolves when the record is set.
41
- *
42
- * @example
43
- * ```ts
44
- * const recordCollection = docRef.getRecords(MyModel);
45
- * await recordCollection.set("record-id", { field: "value" });
46
- * ```
47
- */
48
- set(id: RecordId, state: ModelData<M>): Promise<void>;
49
38
  readonly size: number;
50
39
  [Symbol.iterator](): Iterator<RecordRef<M>>;
51
40
  /**
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,UAAU,iBAAiB;AAEzC,OAAO,cAAMA;;;;AAOb,iBAAiB,oBAAoB,UAAU,QAAQ,OAAO;UACnD,QAAQ;UACR,OAAO;WACN,kCAAkC;;;;;;;CAQ5C,OAAO,IAAI,WAAW;;;;;;;;;CAStB,IAAI,IAAI,WAAW,UAAU;;;;;;;CAO7B,IAAI,IAAI;;;;;;;;;;;;;;CAcR,IAAI,IAAI,UAAU,OAAO,UAAU,KAAK;UAC/B;EAER,OAAO,aAAa,SAAS,UAAU;;;;;;;UAQ/B,eACP,WAAW,gBAAgB,UAAU;;;;;;;UAS9B,iBACP,WAAW,gBAAgB,UAAU;;;;;;;UAS9B,iBACP,WAAW,gBAAgB,UAAU","names":["RecordCollectionRefBrand: unique symbol"],"sources":["../../../src/types/RecordCollectionRef.ts"],"version":3,"file":"RecordCollectionRef.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,mBAAmB;AACjC,cAAc,aAAa;AAC3B,cAAc,UAAU,iBAAiB;AAEzC,OAAO,cAAMA;;;;AAOb,iBAAiB,oBAAoB,UAAU,QAAQ,OAAO;UACnD,QAAQ;UACR,OAAO;WACN,kCAAkC;;;;;;;;;;CAW5C,OAAO,IAAI,WAAW;;;;;;;;;CAStB,IAAI,IAAI,WAAW,UAAU;;;;;;;CAO7B,IAAI,IAAI;UACC;EAER,OAAO,aAAa,SAAS,UAAU;;;;;;;UAQ/B,eACP,WAAW,gBAAgB,UAAU;;;;;;;UAS9B,iBACP,WAAW,gBAAgB,UAAU;;;;;;;UAS9B,iBACP,WAAW,gBAAgB,UAAU","names":["RecordCollectionRefBrand: unique symbol"],"sources":["../../../src/types/RecordCollectionRef.ts"],"version":3,"file":"RecordCollectionRef.d.ts"}
@@ -20,9 +20,10 @@ export declare const RecordRefBrand: unique symbol;
20
20
  *
21
21
  * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);
22
22
  *
23
- * const recordRef = docRef.getRecords(MyModel).set("my-record-id", { myFieldName: "some value", foo: 42 });
23
+ * // Create a record via the version-narrowed setRecord on DocumentRef.
24
+ * await docRef.setRecord(MyModel, "my-record-id", { myFieldName: "some value", foo: 42 });
24
25
  *
25
- * // Or get a specific record.
26
+ * // Then get the ref back.
26
27
  * const recordRef = docRef.getRecords(MyModel).get("my-record-id");
27
28
  */
28
29
  export interface RecordRef<M extends Model = Model> {
@@ -48,8 +49,8 @@ export interface RecordRef<M extends Model = Model> {
48
49
  * console.log("Record changed:", newSnapshot);
49
50
  * });
50
51
  *
51
- * // Submit a change
52
- * recordRef.set({ myFieldName: "new value" });
52
+ * // Submit a change via the version-narrowed updateRecord on DocumentRef.
53
+ * await docRef.updateRecord(recordRef, { myFieldName: "new value" });
53
54
  * ```
54
55
  */
55
56
  onChange(callback: (snapshot: ModelData<M>, recordRef: RecordRef<M>) => void): Unsubscribe;
@@ -73,6 +74,9 @@ export interface RecordRef<M extends Model = Model> {
73
74
  /**
74
75
  * Delete the record from the document.
75
76
  *
77
+ * Version-agnostic: deletion needs only the record's identity, not its
78
+ * payload shape, so this is safe to call without narrowing to a version.
79
+ *
76
80
  * @returns An ignorable promise that resolves when the record is deleted.
77
81
  *
78
82
  * @example
@@ -81,32 +85,4 @@ export interface RecordRef<M extends Model = Model> {
81
85
  * ```
82
86
  */
83
87
  delete(): Promise<void>;
84
- /**
85
- * Set the data for the record (creating it if it doesn't exist).
86
- *
87
- * @see {onChange} to subscribe to changes to the record.
88
- *
89
- * @param record - The plain object data to set for the record, corresponding to the model's schema.
90
- * @returns An ignorable promise that resolves when the record is published.
91
- *
92
- * @example
93
- * ```ts
94
- * await recordRef.set({ field: "value" });
95
- * ```
96
- */
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>;
112
88
  }
@@ -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;;;;;;;;;;;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"}
1
+ {"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,mBAAmB;AAEjC,YAAY,WAAW,SAAS;AAEhC,OAAO,cAAMA;;;;;;;;;;;;;;;;;;;;;;;AAwBb,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,UAAU","names":["RecordRefBrand: unique symbol"],"sources":["../../../src/types/RecordRef.ts"],"version":3,"file":"RecordRef.d.ts"}
@@ -1,4 +1,3 @@
1
- import type { JsonValue } from "./JsonValue.js";
2
1
  /** Type descriptor for a field, enabling recursive lens application. */
3
2
  export type FieldTypeDescriptor = {
4
3
  kind: "primitive";
@@ -17,16 +16,16 @@ export type FieldTypeDescriptor = {
17
16
  };
18
17
  export interface FieldLensDef {
19
18
  /**
20
- * Source field names. When empty, the field is additive — only `default` applies and no
21
- * forward function is invoked.
19
+ * Source field names. When empty, the field is additive — the upgrade fn
20
+ * receives `{}` and returns a value of the field's type. Either way, the
21
+ * runtime looks up an entry in `UpgradeFns` at this `(modelName, version,
22
+ * fieldName)` and calls it.
22
23
  */
23
24
  derivedFrom: string[];
24
- /** Literal JSON only — validated at schema build time. Used when no source data exists. */
25
- default?: JsonValue;
26
25
  }
27
26
  export interface FieldDef {
28
27
  type: FieldTypeDescriptor;
29
- default?: unknown;
28
+ addedInVersion?: number;
30
29
  }
31
30
  export interface UpgradeStepDef {
32
31
  /** Schema version this step upgrades to. Unique within a model's chain. */
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,iBAAiB;;AAG/B,YAAY,sBACR;CAAE,MAAM;IACR;CAAE,MAAM;CAAY;IACpB;CAAE,MAAM;CAAS,SAAS;IAC1B;CAAE,MAAM;CAAO,OAAO;IACtB;CAAE,MAAM;CAAY,OAAO;;AAE/B,iBAAiB,aAAa;;;;;CAK5B;;CAEA,UAAU;;AAGZ,iBAAiB,SAAS;CACxB,MAAM;CACN;;AAGF,iBAAiB,eAAe;;CAE9B;CACA,QAAQ,eAAe;CACvB;;AAGF,iBAAiB,gBAAgB,mCAAmC;CAClE,WAAW;;CAEX,WAAW,eAAe;;CAE1B,OAAO;;;;;;;AAQT,iBAAiB,qBAAqB,mCAAmC;CACvE,WAAW;;CAEX;;CAEA,UAAU;;AAGZ,YAAY,uBAAuB,kBAAkB;AAErD,YAAY,qBAAqB,eAAe;;;;;;;;;;;;;;AAehD,YAAY,aAAa,eAEvB,eAAe,gBAAgB","names":[],"sources":["../../../src/types/UpgradeLens.ts"],"version":3,"file":"UpgradeLens.d.ts"}
1
+ {"mappings":";AAiBA,YAAY,sBACR;CAAE,MAAM;IACR;CAAE,MAAM;CAAY;IACpB;CAAE,MAAM;CAAS,SAAS;IAC1B;CAAE,MAAM;CAAO,OAAO;IACtB;CAAE,MAAM;CAAY,OAAO;;AAE/B,iBAAiB,aAAa;;;;;;;CAO5B;;AAGF,iBAAiB,SAAS;CACxB,MAAM;CACN;;AAGF,iBAAiB,eAAe;;CAE9B;CACA,QAAQ,eAAe;CACvB;;AAGF,iBAAiB,gBAAgB,mCAAmC;CAClE,WAAW;;CAEX,WAAW,eAAe;;CAE1B,OAAO;;;;;;;AAQT,iBAAiB,qBAAqB,mCAAmC;CACvE,WAAW;;CAEX;;CAEA,UAAU;;AAGZ,YAAY,uBAAuB,kBAAkB;AAErD,YAAY,qBAAqB,eAAe;;;;;;;;;;;;;;AAehD,YAAY,aAAa,eAEvB,eAAe,gBAAgB","names":[],"sources":["../../../src/types/UpgradeLens.ts"],"version":3,"file":"UpgradeLens.d.ts"}
@@ -1,5 +1,5 @@
1
1
  import type { ActivityEventData, ActivityEventDataCustom, ActivityEventDataUnknown } from "../types/ActivityEvent.js";
2
- import type { EditDescription, Model, ModelData } from "../types/Model.js";
2
+ import type { EditDescription, Model } from "../types/Model.js";
3
3
  /**
4
4
  * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.
5
5
  *
@@ -17,7 +17,11 @@ import type { EditDescription, Model, ModelData } from "../types/Model.js";
17
17
  * }));
18
18
  * ```
19
19
  */
20
- export declare function describeEdit<M extends Model>(model: M, data: ModelData<M>): EditDescription<M>;
20
+ /**
21
+ * @deprecated Narrow the document ref by version and use
22
+ * `doc.describeEdit(model, data)` instead.
23
+ */
24
+ export declare function describeEdit<M extends Model>(model: M, data: never): EditDescription<M>;
21
25
  /**
22
26
  * Type guard for custom event data.
23
27
  *
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cACE,mBACA,yBACA,gCACK;AAEP,cAAc,iBAAiB,OAAO,iBAAiB;;;;;;;;;;;;;;;;;;AAmBvD,OAAO,iBAAS,aAAa,UAAU,OAAO,OAAO,GAAG,MAAM,UAAU,KAAK,gBAAgB;;;;;;;AAa7F,OAAO,iBAAS,SACd,WAAW,oBACV,aAAa;;;;;;;;;;;;;;;;;;;AAsBhB,OAAO,iBAAS,OAAO,UAAU,OAC/B,WAAW,mBACX,OAAO,IACN,aAAa,wBAAwB;;;;;;;;;;;;;AAmBxC,OAAO,iBAAS,UACd,WAAW,oBACV,aAAa","names":[],"sources":["../../../src/utils/ActivityEvents.ts"],"version":3,"file":"ActivityEvents.d.ts"}
1
+ {"mappings":"AAgBA,cACE,mBACA,yBACA,gCACK;AAEP,cAAc,iBAAiB,aAAa;;;;;;;;;;;;;;;;;;;;;;AAuB5C,OAAO,iBAAS,aAAa,UAAU,OAAO,OAAO,GAAG,cAAc,gBAAgB;;;;;;;AAatF,OAAO,iBAAS,SACd,WAAW,oBACV,aAAa;;;;;;;;;;;;;;;;;;;AAsBhB,OAAO,iBAAS,OAAO,UAAU,OAC/B,WAAW,mBACX,OAAO,IACN,aAAa,wBAAwB;;;;;;;;;;;;;AAmBxC,OAAO,iBAAS,UACd,WAAW,oBACV,aAAa","names":[],"sources":["../../../src/utils/ActivityEvents.ts"],"version":3,"file":"ActivityEvents.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palantir/pack.document-schema.model-types",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Minimal types supporting generated PACK schemas",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@palantir/pack.core": "~0.3.0"
31
+ "@palantir/pack.core": "~0.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "zod": "^4.1.7"
package/src/index.ts CHANGED
@@ -50,7 +50,6 @@ export type {
50
50
  DocumentSchemaMetadata,
51
51
  DocumentState,
52
52
  } from "./types/DocumentSchema.js";
53
- export type { JsonValue } from "./types/JsonValue.js";
54
53
  export { MediaRefBrand } from "./types/MediaRef.js";
55
54
  export type { MediaId, MediaRef } from "./types/MediaRef.js";
56
55
  export { getMetadata, hasMetadata, Metadata } from "./types/Metadata.js";
@@ -59,6 +59,7 @@ export interface ActivityEventDataCustom<M extends Model = Model> {
59
59
  readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
60
60
  readonly model: M;
61
61
  readonly eventType: string;
62
+ readonly schemaVersion?: number;
62
63
  readonly data: ModelData<M>;
63
64
  }
64
65
 
@@ -59,10 +59,9 @@ export interface DocumentMetadata {
59
59
  readonly ontologyRid: string;
60
60
  /**
61
61
  * The schema version this document is currently operating at.
62
- * All connected clients must read and write at this version.
63
- * Set by the backend; only increases (one-way ratchet).
62
+ * Calculated and set by the backend; only increases (one-way ratchet).
64
63
  */
65
- readonly schemaVersion?: number;
64
+ readonly operationalVersion?: number;
66
65
  readonly security: DocumentSecurity;
67
66
  readonly updatedBy?: string;
68
67
  readonly updatedTime?: string;
@@ -18,9 +18,10 @@ import type { Flavored } from "@palantir/pack.core";
18
18
  import type { ActivityEvent } from "./ActivityEvent.js";
19
19
  import type { DocumentMetadata } from "./DocumentMetadata.js";
20
20
  import type { DocumentSchema, DocumentState } from "./DocumentSchema.js";
21
- import type { EditDescription, Model, ModelData } from "./Model.js";
21
+ import type { EditDescription, Model } from "./Model.js";
22
22
  import type { PresenceEvent } from "./PresenceEvent.js";
23
23
  import type { RecordCollectionRef } from "./RecordCollectionRef.js";
24
+ import type { RecordId, RecordRef } from "./RecordRef.js";
24
25
  import type { Unsubscribe } from "./Unsubscribe.js";
25
26
 
26
27
  export type DocumentId = Flavored<"DocumentId">;
@@ -138,6 +139,10 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
138
139
  /**
139
140
  * Subscribe to metadata changes for the document.
140
141
  *
142
+ * In Foundry, metadata update events are sent for metadata edits/deletion.
143
+ * Name and description changes are not identified in the event payload, and
144
+ * operational-version-only changes do not currently trigger this callback.
145
+ *
141
146
  * @returns An unsubscribe function.
142
147
  * @example
143
148
  * ```ts
@@ -174,10 +179,7 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
174
179
  * }
175
180
  * }, { ignoreSelfUpdates: true });
176
181
  *
177
- * // Broadcast a presence update
178
- * docRef.updateCustomPresence(MyPresenceModel, {
179
- * cursorPosition: [42, 7],
180
- * });
182
+ * // Broadcast a presence update after narrowing to a generated versioned doc ref.
181
183
  *
182
184
  * // Later, to unsubscribe:
183
185
  * unsubscribe();
@@ -225,12 +227,20 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
225
227
  * @param eventData The new presence data for the model.
226
228
  * @param options Options for presence publishing.
227
229
  */
228
- updateCustomPresence<M extends Model = Model>(
229
- model: M,
230
- eventData: ModelData<M>,
230
+ updateCustomPresence(
231
+ model: Model,
232
+ eventData: never,
231
233
  options?: PresencePublishOptions,
232
234
  ): void;
233
235
 
236
+ /**
237
+ * Create a custom activity edit description.
238
+ *
239
+ * The data parameter is `never` on the base interface — narrow to a
240
+ * version-specific type before calling this method.
241
+ */
242
+ describeEdit(model: Model, data: never): EditDescription;
243
+
234
244
  /**
235
245
  * Execute one or more document edits within a transaction, optionally providing
236
246
  * a description of the edit for activity tracking.
@@ -254,10 +264,38 @@ export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
254
264
  * const myRecords = docRef.getRecords(MyModel);
255
265
  * myRecords.set("record-1", { field: "new value" });
256
266
  * myRecords.delete("record-2");
257
- * }, ActivityEvents.describeEdit(MyEditEventModel, {
267
+ * }, doc.describeEdit(MyEditEventModel, {
258
268
  * summary: "Updated record-1 and deleted record-2",
259
269
  * }));
260
270
  * ```
261
271
  */
262
272
  withTransaction(fn: () => void, description?: EditDescription): void;
273
+
274
+ /**
275
+ * The document's current schema operational version.
276
+ *
277
+ * The backend determines the highest schema version this document currently
278
+ * accepts. This may change during a session.
279
+ */
280
+ readonly version: number;
281
+
282
+ /**
283
+ * Update fields on an existing record.
284
+ *
285
+ * The data parameter is `never` on the base interface — narrow the ref to a
286
+ * version-specific type (via the generated SDK's `asVersioned` +
287
+ * `switch (doc.version)`) before calling this method.
288
+ */
289
+ updateRecord(ref: RecordRef, data: never): Promise<void>;
290
+
291
+ /**
292
+ * Create or replace a record in a collection.
293
+ *
294
+ * The data parameter is `never` on the base interface — narrow to a
295
+ * version-specific type before calling this method.
296
+ */
297
+ setRecord(model: Model, id: RecordId, data: never): Promise<void>;
298
+
299
+ /** Delete a record. Version-agnostic — callable without narrowing. */
300
+ deleteRecord<M extends Model>(ref: RecordRef<M>): Promise<void>;
263
301
  }