@palantir/pack.state.foundry 0.9.0 → 0.11.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 +1 -1
- package/.turbo/turbo-transpileCjs.log +1 -1
- package/.turbo/turbo-transpileEsm.log +1 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +24 -0
- package/build/browser/index.js +64 -68
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +62 -66
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/index.js +64 -68
- package/build/esm/index.js.map +1 -1
- package/build/types/FoundryDocumentService.d.ts +2 -3
- package/build/types/FoundryDocumentService.d.ts.map +1 -1
- package/build/types/__tests__/eventMappers.test.d.ts +1 -0
- package/build/types/__tests__/eventMappers.test.d.ts.map +1 -0
- package/build/types/eventMappers.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/FoundryDocumentService.ts +22 -20
- package/src/__tests__/FoundrySecurityConversion.test.ts +1 -0
- package/src/__tests__/FoundryStatusTracking.test.ts +7 -1
- package/src/__tests__/eventMappers.test.ts +258 -0
- package/src/eventMappers.ts +47 -105
package/src/eventMappers.ts
CHANGED
|
@@ -29,7 +29,6 @@ import type {
|
|
|
29
29
|
ActivityEventDataDocumentMandatorySecurityUpdate,
|
|
30
30
|
ActivityEventDataDocumentRename,
|
|
31
31
|
DocumentSchema,
|
|
32
|
-
DocumentSecurityDiscretionary,
|
|
33
32
|
Model,
|
|
34
33
|
ModelData,
|
|
35
34
|
PresenceEvent,
|
|
@@ -64,136 +63,79 @@ export function getActivityEvent(
|
|
|
64
63
|
};
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
/**
|
|
68
|
-
* Platform event type names as sent by backpack.
|
|
69
|
-
* Note: Only DOCUMENT_CREATE is currently emitted by the backend.
|
|
70
|
-
* Remaining types are included for future use.
|
|
71
|
-
*/
|
|
72
|
-
const PlatformEventType = {
|
|
73
|
-
DOCUMENT_CREATE: "DocumentCreateEvent",
|
|
74
|
-
DOCUMENT_DESCRIPTION_UPDATE: "DocumentDescriptionUpdateEvent",
|
|
75
|
-
DOCUMENT_RENAME: "DocumentRenameEvent",
|
|
76
|
-
DOCUMENT_MANDATORY_SECURITY_UPDATE: "DocumentMandatorySecurityUpdateEvent",
|
|
77
|
-
DOCUMENT_DISCRETIONARY_SECURITY_UPDATE: "DocumentDiscretionarySecurityUpdateEvent",
|
|
78
|
-
} as const;
|
|
79
|
-
|
|
80
|
-
interface WireDocumentCreateEvent {
|
|
81
|
-
readonly name?: string;
|
|
82
|
-
readonly initialMandatorySecurity?: {
|
|
83
|
-
readonly classification?: readonly string[];
|
|
84
|
-
readonly markings?: readonly string[];
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface WireDocumentRenameEvent {
|
|
89
|
-
readonly previousName?: string;
|
|
90
|
-
readonly newName?: string;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface WireDocumentDescriptionUpdateEvent {
|
|
94
|
-
readonly newDescription?: string;
|
|
95
|
-
readonly isInitial?: boolean;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
interface WireDocumentMandatorySecurityUpdateEvent {
|
|
99
|
-
readonly newClassification?: readonly string[];
|
|
100
|
-
readonly newMarkings?: readonly string[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
interface WireDocumentDiscretionarySecurityUpdateEvent {
|
|
104
|
-
readonly principalType: "ALL_PRINCIPAL" | "USER";
|
|
105
|
-
readonly previousDiscretionarySecurity?: DocumentSecurityDiscretionary;
|
|
106
|
-
readonly newDiscretionarySecurity: DocumentSecurityDiscretionary;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
66
|
function getActivityEventData(
|
|
110
67
|
docSchema: DocumentSchema,
|
|
111
|
-
{ eventData
|
|
68
|
+
{ eventData }: FoundryActivityEvent,
|
|
112
69
|
): ActivityEventData {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
eventData.data,
|
|
116
|
-
);
|
|
117
|
-
if (platformEventData != null) {
|
|
118
|
-
return platformEventData;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Handle custom application-defined activity events
|
|
122
|
-
// TODO: validate model is valid for activity events
|
|
123
|
-
const model = docSchema[eventType];
|
|
124
|
-
if (model == null) {
|
|
125
|
-
return {
|
|
126
|
-
rawData: eventData.data,
|
|
127
|
-
rawType: eventType,
|
|
128
|
-
type: ActivityEventDataType.UNKNOWN,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// TODO: validate data against model schema
|
|
133
|
-
|
|
134
|
-
return {
|
|
135
|
-
eventData: eventData.data as ModelData<Model>,
|
|
136
|
-
model,
|
|
137
|
-
type: ActivityEventDataType.CUSTOM_EVENT,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function getPlatformActivityEventData(
|
|
142
|
-
eventType: string,
|
|
143
|
-
data: unknown,
|
|
144
|
-
): ActivityEventData | undefined {
|
|
145
|
-
switch (eventType) {
|
|
146
|
-
case PlatformEventType.DOCUMENT_CREATE: {
|
|
147
|
-
const wireData = data as WireDocumentCreateEvent;
|
|
70
|
+
switch (eventData.type) {
|
|
71
|
+
case "documentCreate":
|
|
148
72
|
return {
|
|
149
73
|
initialMandatorySecurity: {
|
|
150
|
-
classification:
|
|
151
|
-
markings:
|
|
74
|
+
classification: eventData.initialMandatorySecurity?.classification,
|
|
75
|
+
markings: eventData.initialMandatorySecurity?.markings,
|
|
152
76
|
},
|
|
153
|
-
name:
|
|
77
|
+
name: eventData.name ?? "",
|
|
154
78
|
type: ActivityEventDataType.DOCUMENT_CREATE,
|
|
155
79
|
} satisfies ActivityEventDataDocumentCreate;
|
|
156
|
-
}
|
|
157
80
|
|
|
158
|
-
case
|
|
159
|
-
const wireData = data as WireDocumentRenameEvent;
|
|
81
|
+
case "documentRename":
|
|
160
82
|
return {
|
|
161
|
-
newName:
|
|
162
|
-
previousName:
|
|
83
|
+
newName: eventData.newName ?? "",
|
|
84
|
+
previousName: eventData.previousName ?? "",
|
|
163
85
|
type: ActivityEventDataType.DOCUMENT_RENAME,
|
|
164
86
|
} satisfies ActivityEventDataDocumentRename;
|
|
165
|
-
}
|
|
166
87
|
|
|
167
|
-
case
|
|
168
|
-
const wireData = data as WireDocumentDescriptionUpdateEvent;
|
|
88
|
+
case "documentDescriptionUpdate":
|
|
169
89
|
return {
|
|
170
|
-
isInitial:
|
|
171
|
-
newDescription:
|
|
90
|
+
isInitial: eventData.isInitial ?? false,
|
|
91
|
+
newDescription: eventData.newDescription ?? "",
|
|
172
92
|
type: ActivityEventDataType.DOCUMENT_DESCRIPTION_UPDATE,
|
|
173
93
|
} satisfies ActivityEventDataDocumentDescriptionUpdate;
|
|
174
|
-
}
|
|
175
94
|
|
|
176
|
-
case
|
|
177
|
-
const wireData = data as WireDocumentMandatorySecurityUpdateEvent;
|
|
95
|
+
case "documentMandatorySecurityUpdate":
|
|
178
96
|
return {
|
|
179
|
-
newClassification:
|
|
180
|
-
newMarkings:
|
|
97
|
+
newClassification: eventData.newClassification ?? [],
|
|
98
|
+
newMarkings: eventData.newMarkings ?? [],
|
|
181
99
|
type: ActivityEventDataType.DOCUMENT_MANDATORY_SECURITY_UPDATE,
|
|
182
100
|
} satisfies ActivityEventDataDocumentMandatorySecurityUpdate;
|
|
183
|
-
}
|
|
184
101
|
|
|
185
|
-
case
|
|
186
|
-
const wireData = data as WireDocumentDiscretionarySecurityUpdateEvent;
|
|
102
|
+
case "documentDiscretionarySecurityUpdate":
|
|
187
103
|
return {
|
|
188
|
-
principalType:
|
|
189
|
-
previousDiscretionarySecurity:
|
|
190
|
-
newDiscretionarySecurity:
|
|
104
|
+
principalType: eventData.principalType ?? "",
|
|
105
|
+
previousDiscretionarySecurity: eventData.previousDiscretionarySecurity,
|
|
106
|
+
newDiscretionarySecurity: eventData.newDiscretionarySecurity ?? [],
|
|
191
107
|
type: ActivityEventDataType.DOCUMENT_DISCRETIONARY_SECURITY_UPDATE,
|
|
192
108
|
} satisfies ActivityEventDataDocumentDiscretionarySecurityUpdate;
|
|
109
|
+
|
|
110
|
+
case "documentCustomEvent": {
|
|
111
|
+
const { eventType, data } = eventData;
|
|
112
|
+
// TODO: validate model is valid for activity events
|
|
113
|
+
const model = docSchema[eventType];
|
|
114
|
+
if (model == null) {
|
|
115
|
+
return {
|
|
116
|
+
rawData: data,
|
|
117
|
+
rawType: eventType,
|
|
118
|
+
type: ActivityEventDataType.UNKNOWN,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// TODO: validate data against model schema
|
|
123
|
+
return {
|
|
124
|
+
data: data as ModelData<Model>,
|
|
125
|
+
eventType,
|
|
126
|
+
model,
|
|
127
|
+
type: ActivityEventDataType.CUSTOM_EVENT,
|
|
128
|
+
};
|
|
193
129
|
}
|
|
194
130
|
|
|
195
|
-
default:
|
|
196
|
-
|
|
131
|
+
default: {
|
|
132
|
+
const unknownEventData = eventData as Record<string, unknown>;
|
|
133
|
+
return {
|
|
134
|
+
rawData: eventData,
|
|
135
|
+
rawType: typeof unknownEventData.type === "string" ? unknownEventData.type : "unknown",
|
|
136
|
+
type: ActivityEventDataType.UNKNOWN,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
197
139
|
}
|
|
198
140
|
}
|
|
199
141
|
|