@palantir/pack.document-schema.model-types 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-transpileBrowser.log +2 -1
- package/.turbo/turbo-transpileCjs.log +2 -1
- package/.turbo/turbo-transpileEsm.log +2 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +28 -0
- package/build/browser/index.js +20 -5
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +20 -4
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +96 -35
- package/build/esm/index.js +20 -5
- package/build/esm/index.js.map +1 -1
- package/build/types/index.d.ts +4 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/ActivityEvent.d.ts +42 -1
- package/build/types/types/ActivityEvent.d.ts.map +1 -1
- package/build/types/types/DocumentMetadata.d.ts +18 -12
- package/build/types/types/DocumentMetadata.d.ts.map +1 -1
- package/build/types/types/Metadata.d.ts +3 -1
- package/build/types/types/Metadata.d.ts.map +1 -1
- package/build/types/types/Model.d.ts +23 -3
- package/build/types/types/Model.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +16 -2
- package/src/types/ActivityEvent.ts +51 -2
- package/src/types/DocumentMetadata.ts +21 -12
- package/src/types/Metadata.ts +23 -2
- package/src/types/Model.ts +31 -4
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.3.0 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,6 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.3.0 transpileBrowser /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f esm -m bundle -t browser
|
|
4
4
|
|
|
5
|
+
[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
|
|
5
6
|
👍
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.3.0 transpileCjs /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f cjs -m bundle -t node
|
|
4
4
|
|
|
5
|
+
[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
|
|
5
6
|
👍
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.3.0 transpileEsm /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f esm -m bundle -t node
|
|
4
4
|
|
|
5
|
+
[baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
|
|
5
6
|
👍
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.3.0 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
|
+
> @palantir/pack.document-schema.model-types@0.3.0 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,33 @@
|
|
|
1
1
|
# @palantir/pack.document-schema.model-types
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 862daf6: Schema union types can define custom discriminant
|
|
8
|
+
- 15f7f90: fix search api to match required types and add search pagination
|
|
9
|
+
- 8057223: Add metadata event types (platform events) and refactor demo app.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 9f45b8e: Improve document creation API to separate create request from raw API types
|
|
14
|
+
- 571578c: Add Booleans to pack.schema
|
|
15
|
+
- 7ee55de: Bump dependencies
|
|
16
|
+
- 4a44875: Remove bun-specific scripts and dependency
|
|
17
|
+
- 19b8f5b: Rm extra field in DiscretionaryPrincipal_All
|
|
18
|
+
- Updated dependencies [9f45b8e]
|
|
19
|
+
- Updated dependencies [571578c]
|
|
20
|
+
- Updated dependencies [e6e40f7]
|
|
21
|
+
- Updated dependencies [7ee55de]
|
|
22
|
+
- Updated dependencies [4a44875]
|
|
23
|
+
- @palantir/pack.core@0.2.1
|
|
24
|
+
|
|
25
|
+
## 0.2.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 0954a30: Relax validation on transaction editDescription for build environments that have duplicated @palantir/pack.document-schema.model-types. Adds a warning when this is detected
|
|
30
|
+
|
|
3
31
|
## 0.2.1
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/build/browser/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { justOnce } from '@palantir/pack.core';
|
|
2
|
+
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
2
4
|
var __export = (target, all) => {
|
|
3
5
|
for (var name in all)
|
|
@@ -7,6 +9,10 @@ var __export = (target, all) => {
|
|
|
7
9
|
// src/types/ActivityEvent.ts
|
|
8
10
|
var ActivityEventDataType = {
|
|
9
11
|
CUSTOM_EVENT: "customEvent",
|
|
12
|
+
DOCUMENT_CREATE: "documentCreate",
|
|
13
|
+
DOCUMENT_DESCRIPTION_UPDATE: "documentDescriptionUpdate",
|
|
14
|
+
DOCUMENT_RENAME: "documentRename",
|
|
15
|
+
DOCUMENT_SECURITY_UPDATE: "documentSecurityUpdate",
|
|
10
16
|
UNKNOWN: "unknown"
|
|
11
17
|
};
|
|
12
18
|
|
|
@@ -15,10 +21,8 @@ var DocumentRefBrand = Symbol("pack:DocumentRef");
|
|
|
15
21
|
|
|
16
22
|
// src/types/MediaRef.ts
|
|
17
23
|
var MediaRefBrand = Symbol("pack:MediaRef");
|
|
18
|
-
|
|
19
|
-
// src/types/Metadata.ts
|
|
20
24
|
var Metadata = Symbol("@palantir/pack.document-schema/metadata");
|
|
21
|
-
function getMetadata(obj) {
|
|
25
|
+
function getMetadata(obj, throwIfMissing = true) {
|
|
22
26
|
const directMetadata = obj[Metadata];
|
|
23
27
|
if (directMetadata != null) {
|
|
24
28
|
return directMetadata;
|
|
@@ -29,11 +33,22 @@ function getMetadata(obj) {
|
|
|
29
33
|
if (symbolKey.toString() === metadataString) {
|
|
30
34
|
const fallbackMetadata = obj[symbolKey];
|
|
31
35
|
if (fallbackMetadata != null) {
|
|
36
|
+
justOnce("getMetadata-fallback-warning", () => {
|
|
37
|
+
console.warn("Warning: Retrieved metadata using fallback symbol lookup. This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.");
|
|
38
|
+
});
|
|
32
39
|
return fallbackMetadata;
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
if (throwIfMissing) {
|
|
44
|
+
throw new Error("Object does not have metadata");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function hasMetadata(obj) {
|
|
48
|
+
if (obj == null || typeof obj !== "object") {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return getMetadata(obj, false) != null;
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
// src/types/Model.ts
|
|
@@ -109,6 +124,6 @@ function isUnknown2(eventData) {
|
|
|
109
124
|
return eventData.type === PresenceEventDataType.UNKNOWN;
|
|
110
125
|
}
|
|
111
126
|
|
|
112
|
-
export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata };
|
|
127
|
+
export { ActivityEventDataType, ActivityEvents_exports as ActivityEvents, DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, PresenceEventDataType, PresenceEvents_exports as PresenceEvents, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata, hasMetadata };
|
|
113
128
|
//# sourceMappingURL=index.js.map
|
|
114
129
|
//# 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","../../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}"]}
|
|
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 DOCUMENT_CREATE: \"documentCreate\",\n DOCUMENT_DESCRIPTION_UPDATE: \"documentDescriptionUpdate\",\n DOCUMENT_RENAME: \"documentRename\",\n DOCUMENT_SECURITY_UPDATE: \"documentSecurityUpdate\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n/**\n * Activity event emitted when a document is created.\n */\n\n/**\n * Activity event emitted when a document is renamed.\n */\n\n/**\n * Activity event emitted when a document's description is updated.\n */\n\n/**\n * Activity event emitted when a document's mandatory security is updated.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { justOnce } from \"@palantir/pack.core\";\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj, throwIfMissing = true) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n justOnce(\"getMetadata-fallback-warning\", () => {\n // eslint-disable-next-line no-console\n console.warn(\"Warning: Retrieved metadata using fallback symbol lookup. \" + \"This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. \" + \"Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.\");\n });\n return fallbackMetadata;\n }\n }\n }\n if (throwIfMissing) {\n throw new Error(\"Object does not have metadata\");\n }\n}\nexport function hasMetadata(obj) {\n if (obj == null || typeof obj !== \"object\") {\n return false;\n }\n return getMetadata(obj, false) != null;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActivityEventDataType } from \"../types/ActivityEvent.js\";\n/**\n * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.\n *\n * @param model The model to edit.\n * @param data The data to apply to the model.\n * @returns An edit description for the model.\n *\n * @example\n * ```ts\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, ActivityEvents.describeEdit(MyEventModel, {\n * myEventDataField: \"some value\",\n * foo: 42,\n * }));\n * ```\n */\nexport function describeEdit(model, data) {\n return {\n data,\n model\n };\n}\n\n/**\n * Type guard for custom event data.\n *\n * @param eventData The event data to check.\n * @returns true if the event data is a custom event, false otherwise.\n */\nexport function isCustom(eventData) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT;\n}\n\n/**\n * Type guard for custom event data for a specific model.\n *\n * @param eventData The event data from a {@link ActivityEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * docRef.onActivity((docRef, event) => {\n * if (!ActivityEvents.isEdit(event.eventData, MyEventModel)) {\n * return;\n * }\n *\n * console.log(\"Got event\", event.eventData.eventData.myField);\n * });\n * ```\n */\nexport function isEdit(eventData, model) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;\n}\n\n/**\n * Type guard for unknown activity event data. These are fired when a user\n * performs an action that is not recognized by this client.\n *\n * This may be due to application version mismatch, or new platform features for\n * example, and should generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === ActivityEventDataType.UNKNOWN;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PresenceEventDataType } from \"../types/PresenceEvent.js\";\n\n/**\n * Type guard for Arrived presence events. These are fired when a user comes online on a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isArrived(event.eventData)) {\n * console.log(`User ${event.userId} has arrived on the document.`);\n * }\n * ```\n */\nexport function isArrived(eventData) {\n return eventData.type === PresenceEventDataType.ARRIVED;\n}\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData, MyEventModel)) {\n * console.log(\"Got event\", event.eventData.data.myField);\n * }\n * ```\n */\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a custom event of some type, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData)) {\n * console.log(\"Got a custom event:\", event.eventData.model);\n * }\n * ```\n */\n\nexport function isCustom(eventData, model) {\n return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);\n}\n\n/**\n * Type guard for Departed presence events. These are fired when a user goes offline from a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a departed event, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isDeparted(event.eventData)) {\n * console.log(`User ${event.userId} has departed from the document.`);\n * }\n * ```\n */\nexport function isDeparted(eventData) {\n return eventData.type === PresenceEventDataType.DEPARTED;\n}\n\n/**\n * Type guard for unknown presence events. These are fired when a user performs an action that is not\n * recognized.\n * This may be due to application version mismatch, or new platform features for example, and should\n * generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === PresenceEventDataType.UNKNOWN;\n}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var pack_core = require('@palantir/pack.core');
|
|
4
|
+
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
4
6
|
var __export = (target, all) => {
|
|
5
7
|
for (var name in all)
|
|
@@ -9,6 +11,10 @@ var __export = (target, all) => {
|
|
|
9
11
|
// src/types/ActivityEvent.ts
|
|
10
12
|
var ActivityEventDataType = {
|
|
11
13
|
CUSTOM_EVENT: "customEvent",
|
|
14
|
+
DOCUMENT_CREATE: "documentCreate",
|
|
15
|
+
DOCUMENT_DESCRIPTION_UPDATE: "documentDescriptionUpdate",
|
|
16
|
+
DOCUMENT_RENAME: "documentRename",
|
|
17
|
+
DOCUMENT_SECURITY_UPDATE: "documentSecurityUpdate",
|
|
12
18
|
UNKNOWN: "unknown"
|
|
13
19
|
};
|
|
14
20
|
|
|
@@ -17,10 +23,8 @@ var DocumentRefBrand = Symbol("pack:DocumentRef");
|
|
|
17
23
|
|
|
18
24
|
// src/types/MediaRef.ts
|
|
19
25
|
var MediaRefBrand = Symbol("pack:MediaRef");
|
|
20
|
-
|
|
21
|
-
// src/types/Metadata.ts
|
|
22
26
|
var Metadata = Symbol("@palantir/pack.document-schema/metadata");
|
|
23
|
-
function getMetadata(obj) {
|
|
27
|
+
function getMetadata(obj, throwIfMissing = true) {
|
|
24
28
|
const directMetadata = obj[Metadata];
|
|
25
29
|
if (directMetadata != null) {
|
|
26
30
|
return directMetadata;
|
|
@@ -31,11 +35,22 @@ function getMetadata(obj) {
|
|
|
31
35
|
if (symbolKey.toString() === metadataString) {
|
|
32
36
|
const fallbackMetadata = obj[symbolKey];
|
|
33
37
|
if (fallbackMetadata != null) {
|
|
38
|
+
pack_core.justOnce("getMetadata-fallback-warning", () => {
|
|
39
|
+
console.warn("Warning: Retrieved metadata using fallback symbol lookup. This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.");
|
|
40
|
+
});
|
|
34
41
|
return fallbackMetadata;
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
|
-
|
|
45
|
+
if (throwIfMissing) {
|
|
46
|
+
throw new Error("Object does not have metadata");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function hasMetadata(obj) {
|
|
50
|
+
if (obj == null || typeof obj !== "object") {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return getMetadata(obj, false) != null;
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
// src/types/Model.ts
|
|
@@ -124,5 +139,6 @@ exports.RecordCollectionRefBrand = RecordCollectionRefBrand;
|
|
|
124
139
|
exports.RecordRefBrand = RecordRefBrand;
|
|
125
140
|
exports.UserRefBrand = UserRefBrand;
|
|
126
141
|
exports.getMetadata = getMetadata;
|
|
142
|
+
exports.hasMetadata = hasMetadata;
|
|
127
143
|
//# sourceMappingURL=index.cjs.map
|
|
128
144
|
//# sourceMappingURL=index.cjs.map
|
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","../../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}"]}
|
|
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":["justOnce","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 DOCUMENT_CREATE: \"documentCreate\",\n DOCUMENT_DESCRIPTION_UPDATE: \"documentDescriptionUpdate\",\n DOCUMENT_RENAME: \"documentRename\",\n DOCUMENT_SECURITY_UPDATE: \"documentSecurityUpdate\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Application specific custom activity event data, as described in a transaction edit,\n * using an application sdk's generated model types.\n *\n * @example\n * ```ts\n * const unsubscribe = docRef.onActivity((docRef, event) => {\n * console.log(\"Activity event:\", event);\n * });\n * // Submit an edit with a description to generate an activity event.\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, {\n * model: MyEventModel,\n * data: {\n * myDataField: \"some value\",\n * foo: 42,\n * },\n * });\n * ```\n */\n\n/**\n * Activity event emitted when a document is created.\n */\n\n/**\n * Activity event emitted when a document is renamed.\n */\n\n/**\n * Activity event emitted when a document's description is updated.\n */\n\n/**\n * Activity event emitted when a document's mandatory security is updated.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing an activity that has occurred on a document. This\n * includes standard document events as well as custom application-specific\n * events describing document edits.\n *\n * ActivityEvents are useful for building activity feeds, or notifications.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Options for subscribing to presence events on a document.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");\n\n/**\n * A reference to a document in the Pack system.\n *\n * A documentRef returned by various interfaces from the pack app instance or\n * utilities such as react hooks from @palantir/pack.state.react provides\n * methods to interact with the document, such as subscribing to & making\n * changes to the document state and also related activity or presence events.\n *\n * A stable documentRef object is guaranteed for the same document id within the\n * same app instance.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { justOnce } from \"@palantir/pack.core\";\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj, throwIfMissing = true) {\n // First try the direct symbol access\n const directMetadata = obj[Metadata];\n if (directMetadata != null) {\n return directMetadata;\n }\n\n // Fallback: search for a symbol with matching string representation\n // If the different copies of this package are used, the symbol references will not match directly\n const metadataString = Metadata.toString();\n const symbolKeys = Object.getOwnPropertySymbols(obj);\n for (const symbolKey of symbolKeys) {\n if (symbolKey.toString() === metadataString) {\n const fallbackMetadata = obj[symbolKey];\n if (fallbackMetadata != null) {\n justOnce(\"getMetadata-fallback-warning\", () => {\n // eslint-disable-next-line no-console\n console.warn(\"Warning: Retrieved metadata using fallback symbol lookup. \" + \"This may indicate that multiple copies of the @palantir/pack.document-schema.model-types package are in use. \" + \"Consider deduplicating your dependencies and checking bundle configurations to ensure proper behavior.\");\n });\n return fallbackMetadata;\n }\n }\n }\n if (throwIfMissing) {\n throw new Error(\"Object does not have metadata\");\n }\n}\nexport function hasMetadata(obj) {\n if (obj == null || typeof obj !== \"object\") {\n return false;\n }\n return getMetadata(obj, false) != null;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\n/**\n * Describes an edit made to a document.\n */\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const PresenceEventDataType = {\n ARRIVED: \"presenceArrived\",\n DEPARTED: \"presenceDeparted\",\n CUSTOM_EVENT: \"customEvent\",\n UNKNOWN: \"unknown\"\n};\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Any client that subscribes to presence events via `DocumentRef.onPresence` will\n * be considered 'present' on the document, and trigger an 'arrived' presence event.\n * When they disconnect or unsubscribe from presence events, a 'departed' presence event\n * will be triggered.\n */\n\n/**\n * Application specific custom presence event data.\n *\n * Each different model type used for presence is expected to update the latest\n * 'presence state' for that model type.\n *\n * For example, your app may have need to broadcast user cursor positions and\n * selection ranges as presence data. You could define your schema to include a\n * `CursorPosition` and `SelectionRange` record types, and set them\n * independently via `{@link DocumentRef.updateCustomPresence}`. Each model type\n * sent as a custom presence event should be considered a separate 'channel' of\n * presence data on this document.\n */\n\n/**\n * Fallback for unrecognized activity event types.\n *\n * This allows some flexibility with new event types added to the platform.\n * Likely unknown events represent a new platform event type and will be handled\n * in a future release of pack libraries and can be safely ignored by\n * applications.\n */\n\n/**\n * An event representing a transient awareness or presence change for a user on this document.\n * The presence channel is intended for ephemeral data such as user cursors, selections, or\n * other live collaboration indicators.\n *\n * PresenceEvents are not persisted in document history.\n *\n * When a client goes offline, its presence is considered departed and any presence events\n * associated with that user should be considered stale and / or cleared.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");\n\n/**\n * A reference providing an API to interact with a collection of records in a document.\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");\n\n/**\n * A reference providing an API to interact with a specific record in a\n * document. This is the main interface for accessing and updating individual\n * records.\n *\n * These will be created by docRef or recordCollectionRef APIs for example and\n * should not be created manually. RecordRefs are stable objects that can be\n * used for reference equality checks.\n *\n * @example\n * ```ts\n * import { DocumentRef, DocumentSchema, MyModel } from \"@myapp/schema\";\n * import { app } from \"./appInstance\";\n *\n * const docRef = app.getDocRef<DocumentSchema>(someDocumentId);\n *\n * const recordRef = docRef.getRecords(MyModel).set(\"my-record-id\", { myFieldName: \"some value\", foo: 42 });\n *\n * // Or get a specific record.\n * const recordRef = docRef.getRecords(MyModel).get(\"my-record-id\");\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");\n\n/**\n * A reference providing an API to interact with a user.\n *\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActivityEventDataType } from \"../types/ActivityEvent.js\";\n/**\n * Creates an edit description to describe an edit for activity purposes, for use with docRef.withTransaction.\n *\n * @param model The model to edit.\n * @param data The data to apply to the model.\n * @returns An edit description for the model.\n *\n * @example\n * ```ts\n * docRef.withTransaction(() => {\n * // make some edits to the document here\n * }, ActivityEvents.describeEdit(MyEventModel, {\n * myEventDataField: \"some value\",\n * foo: 42,\n * }));\n * ```\n */\nexport function describeEdit(model, data) {\n return {\n data,\n model\n };\n}\n\n/**\n * Type guard for custom event data.\n *\n * @param eventData The event data to check.\n * @returns true if the event data is a custom event, false otherwise.\n */\nexport function isCustom(eventData) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT;\n}\n\n/**\n * Type guard for custom event data for a specific model.\n *\n * @param eventData The event data from a {@link ActivityEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * docRef.onActivity((docRef, event) => {\n * if (!ActivityEvents.isEdit(event.eventData, MyEventModel)) {\n * return;\n * }\n *\n * console.log(\"Got event\", event.eventData.eventData.myField);\n * });\n * ```\n */\nexport function isEdit(eventData, model) {\n return eventData.type === ActivityEventDataType.CUSTOM_EVENT && eventData.model === model;\n}\n\n/**\n * Type guard for unknown activity event data. These are fired when a user\n * performs an action that is not recognized by this client.\n *\n * This may be due to application version mismatch, or new platform features for\n * example, and should generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === ActivityEventDataType.UNKNOWN;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { PresenceEventDataType } from \"../types/PresenceEvent.js\";\n\n/**\n * Type guard for Arrived presence events. These are fired when a user comes online on a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isArrived(event.eventData)) {\n * console.log(`User ${event.userId} has arrived on the document.`);\n * }\n * ```\n */\nexport function isArrived(eventData) {\n return eventData.type === PresenceEventDataType.ARRIVED;\n}\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @param model The model to check for.\n * @returns true if the event data is a custom event for the given model, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData, MyEventModel)) {\n * console.log(\"Got event\", event.eventData.data.myField);\n * }\n * ```\n */\n\n/**\n * Type guard for custom presence events.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a custom event of some type, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isCustom(event.eventData)) {\n * console.log(\"Got a custom event:\", event.eventData.model);\n * }\n * ```\n */\n\nexport function isCustom(eventData, model) {\n return eventData.type === PresenceEventDataType.CUSTOM_EVENT && (model == null || eventData.model === model);\n}\n\n/**\n * Type guard for Departed presence events. These are fired when a user goes offline from a document.\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is a departed event, false otherwise.\n *\n * @example\n * ```ts\n * if (PresenceEvents.isDeparted(event.eventData)) {\n * console.log(`User ${event.userId} has departed from the document.`);\n * }\n * ```\n */\nexport function isDeparted(eventData) {\n return eventData.type === PresenceEventDataType.DEPARTED;\n}\n\n/**\n * Type guard for unknown presence events. These are fired when a user performs an action that is not\n * recognized.\n * This may be due to application version mismatch, or new platform features for example, and should\n * generally be ignorable.\n *\n * @experimental\n *\n * @param eventData The event data from a {@link PresenceEvent} to check.\n * @returns true if the event data is an unknown event, false otherwise.\n */\nexport function isUnknown(eventData) {\n return eventData.type === PresenceEventDataType.UNKNOWN;\n}"]}
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -1,21 +1,61 @@
|
|
|
1
1
|
import { Flavored } from '@palantir/pack.core';
|
|
2
2
|
import { ZodType } from 'zod';
|
|
3
3
|
|
|
4
|
+
interface DiscretionaryPrincipal_All {
|
|
5
|
+
"type": "all";
|
|
6
|
+
}
|
|
7
|
+
interface DiscretionaryPrincipal_UserId {
|
|
8
|
+
"type": "userId";
|
|
9
|
+
"userId": string;
|
|
10
|
+
}
|
|
11
|
+
interface DiscretionaryPrincipal_GroupId {
|
|
12
|
+
"groupId": string;
|
|
13
|
+
"type": "groupId";
|
|
14
|
+
}
|
|
15
|
+
type DiscretionaryPrincipal = DiscretionaryPrincipal_All | DiscretionaryPrincipal_GroupId | DiscretionaryPrincipal_UserId;
|
|
16
|
+
interface DocumentSecurityDiscretionary {
|
|
17
|
+
readonly editors?: readonly DiscretionaryPrincipal[];
|
|
18
|
+
readonly owners?: readonly DiscretionaryPrincipal[];
|
|
19
|
+
readonly viewers?: readonly DiscretionaryPrincipal[];
|
|
20
|
+
}
|
|
21
|
+
interface DocumentSecurityMandatory {
|
|
22
|
+
readonly classification?: readonly string[];
|
|
23
|
+
readonly markings?: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
interface DocumentSecurity {
|
|
26
|
+
readonly discretionary: DocumentSecurityDiscretionary;
|
|
27
|
+
readonly mandatory: DocumentSecurityMandatory;
|
|
28
|
+
}
|
|
29
|
+
interface DocumentMetadata {
|
|
30
|
+
readonly createdBy?: string;
|
|
31
|
+
readonly createdTime?: string;
|
|
32
|
+
readonly documentTypeName: string;
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly ontologyRid: string;
|
|
35
|
+
readonly security: DocumentSecurity;
|
|
36
|
+
readonly updatedBy?: string;
|
|
37
|
+
readonly updatedTime?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
4
40
|
declare const Metadata: symbol;
|
|
5
41
|
interface WithMetadata<T> {
|
|
6
42
|
readonly [Metadata]: T;
|
|
7
43
|
}
|
|
8
|
-
declare function getMetadata<T>(obj: WithMetadata<T
|
|
44
|
+
declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing?: true): T;
|
|
45
|
+
declare function getMetadata<T>(obj: WithMetadata<T>, throwIfMissing: false): T | undefined;
|
|
46
|
+
declare function hasMetadata(obj: unknown): obj is WithMetadata<unknown>;
|
|
9
47
|
|
|
10
48
|
/**
|
|
11
49
|
* A Model defines the structure of a document record or union.
|
|
12
50
|
*
|
|
13
51
|
* It includes a zod schema for validation and type information.
|
|
14
52
|
*/
|
|
15
|
-
interface Model<T = unknown, Z extends ZodType<T> = ZodType<T
|
|
53
|
+
interface Model<T = unknown, Z extends ZodType<T> = ZodType<T>, M extends ModelMetadata<T> = ModelMetadata<T>> extends WithMetadata<M> {
|
|
16
54
|
readonly __type: T;
|
|
17
55
|
readonly zodSchema: Readonly<Z>;
|
|
18
56
|
}
|
|
57
|
+
type RecordModel<T = unknown, Z extends ZodType<T> = ZodType<T>> = Model<T, Z, RecordModelMetadata<T>>;
|
|
58
|
+
type UnionModel<T = unknown, Z extends ZodType<T> = ZodType<T>> = Model<T, Z, UnionModelMetadata<T>>;
|
|
19
59
|
type ModelData<M extends Model> = M["__type"];
|
|
20
60
|
/**
|
|
21
61
|
* Describes an edit made to a document.
|
|
@@ -31,7 +71,7 @@ declare const ExternalRefType: {
|
|
|
31
71
|
readonly USER_REF: "userRef";
|
|
32
72
|
};
|
|
33
73
|
type ExternalRefType = typeof ExternalRefType[keyof typeof ExternalRefType];
|
|
34
|
-
interface
|
|
74
|
+
interface RecordModelMetadata<T = unknown> {
|
|
35
75
|
/**
|
|
36
76
|
* Which fields in the model are external references (e.g. UserRef, DocumentRef, etc).
|
|
37
77
|
*/
|
|
@@ -41,6 +81,17 @@ interface ModelMetadata<T = unknown> {
|
|
|
41
81
|
*/
|
|
42
82
|
readonly name: string;
|
|
43
83
|
}
|
|
84
|
+
interface UnionModelMetadata<T = unknown> {
|
|
85
|
+
/**
|
|
86
|
+
* The field name used to discriminate between union variants.
|
|
87
|
+
*/
|
|
88
|
+
readonly discriminant: keyof T;
|
|
89
|
+
/**
|
|
90
|
+
* The name of the model (should match the typescript symbol).
|
|
91
|
+
*/
|
|
92
|
+
readonly name: string;
|
|
93
|
+
}
|
|
94
|
+
type ModelMetadata<T = unknown> = RecordModelMetadata<T> | UnionModelMetadata<T>;
|
|
44
95
|
|
|
45
96
|
type UserId = Flavored<"pack:UserId">;
|
|
46
97
|
declare const UserRefBrand: unique symbol;
|
|
@@ -58,6 +109,10 @@ interface UserRef {
|
|
|
58
109
|
type ActivityEventId = Flavored<"pack:EventId">;
|
|
59
110
|
declare const ActivityEventDataType: {
|
|
60
111
|
readonly CUSTOM_EVENT: "customEvent";
|
|
112
|
+
readonly DOCUMENT_CREATE: "documentCreate";
|
|
113
|
+
readonly DOCUMENT_DESCRIPTION_UPDATE: "documentDescriptionUpdate";
|
|
114
|
+
readonly DOCUMENT_RENAME: "documentRename";
|
|
115
|
+
readonly DOCUMENT_SECURITY_UPDATE: "documentSecurityUpdate";
|
|
61
116
|
readonly UNKNOWN: "unknown";
|
|
62
117
|
};
|
|
63
118
|
/**
|
|
@@ -86,6 +141,42 @@ interface ActivityEventDataCustom<M extends Model = Model> {
|
|
|
86
141
|
readonly model: M;
|
|
87
142
|
readonly eventData: ModelData<M>;
|
|
88
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Activity event emitted when a document is created.
|
|
146
|
+
*/
|
|
147
|
+
interface ActivityEventDataDocumentCreate {
|
|
148
|
+
readonly type: typeof ActivityEventDataType.DOCUMENT_CREATE;
|
|
149
|
+
readonly initialMandatorySecurity: DocumentSecurityMandatory;
|
|
150
|
+
readonly name: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Activity event emitted when a document is renamed.
|
|
154
|
+
*/
|
|
155
|
+
interface ActivityEventDataDocumentRename {
|
|
156
|
+
readonly type: typeof ActivityEventDataType.DOCUMENT_RENAME;
|
|
157
|
+
readonly previousName: string;
|
|
158
|
+
readonly newName: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Activity event emitted when a document's description is updated.
|
|
162
|
+
*/
|
|
163
|
+
interface ActivityEventDataDocumentDescriptionUpdate {
|
|
164
|
+
readonly type: typeof ActivityEventDataType.DOCUMENT_DESCRIPTION_UPDATE;
|
|
165
|
+
readonly newDescription: string;
|
|
166
|
+
/**
|
|
167
|
+
* True if this is the first time the description is being set,
|
|
168
|
+
* false if updating an existing description.
|
|
169
|
+
*/
|
|
170
|
+
readonly isInitial: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Activity event emitted when a document's mandatory security is updated.
|
|
174
|
+
*/
|
|
175
|
+
interface ActivityEventDataDocumentSecurityUpdate {
|
|
176
|
+
readonly type: typeof ActivityEventDataType.DOCUMENT_SECURITY_UPDATE;
|
|
177
|
+
readonly newClassification: readonly string[];
|
|
178
|
+
readonly newMarkings: readonly string[];
|
|
179
|
+
}
|
|
89
180
|
/**
|
|
90
181
|
* Fallback for unrecognized activity event types.
|
|
91
182
|
*
|
|
@@ -99,7 +190,7 @@ interface ActivityEventDataUnknown {
|
|
|
99
190
|
readonly rawType: string;
|
|
100
191
|
readonly rawData: unknown;
|
|
101
192
|
}
|
|
102
|
-
type ActivityEventData = ActivityEventDataCustom | ActivityEventDataUnknown;
|
|
193
|
+
type ActivityEventData = ActivityEventDataCustom | ActivityEventDataDocumentCreate | ActivityEventDataDocumentDescriptionUpdate | ActivityEventDataDocumentRename | ActivityEventDataDocumentSecurityUpdate | ActivityEventDataUnknown;
|
|
103
194
|
/**
|
|
104
195
|
* An event representing an activity that has occurred on a document. This
|
|
105
196
|
* includes standard document events as well as custom application-specific
|
|
@@ -117,36 +208,6 @@ interface ActivityEvent {
|
|
|
117
208
|
readonly isRead: boolean;
|
|
118
209
|
}
|
|
119
210
|
|
|
120
|
-
interface DiscretionaryPrincipal_All {
|
|
121
|
-
"all": Record<string, never>;
|
|
122
|
-
"type": "all";
|
|
123
|
-
}
|
|
124
|
-
interface DiscretionaryPrincipal_UserId {
|
|
125
|
-
"type": "userId";
|
|
126
|
-
"userId": string;
|
|
127
|
-
}
|
|
128
|
-
interface DiscretionaryPrincipal_GroupId {
|
|
129
|
-
"groupId": string;
|
|
130
|
-
"type": "groupId";
|
|
131
|
-
}
|
|
132
|
-
type DiscretionaryPrincipal = DiscretionaryPrincipal_All | DiscretionaryPrincipal_GroupId | DiscretionaryPrincipal_UserId;
|
|
133
|
-
interface DocumentMetadata {
|
|
134
|
-
readonly documentTypeName: string;
|
|
135
|
-
readonly name: string;
|
|
136
|
-
readonly ontologyRid: string;
|
|
137
|
-
readonly security: {
|
|
138
|
-
readonly discretionary: {
|
|
139
|
-
readonly editors?: readonly DiscretionaryPrincipal[];
|
|
140
|
-
readonly owners: readonly DiscretionaryPrincipal[];
|
|
141
|
-
readonly viewers?: readonly DiscretionaryPrincipal[];
|
|
142
|
-
};
|
|
143
|
-
readonly mandatory: {
|
|
144
|
-
readonly classification?: readonly string[];
|
|
145
|
-
readonly markings?: readonly string[];
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
211
|
/**
|
|
151
212
|
* The base type for an application sdk's generated document schema.
|
|
152
213
|
*/
|
|
@@ -781,4 +842,4 @@ declare namespace PresenceEvents {
|
|
|
781
842
|
export { PresenceEvents_isArrived as isArrived, PresenceEvents_isCustom as isCustom, PresenceEvents_isDeparted as isDeparted, PresenceEvents_isUnknown as isUnknown };
|
|
782
843
|
}
|
|
783
844
|
|
|
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 };
|
|
845
|
+
export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, type ActivityEventDataDocumentCreate, type ActivityEventDataDocumentDescriptionUpdate, type ActivityEventDataDocumentRename, type ActivityEventDataDocumentSecurityUpdate, 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 DocumentSecurity, type DocumentSecurityDiscretionary, type DocumentSecurityMandatory, 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 RecordModel, type RecordRef, RecordRefBrand, type UnionModel, type Unsubscribe, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata, hasMetadata };
|