@palantir/pack.document-schema.model-types 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) 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 +10 -0
  8. package/build/browser/index.js +14 -4
  9. package/build/browser/index.js.map +1 -1
  10. package/build/cjs/index.cjs +14 -4
  11. package/build/cjs/index.cjs.map +1 -1
  12. package/build/cjs/index.d.cts +413 -0
  13. package/build/esm/index.js +14 -4
  14. package/build/esm/index.js.map +1 -1
  15. package/build/types/__tests__/Metadata.test.d.ts +1 -0
  16. package/build/types/__tests__/Metadata.test.d.ts.map +1 -0
  17. package/build/types/types/ActivityEvent.d.ts +37 -0
  18. package/build/types/types/ActivityEvent.d.ts.map +1 -1
  19. package/build/types/types/DocumentRef.d.ts +185 -0
  20. package/build/types/types/DocumentRef.d.ts.map +1 -1
  21. package/build/types/types/DocumentSchema.d.ts +6 -0
  22. package/build/types/types/DocumentSchema.d.ts.map +1 -1
  23. package/build/types/types/Model.d.ts +9 -0
  24. package/build/types/types/Model.d.ts.map +1 -1
  25. package/build/types/types/PresenceEvent.d.ts +43 -0
  26. package/build/types/types/PresenceEvent.d.ts.map +1 -1
  27. package/build/types/types/RecordCollectionRef.d.ts +54 -0
  28. package/build/types/types/RecordCollectionRef.d.ts.map +1 -1
  29. package/build/types/types/RecordRef.d.ts +71 -0
  30. package/build/types/types/RecordRef.d.ts.map +1 -1
  31. package/build/types/types/Unsubscribe.d.ts +3 -0
  32. package/build/types/types/Unsubscribe.d.ts.map +1 -1
  33. package/build/types/types/UserRef.d.ts +5 -0
  34. package/build/types/types/UserRef.d.ts.map +1 -1
  35. package/package.json +3 -3
  36. package/src/__tests__/Metadata.test.ts +43 -0
  37. package/src/types/ActivityEvent.ts +37 -0
  38. package/src/types/DocumentRef.ts +192 -0
  39. package/src/types/DocumentSchema.ts +6 -0
  40. package/src/types/Metadata.ts +20 -5
  41. package/src/types/Model.ts +9 -0
  42. package/src/types/PresenceEvent.ts +43 -0
  43. package/src/types/RecordCollectionRef.ts +54 -0
  44. package/src/types/RecordRef.ts +74 -0
  45. package/src/types/Unsubscribe.ts +3 -0
  46. package/src/types/UserRef.ts +5 -0
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 lint /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 lint /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files
4
4
 
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 transpileBrowser /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 transpileBrowser /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > monorepo-transpile -f esm -m bundle -t browser
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 transpileCjs /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 transpileCjs /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > monorepo-transpile -f cjs -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 transpileEsm /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 transpileEsm /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > monorepo-transpile -f esm -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 transpileTypes /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 transpileTypes /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > monorepo-transpile -f esm -m types -t node
4
4
 
5
5
  👍
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.document-schema.model-types@0.1.0 typecheck /home/runner/work/pack/pack/packages/document-schema/model-types
2
+ > @palantir/pack.document-schema.model-types@0.1.1 typecheck /home/runner/work/pack/pack/packages/document-schema/model-types
3
3
  > tsc --noEmit --emitDeclarationOnly false
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @palantir/pack.document-schema.model-types
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - eba27ae: Fix issues locating model metadata when multiple copies of the schema package are present
8
+ - 67df6e4: Documented public apis
9
+ - Updated dependencies [eba27ae]
10
+ - Updated dependencies [67df6e4]
11
+ - @palantir/pack.core@0.1.1
12
+
3
13
  ## 0.1.0
4
14
 
5
15
  ### Minor Changes
@@ -13,11 +13,21 @@ var MediaRefBrand = Symbol("pack:MediaRef");
13
13
  // src/types/Metadata.ts
14
14
  var Metadata = Symbol("@palantir/pack.document-schema/metadata");
15
15
  function getMetadata(obj) {
16
- const metadata = obj[Metadata];
17
- if (metadata == null) {
18
- throw new Error("Object does not have metadata");
16
+ const directMetadata = obj[Metadata];
17
+ if (directMetadata != null) {
18
+ return directMetadata;
19
19
  }
20
- return metadata;
20
+ const metadataString = Metadata.toString();
21
+ const symbolKeys = Object.getOwnPropertySymbols(obj);
22
+ for (const symbolKey of symbolKeys) {
23
+ if (symbolKey.toString() === metadataString) {
24
+ const fallbackMetadata = obj[symbolKey];
25
+ if (fallbackMetadata != null) {
26
+ return fallbackMetadata;
27
+ }
28
+ }
29
+ }
30
+ throw new Error("Object does not have metadata");
21
31
  }
22
32
 
23
33
  // src/types/Model.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACHO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACAlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,QAAA,GAAW,IAAI,QAAQ,CAAA;AAC7B,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,QAAA;AACT;;;ACDO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;ACZO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n// TODO: add standard document activity events (need to be added to api types)","/*\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 DocumentRefBrand = Symbol(\"pack:DocumentRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // TS always treats symbol keys as optional\n const metadata = obj[Metadata];\n if (metadata == null) {\n throw new Error(\"Object does not have metadata\");\n }\n return metadata;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\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 * 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 * 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 * 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\");"]}
1
+ {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AACjD;;;ACVO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n// TODO: add standard document activity events (need to be added to api types)\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n return fallbackMetadata;\n }\n }\n }\n throw new Error(\"Object does not have metadata\");\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */"]}
@@ -15,11 +15,21 @@ var MediaRefBrand = Symbol("pack:MediaRef");
15
15
  // src/types/Metadata.ts
16
16
  var Metadata = Symbol("@palantir/pack.document-schema/metadata");
17
17
  function getMetadata(obj) {
18
- const metadata = obj[Metadata];
19
- if (metadata == null) {
20
- throw new Error("Object does not have metadata");
18
+ const directMetadata = obj[Metadata];
19
+ if (directMetadata != null) {
20
+ return directMetadata;
21
21
  }
22
- return metadata;
22
+ const metadataString = Metadata.toString();
23
+ const symbolKeys = Object.getOwnPropertySymbols(obj);
24
+ for (const symbolKey of symbolKeys) {
25
+ if (symbolKey.toString() === metadataString) {
26
+ const fallbackMetadata = obj[symbolKey];
27
+ if (fallbackMetadata != null) {
28
+ return fallbackMetadata;
29
+ }
30
+ }
31
+ }
32
+ throw new Error("Object does not have metadata");
23
33
  }
24
34
 
25
35
  // src/types/Model.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";;;AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACHO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACAlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,QAAA,GAAW,IAAI,QAAQ,CAAA;AAC7B,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,QAAA;AACT;;;ACDO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;ACZO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.cjs","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n// TODO: add standard document activity events (need to be added to api types)","/*\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 DocumentRefBrand = Symbol(\"pack:DocumentRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // TS always treats symbol keys as optional\n const metadata = obj[Metadata];\n if (metadata == null) {\n throw new Error(\"Object does not have metadata\");\n }\n return metadata;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\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 * 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 * 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 * 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\");"]}
1
+ {"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";;;AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AACjD;;;ACVO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.cjs","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n// TODO: add standard document activity events (need to be added to api types)\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n return fallbackMetadata;\n }\n }\n }\n throw new Error(\"Object does not have metadata\");\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */"]}