@palantir/pack.document-schema.model-types 0.6.0 → 0.8.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 +15 -0
- package/build/cjs/index.d.cts +70 -2
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/ActivityEvent.d.ts +2 -1
- package/build/types/types/ActivityEvent.d.ts.map +1 -1
- package/build/types/types/DocumentMetadata.d.ts +8 -0
- package/build/types/types/DocumentMetadata.d.ts.map +1 -1
- package/build/types/types/DocumentSchema.d.ts +3 -0
- package/build/types/types/DocumentSchema.d.ts.map +1 -1
- package/build/types/types/UpgradeLens.d.ts +56 -0
- package/build/types/types/UpgradeLens.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +11 -0
- package/src/types/ActivityEvent.ts +2 -1
- package/src/types/DocumentMetadata.ts +9 -0
- package/src/types/DocumentSchema.ts +3 -0
- package/src/types/UpgradeLens.ts +70 -0
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.8.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,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.8.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
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`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.8.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
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`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.8.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
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`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.8.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.8.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,20 @@
|
|
|
1
1
|
# @palantir/pack.document-schema.model-types
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2b00422: Add 'gen-types' command, along with scope, metadata and manifest generators
|
|
8
|
+
- 222e157: Wire in lens upgrade registry to reads in the yjs layer
|
|
9
|
+
- ad7a355: Add UpgradeLens utilities
|
|
10
|
+
- 792a1b0: Add new 'gen-types' command, direct from TS schema to Versioned SDK Types.
|
|
11
|
+
|
|
12
|
+
## 0.7.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- 2ccb561: Update activity event types and add document operations to metadata
|
|
17
|
+
|
|
3
18
|
## 0.6.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -26,13 +26,21 @@ interface DocumentSecurity {
|
|
|
26
26
|
readonly discretionary: DocumentSecurityDiscretionary;
|
|
27
27
|
readonly mandatory: DocumentSecurityMandatory;
|
|
28
28
|
}
|
|
29
|
+
type DocumentOperation = "VIEW" | "EDIT" | "OWN" | "DELETE";
|
|
29
30
|
interface DocumentMetadata {
|
|
30
31
|
readonly createdBy?: string;
|
|
31
32
|
readonly createdTime?: string;
|
|
32
33
|
readonly description?: string;
|
|
33
34
|
readonly documentTypeName: string;
|
|
34
35
|
readonly name: string;
|
|
36
|
+
readonly operations?: readonly DocumentOperation[];
|
|
35
37
|
readonly ontologyRid: string;
|
|
38
|
+
/**
|
|
39
|
+
* The schema version this document is currently operating at.
|
|
40
|
+
* All connected clients must read and write at this version.
|
|
41
|
+
* Set by the backend; only increases (one-way ratchet).
|
|
42
|
+
*/
|
|
43
|
+
readonly schemaVersion?: number;
|
|
36
44
|
readonly security: DocumentSecurity;
|
|
37
45
|
readonly updatedBy?: string;
|
|
38
46
|
readonly updatedTime?: string;
|
|
@@ -141,7 +149,8 @@ declare const ActivityEventDataType: {
|
|
|
141
149
|
interface ActivityEventDataCustom<M extends Model = Model> {
|
|
142
150
|
readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
|
|
143
151
|
readonly model: M;
|
|
144
|
-
readonly
|
|
152
|
+
readonly eventType: string;
|
|
153
|
+
readonly data: ModelData<M>;
|
|
145
154
|
}
|
|
146
155
|
/**
|
|
147
156
|
* Activity event emitted when a document is created.
|
|
@@ -219,6 +228,63 @@ interface ActivityEvent {
|
|
|
219
228
|
readonly isRead: boolean;
|
|
220
229
|
}
|
|
221
230
|
|
|
231
|
+
/** Type descriptor for a field, enabling recursive lens application. */
|
|
232
|
+
type FieldTypeDescriptor = {
|
|
233
|
+
kind: "primitive";
|
|
234
|
+
} | {
|
|
235
|
+
kind: "modelRef";
|
|
236
|
+
model: string;
|
|
237
|
+
} | {
|
|
238
|
+
kind: "array";
|
|
239
|
+
element: FieldTypeDescriptor;
|
|
240
|
+
} | {
|
|
241
|
+
kind: "map";
|
|
242
|
+
value: FieldTypeDescriptor;
|
|
243
|
+
} | {
|
|
244
|
+
kind: "optional";
|
|
245
|
+
inner: FieldTypeDescriptor;
|
|
246
|
+
};
|
|
247
|
+
interface FieldLensDef {
|
|
248
|
+
/**
|
|
249
|
+
* Source field names. `forward` receives only these fields, not the full record.
|
|
250
|
+
* When empty, the field is additive — only `default` applies and `forward` is never called.
|
|
251
|
+
*/
|
|
252
|
+
derivedFrom: string[];
|
|
253
|
+
forward: (oldFields: Record<string, unknown>) => unknown;
|
|
254
|
+
default?: unknown;
|
|
255
|
+
}
|
|
256
|
+
interface FieldDef {
|
|
257
|
+
type: FieldTypeDescriptor;
|
|
258
|
+
default?: unknown;
|
|
259
|
+
}
|
|
260
|
+
interface UpgradeStepDef {
|
|
261
|
+
name: string;
|
|
262
|
+
addedInVersion: number;
|
|
263
|
+
fields: Record<string, FieldLensDef>;
|
|
264
|
+
removedFields?: string[];
|
|
265
|
+
}
|
|
266
|
+
interface UpgradeRegistry<ModelName extends string = string> {
|
|
267
|
+
modelName: ModelName;
|
|
268
|
+
/** All fields in the current schema (not just upgraded ones). Drives recursive lens application on nested types. */
|
|
269
|
+
allFields: Record<string, FieldDef>;
|
|
270
|
+
/** Must be in version order — the lens walks them sequentially. */
|
|
271
|
+
steps: UpgradeStepDef[];
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Upgrade registry for union models. Instead of having its own fields/steps,
|
|
275
|
+
* a union delegates to the variant's UpgradeRegistry based on the discriminant
|
|
276
|
+
* value in the data.
|
|
277
|
+
*/
|
|
278
|
+
interface UnionUpgradeRegistry<ModelName extends string = string> {
|
|
279
|
+
modelName: ModelName;
|
|
280
|
+
/** The field name used to discriminate between variants. */
|
|
281
|
+
discriminant: string;
|
|
282
|
+
/** Maps discriminant values to variant model names in the UpgradeRegistryMap. */
|
|
283
|
+
variants: Record<string, string>;
|
|
284
|
+
}
|
|
285
|
+
type UpgradeRegistryEntry = UpgradeRegistry | UnionUpgradeRegistry;
|
|
286
|
+
type UpgradeRegistryMap = Record<string, UpgradeRegistryEntry>;
|
|
287
|
+
|
|
222
288
|
/**
|
|
223
289
|
* The base type for an application sdk's generated document schema.
|
|
224
290
|
*/
|
|
@@ -235,6 +301,8 @@ type DocumentState<S extends DocumentSchema> = {
|
|
|
235
301
|
};
|
|
236
302
|
interface DocumentSchemaMetadata {
|
|
237
303
|
readonly version: number;
|
|
304
|
+
readonly minSupportedVersion?: number;
|
|
305
|
+
readonly upgrades?: UpgradeRegistryMap;
|
|
238
306
|
}
|
|
239
307
|
|
|
240
308
|
declare const PresenceEventDataType: {
|
|
@@ -866,4 +934,4 @@ declare namespace PresenceEvents {
|
|
|
866
934
|
export { PresenceEvents_isArrived as isArrived, PresenceEvents_isCustom as isCustom, PresenceEvents_isDeparted as isDeparted, PresenceEvents_isUnknown as isUnknown };
|
|
867
935
|
}
|
|
868
936
|
|
|
869
|
-
export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, type ActivityEventDataDocumentCreate, type ActivityEventDataDocumentDescriptionUpdate, type ActivityEventDataDocumentDiscretionarySecurityUpdate, type ActivityEventDataDocumentMandatorySecurityUpdate, type ActivityEventDataDocumentRename, 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 PresencePublishOptions, 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 };
|
|
937
|
+
export { type ActivityEvent, type ActivityEventData, type ActivityEventDataCustom, type ActivityEventDataDocumentCreate, type ActivityEventDataDocumentDescriptionUpdate, type ActivityEventDataDocumentDiscretionarySecurityUpdate, type ActivityEventDataDocumentMandatorySecurityUpdate, type ActivityEventDataDocumentRename, ActivityEventDataType, type ActivityEventDataUnknown, type ActivityEventId, ActivityEvents, type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentOperation, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentSecurity, type DocumentSecurityDiscretionary, type DocumentSecurityMandatory, type DocumentState, type EditDescription, ExternalRefType, type FieldDef, type FieldLensDef, type FieldTypeDescriptor, 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 PresencePublishOptions, type PresenceSubscriptionOptions, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, type RecordModel, type RecordRef, RecordRefBrand, type UnionModel, type UnionUpgradeRegistry, type Unsubscribe, type UpgradeRegistry, type UpgradeRegistryEntry, type UpgradeRegistryMap, type UpgradeStepDef, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata, hasMetadata };
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ActivityEventDataType } from "./types/ActivityEvent.js";
|
|
2
2
|
export type { ActivityEvent, ActivityEventData, ActivityEventDataCustom, ActivityEventDataDocumentCreate, ActivityEventDataDocumentDescriptionUpdate, ActivityEventDataDocumentDiscretionarySecurityUpdate, ActivityEventDataDocumentMandatorySecurityUpdate, ActivityEventDataDocumentRename, ActivityEventDataUnknown, ActivityEventId } from "./types/ActivityEvent.js";
|
|
3
|
-
export type { DiscretionaryPrincipal, DiscretionaryPrincipal_All, DiscretionaryPrincipal_GroupId, DiscretionaryPrincipal_UserId, DocumentMetadata, DocumentSecurity, DocumentSecurityDiscretionary, DocumentSecurityMandatory } from "./types/DocumentMetadata.js";
|
|
3
|
+
export type { DiscretionaryPrincipal, DiscretionaryPrincipal_All, DiscretionaryPrincipal_GroupId, DiscretionaryPrincipal_UserId, DocumentMetadata, DocumentOperation, DocumentSecurity, DocumentSecurityDiscretionary, DocumentSecurityMandatory } from "./types/DocumentMetadata.js";
|
|
4
4
|
export { DocumentRefBrand } from "./types/DocumentRef.js";
|
|
5
5
|
export type { DocumentId, DocumentRef, PresencePublishOptions, PresenceSubscriptionOptions } from "./types/DocumentRef.js";
|
|
6
6
|
export type { DocumentSchema, DocumentSchemaMetadata, DocumentState } from "./types/DocumentSchema.js";
|
|
@@ -19,6 +19,7 @@ export type { RecordCollectionRef } from "./types/RecordCollectionRef.js";
|
|
|
19
19
|
export { RecordRefBrand } from "./types/RecordRef.js";
|
|
20
20
|
export type { RecordId, RecordRef } from "./types/RecordRef.js";
|
|
21
21
|
export type { Unsubscribe } from "./types/Unsubscribe.js";
|
|
22
|
+
export type { FieldDef, FieldLensDef, FieldTypeDescriptor, UnionUpgradeRegistry, UpgradeRegistry, UpgradeRegistryEntry, UpgradeRegistryMap, UpgradeStepDef } from "./types/UpgradeLens.js";
|
|
22
23
|
export { UserRefBrand } from "./types/UserRef.js";
|
|
23
24
|
export type { UserId, UserRef } from "./types/UserRef.js";
|
|
24
25
|
export * as ActivityEvents from "./utils/ActivityEvents.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,iCACA,4CACA,sDACA,kDACA,iCACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,kBACA,kBACA,+BACA,iCACK;AACP,SAAS,wBAAwB;AACjC,cACE,YACA,aACA,wBACA,mCACK;AACP,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,aAAa,gBAAgB;AACnD,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cACE,iBACA,OACA,WACA,eACA,aACA,kBACK;AACP,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,0BACA,yBACA,2BACA,gCACK;AACP,SAAS,gCAAgC;AACzC,cAAc,2BAA2B;AACzC,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,cAAc,mBAAmB;AACjC,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe;AACrC,YAAY,oBAAoB;AAChC,YAAY,oBAAoB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,yBACA,iCACA,4CACA,sDACA,kDACA,iCACA,0BACA,uBACK;AACP,cACE,wBACA,4BACA,gCACA,+BACA,kBACA,mBACA,kBACA,+BACA,iCACK;AACP,SAAS,wBAAwB;AACjC,cACE,YACA,aACA,wBACA,mCACK;AACP,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,aAAa,gBAAgB;AACnD,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cACE,iBACA,OACA,WACA,eACA,aACA,kBACK;AACP,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,SAAS,6BAA6B;AACtC,cACE,eACA,mBACA,0BACA,yBACA,2BACA,gCACK;AACP,SAAS,gCAAgC;AACzC,cAAc,2BAA2B;AACzC,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,cAAc,mBAAmB;AACjC,cACE,UACA,cACA,qBACA,sBACA,iBACA,sBACA,oBACA,sBACK;AACP,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe;AACrC,YAAY,oBAAoB;AAChC,YAAY,oBAAoB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -36,7 +36,8 @@ export declare const ActivityEventDataType: {
|
|
|
36
36
|
export interface ActivityEventDataCustom<M extends Model = Model> {
|
|
37
37
|
readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
|
|
38
38
|
readonly model: M;
|
|
39
|
-
readonly
|
|
39
|
+
readonly eventType: string;
|
|
40
|
+
readonly data: ModelData<M>;
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* Activity event emitted when a document is created.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cACE,+BACA,iCACK;AACP,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,iBAAiB;UACjB,6BAA6B;UAC7B,iBAAiB;UACjB,oCAAoC;UACpC,wCAAwC;UACxC,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP,
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cACE,+BACA,iCACK;AACP,cAAc,OAAO,iBAAiB;AACtC,cAAc,cAAc;AAE5B,YAAY,kBAAkB,SAAS;AAEvC,OAAO,cAAM;UACX,cAAc;UACd,iBAAiB;UACjB,6BAA6B;UAC7B,iBAAiB;UACjB,oCAAoC;UACpC,wCAAwC;UACxC,SAAS;;;;;;;;;;;;;;;;;;;;;;;AAwBX,iBAAiB,wBAAwB,UAAU,QAAQ,OAAO;UACvD,aAAa,sBAAsB;UACnC,OAAO;UACP;UACA,MAAM,UAAU;;;;;AAM3B,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC,0BAA0B;UAC1B;;;;;AAMX,iBAAiB,gCAAgC;UACtC,aAAa,sBAAsB;UACnC;UACA;;;;;AAMX,iBAAiB,2CAA2C;UACjD,aAAa,sBAAsB;UACnC;;;;;UAKA;;;;;AAMX,iBAAiB,qDAAqD;UAC3D,aAAa,sBAAsB;UACnC,eAAe,kBAAkB;UACjC,gCAAgC;UAChC,0BAA0B;;;;;AAMrC,iBAAiB,iDAAiD;UACvD,aAAa,sBAAsB;UACnC;UACA;;;;;;;;;;AAWX,iBAAiB,yBAAyB;UAC/B,aAAa,sBAAsB;UACnC;UACA;;AAGX,YAAY,oBACR,0BACA,kCACA,6CACA,kCACA,mDACA,uDACA;;;;;;;;AASJ,iBAAiB,cAAc;;UAEpB;UACA,WAAW;UACX;UACA,WAAW;UACX,SAAS;UACT","names":[],"sources":["../../../src/types/ActivityEvent.ts"],"version":3,"file":"ActivityEvent.d.ts"}
|
|
@@ -23,13 +23,21 @@ export interface DocumentSecurity {
|
|
|
23
23
|
readonly discretionary: DocumentSecurityDiscretionary;
|
|
24
24
|
readonly mandatory: DocumentSecurityMandatory;
|
|
25
25
|
}
|
|
26
|
+
export type DocumentOperation = "VIEW" | "EDIT" | "OWN" | "DELETE";
|
|
26
27
|
export interface DocumentMetadata {
|
|
27
28
|
readonly createdBy?: string;
|
|
28
29
|
readonly createdTime?: string;
|
|
29
30
|
readonly description?: string;
|
|
30
31
|
readonly documentTypeName: string;
|
|
31
32
|
readonly name: string;
|
|
33
|
+
readonly operations?: readonly DocumentOperation[];
|
|
32
34
|
readonly ontologyRid: string;
|
|
35
|
+
/**
|
|
36
|
+
* The schema version this document is currently operating at.
|
|
37
|
+
* All connected clients must read and write at this version.
|
|
38
|
+
* Set by the backend; only increases (one-way ratchet).
|
|
39
|
+
*/
|
|
40
|
+
readonly schemaVersion?: number;
|
|
33
41
|
readonly security: DocumentSecurity;
|
|
34
42
|
readonly updatedBy?: string;
|
|
35
43
|
readonly updatedTime?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,iBAAiB,2BAA2B;CAC1C,QAAQ;;AAEV,iBAAiB,8BAA8B;CAC7C,QAAQ;CACR;;AAEF,iBAAiB,+BAA+B;CAC9C;CACA,QAAQ;;AAGV,YAAY,yBACR,6BACA,iCACA;AAEJ,iBAAiB,8BAA8B;UACpC,mBAAmB;UACnB,kBAAkB;UAClB,mBAAmB;;AAG9B,iBAAiB,0BAA0B;UAChC;UACA;;AAGX,iBAAiB,iBAAiB;UACvB,eAAe;UACf,WAAW;;AAGtB,iBAAiB,iBAAiB;UACvB;UACA;UACA;UACA;UACA;UACA;UACA,UAAU;UACV;UACA","names":[],"sources":["../../../src/types/DocumentMetadata.ts"],"version":3,"file":"DocumentMetadata.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,iBAAiB,2BAA2B;CAC1C,QAAQ;;AAEV,iBAAiB,8BAA8B;CAC7C,QAAQ;CACR;;AAEF,iBAAiB,+BAA+B;CAC9C;CACA,QAAQ;;AAGV,YAAY,yBACR,6BACA,iCACA;AAEJ,iBAAiB,8BAA8B;UACpC,mBAAmB;UACnB,kBAAkB;UAClB,mBAAmB;;AAG9B,iBAAiB,0BAA0B;UAChC;UACA;;AAGX,iBAAiB,iBAAiB;UACvB,eAAe;UACf,WAAW;;AAGtB,YAAY,oBAAoB,SAAS,SAAS,QAAQ;AAE1D,iBAAiB,iBAAiB;UACvB;UACA;UACA;UACA;UACA;UACA,sBAAsB;UACtB;;;;;;UAMA;UACA,UAAU;UACV;UACA","names":[],"sources":["../../../src/types/DocumentMetadata.ts"],"version":3,"file":"DocumentMetadata.d.ts"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { WithMetadata } from "./Metadata.js";
|
|
2
2
|
import type { Model, ModelData } from "./Model.js";
|
|
3
|
+
import type { UpgradeRegistryMap } from "./UpgradeLens.js";
|
|
3
4
|
/**
|
|
4
5
|
* The base type for an application sdk's generated document schema.
|
|
5
6
|
*/
|
|
@@ -14,4 +15,6 @@ export type DocumentState<S extends DocumentSchema> = { readonly [K in Exclude<k
|
|
|
14
15
|
} };
|
|
15
16
|
export interface DocumentSchemaMetadata {
|
|
16
17
|
readonly version: number;
|
|
18
|
+
readonly minSupportedVersion?: number;
|
|
19
|
+
readonly upgrades?: UpgradeRegistryMap;
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,oBAAoB;AAClC,cAAc,OAAO,iBAAiB;;;;
|
|
1
|
+
{"mappings":"AAgBA,cAAc,oBAAoB;AAClC,cAAc,OAAO,iBAAiB;AACtC,cAAc,0BAA0B;;;;AAKxC,iBAAiB,uBAAuB,aAAa,wBAAwB;+BAC7C;;;;;AAMhC,YAAY,cAAc,UAAU,8BACxB,KAAK,cAAc,cAAa;yBAA0B,UAAU,EAAE;;AAGlF,iBAAiB,uBAAuB;UAC7B;UACA;UACA,WAAW","names":[],"sources":["../../../src/types/DocumentSchema.ts"],"version":3,"file":"DocumentSchema.d.ts"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Type descriptor for a field, enabling recursive lens application. */
|
|
2
|
+
export type FieldTypeDescriptor = {
|
|
3
|
+
kind: "primitive";
|
|
4
|
+
} | {
|
|
5
|
+
kind: "modelRef";
|
|
6
|
+
model: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "array";
|
|
9
|
+
element: FieldTypeDescriptor;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "map";
|
|
12
|
+
value: FieldTypeDescriptor;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "optional";
|
|
15
|
+
inner: FieldTypeDescriptor;
|
|
16
|
+
};
|
|
17
|
+
export interface FieldLensDef {
|
|
18
|
+
/**
|
|
19
|
+
* Source field names. `forward` receives only these fields, not the full record.
|
|
20
|
+
* When empty, the field is additive — only `default` applies and `forward` is never called.
|
|
21
|
+
*/
|
|
22
|
+
derivedFrom: string[];
|
|
23
|
+
forward: (oldFields: Record<string, unknown>) => unknown;
|
|
24
|
+
default?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface FieldDef {
|
|
27
|
+
type: FieldTypeDescriptor;
|
|
28
|
+
default?: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface UpgradeStepDef {
|
|
31
|
+
name: string;
|
|
32
|
+
addedInVersion: number;
|
|
33
|
+
fields: Record<string, FieldLensDef>;
|
|
34
|
+
removedFields?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface UpgradeRegistry<ModelName extends string = string> {
|
|
37
|
+
modelName: ModelName;
|
|
38
|
+
/** All fields in the current schema (not just upgraded ones). Drives recursive lens application on nested types. */
|
|
39
|
+
allFields: Record<string, FieldDef>;
|
|
40
|
+
/** Must be in version order — the lens walks them sequentially. */
|
|
41
|
+
steps: UpgradeStepDef[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Upgrade registry for union models. Instead of having its own fields/steps,
|
|
45
|
+
* a union delegates to the variant's UpgradeRegistry based on the discriminant
|
|
46
|
+
* value in the data.
|
|
47
|
+
*/
|
|
48
|
+
export interface UnionUpgradeRegistry<ModelName extends string = string> {
|
|
49
|
+
modelName: ModelName;
|
|
50
|
+
/** The field name used to discriminate between variants. */
|
|
51
|
+
discriminant: string;
|
|
52
|
+
/** Maps discriminant values to variant model names in the UpgradeRegistryMap. */
|
|
53
|
+
variants: Record<string, string>;
|
|
54
|
+
}
|
|
55
|
+
export type UpgradeRegistryEntry = UpgradeRegistry | UnionUpgradeRegistry;
|
|
56
|
+
export type UpgradeRegistryMap = Record<string, UpgradeRegistryEntry>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAiBA,YAAY,sBACR;CAAE,MAAM;IACR;CAAE,MAAM;CAAY;IACpB;CAAE,MAAM;CAAS,SAAS;IAC1B;CAAE,MAAM;CAAO,OAAO;IACtB;CAAE,MAAM;CAAY,OAAO;;AAE/B,iBAAiB,aAAa;;;;;CAK5B;CACA,UAAU,WAAW;CACrB;;AAGF,iBAAiB,SAAS;CACxB,MAAM;CACN;;AAGF,iBAAiB,eAAe;CAC9B;CACA;CACA,QAAQ,eAAe;CACvB;;AAGF,iBAAiB,gBAAgB,mCAAmC;CAClE,WAAW;;CAEX,WAAW,eAAe;;CAE1B,OAAO;;;;;;;AAQT,iBAAiB,qBAAqB,mCAAmC;CACvE,WAAW;;CAEX;;CAEA,UAAU;;AAGZ,YAAY,uBAAuB,kBAAkB;AAErD,YAAY,qBAAqB,eAAe","names":[],"sources":["../../../src/types/UpgradeLens.ts"],"version":3,"file":"UpgradeLens.d.ts"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ export type {
|
|
|
33
33
|
DiscretionaryPrincipal_GroupId,
|
|
34
34
|
DiscretionaryPrincipal_UserId,
|
|
35
35
|
DocumentMetadata,
|
|
36
|
+
DocumentOperation,
|
|
36
37
|
DocumentSecurity,
|
|
37
38
|
DocumentSecurityDiscretionary,
|
|
38
39
|
DocumentSecurityMandatory,
|
|
@@ -78,6 +79,16 @@ export type { RecordCollectionRef } from "./types/RecordCollectionRef.js";
|
|
|
78
79
|
export { RecordRefBrand } from "./types/RecordRef.js";
|
|
79
80
|
export type { RecordId, RecordRef } from "./types/RecordRef.js";
|
|
80
81
|
export type { Unsubscribe } from "./types/Unsubscribe.js";
|
|
82
|
+
export type {
|
|
83
|
+
FieldDef,
|
|
84
|
+
FieldLensDef,
|
|
85
|
+
FieldTypeDescriptor,
|
|
86
|
+
UnionUpgradeRegistry,
|
|
87
|
+
UpgradeRegistry,
|
|
88
|
+
UpgradeRegistryEntry,
|
|
89
|
+
UpgradeRegistryMap,
|
|
90
|
+
UpgradeStepDef,
|
|
91
|
+
} from "./types/UpgradeLens.js";
|
|
81
92
|
export { UserRefBrand } from "./types/UserRef.js";
|
|
82
93
|
export type { UserId, UserRef } from "./types/UserRef.js";
|
|
83
94
|
export * as ActivityEvents from "./utils/ActivityEvents.js";
|
|
@@ -58,7 +58,8 @@ export const ActivityEventDataType = {
|
|
|
58
58
|
export interface ActivityEventDataCustom<M extends Model = Model> {
|
|
59
59
|
readonly type: typeof ActivityEventDataType.CUSTOM_EVENT;
|
|
60
60
|
readonly model: M;
|
|
61
|
-
readonly
|
|
61
|
+
readonly eventType: string;
|
|
62
|
+
readonly data: ModelData<M>;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
@@ -47,13 +47,22 @@ export interface DocumentSecurity {
|
|
|
47
47
|
readonly mandatory: DocumentSecurityMandatory;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export type DocumentOperation = "VIEW" | "EDIT" | "OWN" | "DELETE";
|
|
51
|
+
|
|
50
52
|
export interface DocumentMetadata {
|
|
51
53
|
readonly createdBy?: string;
|
|
52
54
|
readonly createdTime?: string;
|
|
53
55
|
readonly description?: string;
|
|
54
56
|
readonly documentTypeName: string;
|
|
55
57
|
readonly name: string;
|
|
58
|
+
readonly operations?: readonly DocumentOperation[];
|
|
56
59
|
readonly ontologyRid: string;
|
|
60
|
+
/**
|
|
61
|
+
* The schema version this document is currently operating at.
|
|
62
|
+
* All connected clients must read and write at this version.
|
|
63
|
+
* Set by the backend; only increases (one-way ratchet).
|
|
64
|
+
*/
|
|
65
|
+
readonly schemaVersion?: number;
|
|
57
66
|
readonly security: DocumentSecurity;
|
|
58
67
|
readonly updatedBy?: string;
|
|
59
68
|
readonly updatedTime?: string;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import type { WithMetadata } from "./Metadata.js";
|
|
18
18
|
import type { Model, ModelData } from "./Model.js";
|
|
19
|
+
import type { UpgradeRegistryMap } from "./UpgradeLens.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* The base type for an application sdk's generated document schema.
|
|
@@ -33,4 +34,6 @@ export type DocumentState<S extends DocumentSchema> = {
|
|
|
33
34
|
|
|
34
35
|
export interface DocumentSchemaMetadata {
|
|
35
36
|
readonly version: number;
|
|
37
|
+
readonly minSupportedVersion?: number;
|
|
38
|
+
readonly upgrades?: UpgradeRegistryMap;
|
|
36
39
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Type descriptor for a field, enabling recursive lens application. */
|
|
18
|
+
export type FieldTypeDescriptor =
|
|
19
|
+
| { kind: "primitive" }
|
|
20
|
+
| { kind: "modelRef"; model: string }
|
|
21
|
+
| { kind: "array"; element: FieldTypeDescriptor }
|
|
22
|
+
| { kind: "map"; value: FieldTypeDescriptor }
|
|
23
|
+
| { kind: "optional"; inner: FieldTypeDescriptor };
|
|
24
|
+
|
|
25
|
+
export interface FieldLensDef {
|
|
26
|
+
/**
|
|
27
|
+
* Source field names. `forward` receives only these fields, not the full record.
|
|
28
|
+
* When empty, the field is additive — only `default` applies and `forward` is never called.
|
|
29
|
+
*/
|
|
30
|
+
derivedFrom: string[];
|
|
31
|
+
forward: (oldFields: Record<string, unknown>) => unknown;
|
|
32
|
+
default?: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FieldDef {
|
|
36
|
+
type: FieldTypeDescriptor;
|
|
37
|
+
default?: unknown;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface UpgradeStepDef {
|
|
41
|
+
name: string;
|
|
42
|
+
addedInVersion: number;
|
|
43
|
+
fields: Record<string, FieldLensDef>;
|
|
44
|
+
removedFields?: string[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface UpgradeRegistry<ModelName extends string = string> {
|
|
48
|
+
modelName: ModelName;
|
|
49
|
+
/** All fields in the current schema (not just upgraded ones). Drives recursive lens application on nested types. */
|
|
50
|
+
allFields: Record<string, FieldDef>;
|
|
51
|
+
/** Must be in version order — the lens walks them sequentially. */
|
|
52
|
+
steps: UpgradeStepDef[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Upgrade registry for union models. Instead of having its own fields/steps,
|
|
57
|
+
* a union delegates to the variant's UpgradeRegistry based on the discriminant
|
|
58
|
+
* value in the data.
|
|
59
|
+
*/
|
|
60
|
+
export interface UnionUpgradeRegistry<ModelName extends string = string> {
|
|
61
|
+
modelName: ModelName;
|
|
62
|
+
/** The field name used to discriminate between variants. */
|
|
63
|
+
discriminant: string;
|
|
64
|
+
/** Maps discriminant values to variant model names in the UpgradeRegistryMap. */
|
|
65
|
+
variants: Record<string, string>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type UpgradeRegistryEntry = UpgradeRegistry | UnionUpgradeRegistry;
|
|
69
|
+
|
|
70
|
+
export type UpgradeRegistryMap = Record<string, UpgradeRegistryEntry>;
|