@palantir/pack.document-schema.model-types 0.2.0 → 0.2.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.
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-transpileBrowser.log +1 -1
- package/.turbo/turbo-transpileCjs.log +1 -1
- package/.turbo/turbo-transpileEsm.log +1 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +6 -0
- package/build/browser/index.js +52 -1
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +53 -0
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +171 -12
- package/build/esm/index.js +52 -1
- package/build/esm/index.js.map +1 -1
- package/build/types/index.d.ts +3 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/ActivityEvent.d.ts +1 -1
- package/build/types/types/ActivityEvent.d.ts.map +1 -1
- package/build/types/types/DocumentRef.d.ts +3 -6
- package/build/types/types/DocumentRef.d.ts.map +1 -1
- package/build/types/types/PresenceEvent.d.ts +3 -3
- package/build/types/types/PresenceEvent.d.ts.map +1 -1
- package/build/types/types/RecordRef.d.ts +26 -1
- package/build/types/types/RecordRef.d.ts.map +1 -1
- package/build/types/utils/ActivityEvents.d.ts +59 -0
- package/build/types/utils/ActivityEvents.d.ts.map +1 -0
- package/build/types/utils/PresenceEvents.d.ts +66 -0
- package/build/types/utils/PresenceEvents.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/types/ActivityEvent.ts +1 -1
- package/src/types/DocumentRef.ts +3 -6
- package/src/types/PresenceEvent.ts +3 -3
- package/src/types/RecordRef.ts +28 -1
- package/src/utils/ActivityEvents.ts +105 -0
- package/src/utils/PresenceEvents.ts +113 -0
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.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.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.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.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.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.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.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.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.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.2.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.2.1 typecheck /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> tsc --noEmit --emitDeclarationOnly false
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
package/build/browser/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/types/ActivityEvent.ts
|
|
2
8
|
var ActivityEventDataType = {
|
|
3
9
|
CUSTOM_EVENT: "customEvent",
|
|
@@ -58,6 +64,51 @@ var RecordRefBrand = Symbol("pack:RecordRef");
|
|
|
58
64
|
// src/types/UserRef.ts
|
|
59
65
|
var UserRefBrand = Symbol("pack:UserRef");
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
// src/utils/ActivityEvents.ts
|
|
68
|
+
var ActivityEvents_exports = {};
|
|
69
|
+
__export(ActivityEvents_exports, {
|
|
70
|
+
describeEdit: () => describeEdit,
|
|
71
|
+
isCustom: () => isCustom,
|
|
72
|
+
isEdit: () => isEdit,
|
|
73
|
+
isUnknown: () => isUnknown
|
|
74
|
+
});
|
|
75
|
+
function describeEdit(model, data) {
|
|
76
|
+
return {
|
|
77
|
+
data,
|
|
78
|
+
model
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function isCustom(eventData) {
|
|
82
|
+
return eventData.type === ActivityEventDataType.CUSTOM_EVENT;
|
|
83
|
+
}
|
|
84
|
+
function isEdit(eventData, model) {
|
|
85
|
+
return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;
|
|
86
|
+
}
|
|
87
|
+
function isUnknown(eventData) {
|
|
88
|
+
return eventData.type === ActivityEventDataType.UNKNOWN;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/utils/PresenceEvents.ts
|
|
92
|
+
var PresenceEvents_exports = {};
|
|
93
|
+
__export(PresenceEvents_exports, {
|
|
94
|
+
isArrived: () => isArrived,
|
|
95
|
+
isCustom: () => isCustom2,
|
|
96
|
+
isDeparted: () => isDeparted,
|
|
97
|
+
isUnknown: () => isUnknown2
|
|
98
|
+
});
|
|
99
|
+
function isArrived(eventData) {
|
|
100
|
+
return eventData.type === PresenceEventDataType.ARRIVED;
|
|
101
|
+
}
|
|
102
|
+
function isCustom2(eventData, model) {
|
|
103
|
+
return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);
|
|
104
|
+
}
|
|
105
|
+
function isDeparted(eventData) {
|
|
106
|
+
return eventData.type === PresenceEventDataType.DEPARTED;
|
|
107
|
+
}
|
|
108
|
+
function isUnknown2(eventData) {
|
|
109
|
+
return eventData.type === PresenceEventDataType.UNKNOWN;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata };
|
|
62
113
|
//# sourceMappingURL=index.js.map
|
|
63
114
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AACjD;;;ACVO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ActivityEventDataType = {\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n// TODO: add standard document activity events (need to be added to api types)\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n return fallbackMetadata;\n }\n }\n }\n throw new Error(\"Object does not have metadata\");\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */"]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts","../../src/utils/ActivityEvents.ts","../../src/utils/PresenceEvents.ts"],"names":["isCustom","isUnknown"],"mappings":"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","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 */","/*\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}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __export = (target, all) => {
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
// src/types/ActivityEvent.ts
|
|
4
10
|
var ActivityEventDataType = {
|
|
5
11
|
CUSTOM_EVENT: "customEvent",
|
|
@@ -60,13 +66,60 @@ var RecordRefBrand = Symbol("pack:RecordRef");
|
|
|
60
66
|
// src/types/UserRef.ts
|
|
61
67
|
var UserRefBrand = Symbol("pack:UserRef");
|
|
62
68
|
|
|
69
|
+
// src/utils/ActivityEvents.ts
|
|
70
|
+
var ActivityEvents_exports = {};
|
|
71
|
+
__export(ActivityEvents_exports, {
|
|
72
|
+
describeEdit: () => describeEdit,
|
|
73
|
+
isCustom: () => isCustom,
|
|
74
|
+
isEdit: () => isEdit,
|
|
75
|
+
isUnknown: () => isUnknown
|
|
76
|
+
});
|
|
77
|
+
function describeEdit(model, data) {
|
|
78
|
+
return {
|
|
79
|
+
data,
|
|
80
|
+
model
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function isCustom(eventData) {
|
|
84
|
+
return eventData.type === ActivityEventDataType.CUSTOM_EVENT;
|
|
85
|
+
}
|
|
86
|
+
function isEdit(eventData, model) {
|
|
87
|
+
return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;
|
|
88
|
+
}
|
|
89
|
+
function isUnknown(eventData) {
|
|
90
|
+
return eventData.type === ActivityEventDataType.UNKNOWN;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/utils/PresenceEvents.ts
|
|
94
|
+
var PresenceEvents_exports = {};
|
|
95
|
+
__export(PresenceEvents_exports, {
|
|
96
|
+
isArrived: () => isArrived,
|
|
97
|
+
isCustom: () => isCustom2,
|
|
98
|
+
isDeparted: () => isDeparted,
|
|
99
|
+
isUnknown: () => isUnknown2
|
|
100
|
+
});
|
|
101
|
+
function isArrived(eventData) {
|
|
102
|
+
return eventData.type === PresenceEventDataType.ARRIVED;
|
|
103
|
+
}
|
|
104
|
+
function isCustom2(eventData, model) {
|
|
105
|
+
return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);
|
|
106
|
+
}
|
|
107
|
+
function isDeparted(eventData) {
|
|
108
|
+
return eventData.type === PresenceEventDataType.DEPARTED;
|
|
109
|
+
}
|
|
110
|
+
function isUnknown2(eventData) {
|
|
111
|
+
return eventData.type === PresenceEventDataType.UNKNOWN;
|
|
112
|
+
}
|
|
113
|
+
|
|
63
114
|
exports.ActivityEventDataType = ActivityEventDataType;
|
|
115
|
+
exports.ActivityEvents = ActivityEvents_exports;
|
|
64
116
|
exports.DocumentRefBrand = DocumentRefBrand;
|
|
65
117
|
exports.ExternalRefType = ExternalRefType;
|
|
66
118
|
exports.MediaRefBrand = MediaRefBrand;
|
|
67
119
|
exports.Metadata = Metadata;
|
|
68
120
|
exports.ObjectRefBrand = ObjectRefBrand;
|
|
69
121
|
exports.PresenceEventDataType = PresenceEventDataType;
|
|
122
|
+
exports.PresenceEvents = PresenceEvents_exports;
|
|
70
123
|
exports.RecordCollectionRefBrand = RecordCollectionRefBrand;
|
|
71
124
|
exports.RecordRefBrand = RecordRefBrand;
|
|
72
125
|
exports.UserRefBrand = UserRefBrand;
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/ActivityEvent.ts","../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/PresenceEvent.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";;;AAgBO,IAAM,qBAAA,GAAwB;AAAA,EACnC,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACCO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACJlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,cAAA,GAAiB,IAAI,QAAQ,CAAA;AACnC,EAAA,IAAI,kBAAkB,IAAA,EAAM;AAC1B,IAAA,OAAO,cAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,SAAS,QAAA,EAAS;AACzC,EAAA,MAAM,UAAA,GAAa,MAAA,CAAO,qBAAA,CAAsB,GAAG,CAAA;AACnD,EAAA,KAAA,MAAW,aAAa,UAAA,EAAY;AAClC,IAAA,IAAI,SAAA,CAAU,QAAA,EAAS,KAAM,cAAA,EAAgB;AAC3C,MAAA,MAAM,gBAAA,GAAmB,IAAI,SAAS,CAAA;AACtC,MAAA,IAAI,oBAAoB,IAAA,EAAM;AAC5B,QAAA,OAAO,gBAAA;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AACjD;;;ACVO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;AChBO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,qBAAA,GAAwB;AAAA,EACnC,OAAA,EAAS,iBAAA;AAAA,EACT,QAAA,EAAU,kBAAA;AAAA,EACV,YAAA,EAAc,aAAA;AAAA,EACd,OAAA,EAAS;AACX;;;ACLO,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.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 */"]}
|
|
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":"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","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 */","/*\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}"]}
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -95,7 +95,7 @@ interface ActivityEventDataCustom<M extends Model = Model> {
|
|
|
95
95
|
* applications.
|
|
96
96
|
*/
|
|
97
97
|
interface ActivityEventDataUnknown {
|
|
98
|
-
readonly type:
|
|
98
|
+
readonly type: typeof ActivityEventDataType.UNKNOWN;
|
|
99
99
|
readonly rawType: string;
|
|
100
100
|
readonly rawData: unknown;
|
|
101
101
|
}
|
|
@@ -216,12 +216,12 @@ interface PresenceEventDataCustom<M extends Model = Model> {
|
|
|
216
216
|
* in a future release of pack libraries and can be safely ignored by
|
|
217
217
|
* applications.
|
|
218
218
|
*/
|
|
219
|
-
interface
|
|
220
|
-
readonly type:
|
|
219
|
+
interface PresenceEventDataUnknown {
|
|
220
|
+
readonly type: typeof PresenceEventDataType.UNKNOWN;
|
|
221
221
|
readonly rawType: string;
|
|
222
222
|
readonly rawData: unknown;
|
|
223
223
|
}
|
|
224
|
-
type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom |
|
|
224
|
+
type PresenceEventData = PresenceEventDataArrived | PresenceEventDataDeparted | PresenceEventDataCustom | PresenceEventDataUnknown;
|
|
225
225
|
/**
|
|
226
226
|
* An event representing a transient awareness or presence change for a user on this document.
|
|
227
227
|
* The presence channel is intended for ephemeral data such as user cursors, selections, or
|
|
@@ -306,10 +306,21 @@ interface RecordRef<M extends Model = Model> {
|
|
|
306
306
|
* });
|
|
307
307
|
*
|
|
308
308
|
* // Trigger the deletion
|
|
309
|
-
*
|
|
309
|
+
* recordRef.delete();
|
|
310
310
|
* ```
|
|
311
311
|
*/
|
|
312
312
|
onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
313
|
+
/**
|
|
314
|
+
* Delete the record from the document.
|
|
315
|
+
*
|
|
316
|
+
* @returns An ignorable promise that resolves when the record is deleted.
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* await recordRef.delete();
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
delete(): Promise<void>;
|
|
313
324
|
/**
|
|
314
325
|
* Set the data for the record (creating it if it doesn't exist).
|
|
315
326
|
*
|
|
@@ -324,6 +335,20 @@ interface RecordRef<M extends Model = Model> {
|
|
|
324
335
|
* ```
|
|
325
336
|
*/
|
|
326
337
|
set(record: ModelData<M>): Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* Update specific fields of the record.
|
|
340
|
+
*
|
|
341
|
+
* @see {onChange} to subscribe to changes to the record.
|
|
342
|
+
*
|
|
343
|
+
* @param partialRecord - A partial plain object with the fields to update.
|
|
344
|
+
* @returns An ignorable promise that resolves when the record is published.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```ts
|
|
348
|
+
* await recordRef.update({ field: "new value" });
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
update(record: Partial<ModelData<M>>): Promise<void>;
|
|
327
352
|
}
|
|
328
353
|
|
|
329
354
|
declare const RecordCollectionRefBrand: unique symbol;
|
|
@@ -589,12 +614,9 @@ interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
|
|
|
589
614
|
* const myRecords = docRef.getRecords(MyModel);
|
|
590
615
|
* myRecords.set("record-1", { field: "new value" });
|
|
591
616
|
* myRecords.delete("record-2");
|
|
592
|
-
* }, {
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* summary: "Updated record-1 and deleted record-2",
|
|
596
|
-
* },
|
|
597
|
-
* });
|
|
617
|
+
* }, ActivityEvents.describeEdit(MyEditEventModel, {
|
|
618
|
+
* summary: "Updated record-1 and deleted record-2",
|
|
619
|
+
* }));
|
|
598
620
|
* ```
|
|
599
621
|
*/
|
|
600
622
|
withTransaction(fn: () => void, description?: EditDescription): void;
|
|
@@ -622,4 +644,141 @@ interface ObjectRef {
|
|
|
622
644
|
readonly subscribe?: (callback: unknown) => unknown;
|
|
623
645
|
}
|
|
624
646
|
|
|
625
|
-
|
|
647
|
+
/**
|
|
648
|
+
* Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.
|
|
649
|
+
*
|
|
650
|
+
* @param model The model to edit.
|
|
651
|
+
* @param data The data to apply to the model.
|
|
652
|
+
* @returns An edit description for the model.
|
|
653
|
+
*
|
|
654
|
+
* @example
|
|
655
|
+
* ```ts
|
|
656
|
+
* docRef.withTransaction(() => {
|
|
657
|
+
* // make some edits to the document here
|
|
658
|
+
* }, ActivityEvents.describeEdit(MyEventModel, {
|
|
659
|
+
* myEventDataField: "some value",
|
|
660
|
+
* foo: 42,
|
|
661
|
+
* }));
|
|
662
|
+
* ```
|
|
663
|
+
*/
|
|
664
|
+
declare function describeEdit<M extends Model>(model: M, data: ModelData<M>): EditDescription<M>;
|
|
665
|
+
/**
|
|
666
|
+
* Type guard for custom event data.
|
|
667
|
+
*
|
|
668
|
+
* @param eventData The event data to check.
|
|
669
|
+
* @returns true if the event data is a custom event, false otherwise.
|
|
670
|
+
*/
|
|
671
|
+
declare function isCustom$1(eventData: ActivityEventData): eventData is ActivityEventDataCustom;
|
|
672
|
+
/**
|
|
673
|
+
* Type guard for custom event data for a specific model.
|
|
674
|
+
*
|
|
675
|
+
* @param eventData The event data from a {@link ActivityEvent} to check.
|
|
676
|
+
* @param model The model to check for.
|
|
677
|
+
* @returns true if the event data is a custom event for the given model, false otherwise.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```ts
|
|
681
|
+
* docRef.onActivity((docRef, event) => {
|
|
682
|
+
* if (!ActivityEvents.isEdit(event.eventData, MyEventModel)) {
|
|
683
|
+
* return;
|
|
684
|
+
* }
|
|
685
|
+
*
|
|
686
|
+
* console.log("Got event", event.eventData.eventData.myField);
|
|
687
|
+
* });
|
|
688
|
+
* ```
|
|
689
|
+
*/
|
|
690
|
+
declare function isEdit<M extends Model>(eventData: ActivityEventData, model: M): eventData is ActivityEventDataCustom<M>;
|
|
691
|
+
/**
|
|
692
|
+
* Type guard for unknown activity event data. These are fired when a user
|
|
693
|
+
* performs an action that is not recognized by this client.
|
|
694
|
+
*
|
|
695
|
+
* This may be due to application version mismatch, or new platform features for
|
|
696
|
+
* example, and should generally be ignorable.
|
|
697
|
+
*
|
|
698
|
+
* @experimental
|
|
699
|
+
*
|
|
700
|
+
* @param eventData The event data to check.
|
|
701
|
+
* @returns true if the event data is an unknown event, false otherwise.
|
|
702
|
+
*/
|
|
703
|
+
declare function isUnknown$1(eventData: ActivityEventData): eventData is ActivityEventDataUnknown;
|
|
704
|
+
|
|
705
|
+
declare const ActivityEvents_describeEdit: typeof describeEdit;
|
|
706
|
+
declare const ActivityEvents_isEdit: typeof isEdit;
|
|
707
|
+
declare namespace ActivityEvents {
|
|
708
|
+
export { ActivityEvents_describeEdit as describeEdit, isCustom$1 as isCustom, ActivityEvents_isEdit as isEdit, isUnknown$1 as isUnknown };
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Type guard for Arrived presence events. These are fired when a user comes online on a document.
|
|
713
|
+
* @param eventData The event data from a {@link PresenceEvent} to check.
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* ```ts
|
|
717
|
+
* if (PresenceEvents.isArrived(event.eventData)) {
|
|
718
|
+
* console.log(`User ${event.userId} has arrived on the document.`);
|
|
719
|
+
* }
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
declare function isArrived(eventData: PresenceEventData): eventData is PresenceEventDataArrived;
|
|
723
|
+
/**
|
|
724
|
+
* Type guard for custom presence events.
|
|
725
|
+
* @param eventData The event data from a {@link PresenceEvent} to check.
|
|
726
|
+
* @param model The model to check for.
|
|
727
|
+
* @returns true if the event data is a custom event for the given model, false otherwise.
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* ```ts
|
|
731
|
+
* if (PresenceEvents.isCustom(event.eventData, MyEventModel)) {
|
|
732
|
+
* console.log("Got event", event.eventData.data.myField);
|
|
733
|
+
* }
|
|
734
|
+
* ```
|
|
735
|
+
*/
|
|
736
|
+
declare function isCustom<M extends Model>(eventData: PresenceEventData, model: M): eventData is PresenceEventDataCustom<M>;
|
|
737
|
+
/**
|
|
738
|
+
* Type guard for custom presence events.
|
|
739
|
+
* @param eventData The event data from a {@link PresenceEvent} to check.
|
|
740
|
+
* @returns true if the event data is a custom event of some type, false otherwise.
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* if (PresenceEvents.isCustom(event.eventData)) {
|
|
745
|
+
* console.log("Got a custom event:", event.eventData.model);
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
declare function isCustom(eventData: PresenceEventData): eventData is PresenceEventDataCustom;
|
|
750
|
+
/**
|
|
751
|
+
* Type guard for Departed presence events. These are fired when a user goes offline from a document.
|
|
752
|
+
* @param eventData The event data from a {@link PresenceEvent} to check.
|
|
753
|
+
* @returns true if the event data is a departed event, false otherwise.
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
* ```ts
|
|
757
|
+
* if (PresenceEvents.isDeparted(event.eventData)) {
|
|
758
|
+
* console.log(`User ${event.userId} has departed from the document.`);
|
|
759
|
+
* }
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
declare function isDeparted(eventData: PresenceEventData): eventData is PresenceEventDataDeparted;
|
|
763
|
+
/**
|
|
764
|
+
* Type guard for unknown presence events. These are fired when a user performs an action that is not
|
|
765
|
+
* recognized.
|
|
766
|
+
* This may be due to application version mismatch, or new platform features for example, and should
|
|
767
|
+
* generally be ignorable.
|
|
768
|
+
*
|
|
769
|
+
* @experimental
|
|
770
|
+
*
|
|
771
|
+
* @param eventData The event data from a {@link PresenceEvent} to check.
|
|
772
|
+
* @returns true if the event data is an unknown event, false otherwise.
|
|
773
|
+
*/
|
|
774
|
+
declare function isUnknown(eventData: PresenceEventData): eventData is PresenceEventDataUnknown;
|
|
775
|
+
|
|
776
|
+
declare const PresenceEvents_isArrived: typeof isArrived;
|
|
777
|
+
declare const PresenceEvents_isCustom: typeof isCustom;
|
|
778
|
+
declare const PresenceEvents_isDeparted: typeof isDeparted;
|
|
779
|
+
declare const PresenceEvents_isUnknown: typeof isUnknown;
|
|
780
|
+
declare namespace PresenceEvents {
|
|
781
|
+
export { PresenceEvents_isArrived as isArrived, PresenceEvents_isCustom as isCustom, PresenceEvents_isDeparted as isDeparted, PresenceEvents_isUnknown as isUnknown };
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, ActivityEvents, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentState, type EditDescription, ExternalRefType, type MediaId, type MediaRef, MediaRefBrand, Metadata, type Model, type ModelData, type ModelMetadata, type ObjectId, type ObjectRef, ObjectRefBrand, type PresenceEvent, type PresenceEventData, type PresenceEventDataArrived, type PresenceEventDataCustom, type PresenceEventDataDeparted, PresenceEventDataType, type PresenceEventDataUnknown, PresenceEvents, type PresenceSubscriptionOptions, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, type RecordRef, RecordRefBrand, type Unsubscribe, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata };
|