@palantir/pack.document-schema.model-types 0.0.1-beta.1 → 0.1.0-beta.3
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 -7
- 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 +19 -0
- package/build/browser/index.js +28 -2
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +34 -1
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +115 -3
- package/build/esm/index.js +28 -2
- package/build/esm/index.js.map +1 -1
- package/build/types/index.d.ts +15 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/DocumentMetadata.d.ts +29 -0
- package/build/types/types/DocumentMetadata.d.ts.map +1 -0
- package/build/types/types/DocumentRef.d.ts +17 -0
- package/build/types/types/DocumentRef.d.ts.map +1 -0
- package/build/types/types/MediaRef.d.ts +11 -0
- package/build/types/types/MediaRef.d.ts.map +1 -0
- package/build/types/types/Model.d.ts +10 -2
- package/build/types/types/Model.d.ts.map +1 -1
- package/build/types/types/ObjectRef.d.ts +11 -0
- package/build/types/types/ObjectRef.d.ts.map +1 -0
- package/build/types/types/RecordCollectionRef.d.ts +18 -0
- package/build/types/types/RecordCollectionRef.d.ts.map +1 -0
- package/build/types/types/RecordRef.d.ts +16 -0
- package/build/types/types/RecordRef.d.ts.map +1 -0
- package/build/types/types/Unsubscribe.d.ts +1 -0
- package/build/types/types/Unsubscribe.d.ts.map +1 -0
- package/build/types/types/UserRef.d.ts +8 -0
- package/build/types/types/UserRef.d.ts.map +1 -0
- package/package.json +4 -1
- package/src/index.ts +21 -0
- package/src/types/DocumentMetadata.ts +50 -0
- package/src/types/DocumentRef.ts +41 -0
- package/src/types/MediaRef.ts +32 -0
- package/src/types/Metadata.ts +1 -1
- package/src/types/Model.ts +12 -2
- package/src/types/ObjectRef.ts +32 -0
- package/src/types/RecordCollectionRef.ts +49 -0
- package/src/types/RecordRef.ts +36 -0
- package/src/types/Unsubscribe.ts +17 -0
- package/src/types/UserRef.ts +27 -0
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 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
|
|
|
5
|
-
Compiling https://plugins.dprint.dev/g-plane/markup_fmt-v0.23.1.wasm
|
|
6
|
-
Compiling https://plugins.dprint.dev/json-0.20.0.wasm
|
|
7
|
-
Compiling https://plugins.dprint.dev/g-plane/malva-v0.14.2.wasm
|
|
8
|
-
Compiling https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm
|
|
9
|
-
Compiling https://plugins.dprint.dev/typescript-0.95.10.wasm
|
|
10
|
-
Compiling https://plugins.dprint.dev/markdown-0.19.0.wasm
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 transpileBrowser /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f esm -m bundle -t browser
|
|
4
4
|
|
|
5
5
|
👍
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 transpileCjs /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f cjs -m bundle -t node
|
|
4
4
|
|
|
5
5
|
👍
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 transpileEsm /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> monorepo-transpile -f esm -m bundle -t node
|
|
4
4
|
|
|
5
5
|
👍
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.document-schema.model-types@0.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 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.0
|
|
2
|
+
> @palantir/pack.document-schema.model-types@0.1.0-beta.3 typecheck /home/runner/work/pack/pack/packages/document-schema/model-types
|
|
3
3
|
> tsc --noEmit --emitDeclarationOnly false
|
|
4
4
|
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @palantir/pack.document-schema.model-types
|
|
2
|
+
|
|
3
|
+
## 0.1.0-beta.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 77c07c4: Add Core and State Core packages, add Refs to core model types
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [77c07c4]
|
|
12
|
+
- @palantir/pack.core@0.1.0-beta.2
|
|
13
|
+
|
|
14
|
+
## 0.1.0-beta.2
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 27a3b33: Initial release
|
|
19
|
+
- 511ee0c: Resetting to beta version of package
|
package/build/browser/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
// src/types/DocumentRef.ts
|
|
2
|
+
var DocumentRefBrand = Symbol("pack:DocumentRef");
|
|
3
|
+
|
|
4
|
+
// src/types/MediaRef.ts
|
|
5
|
+
var MediaRefBrand = Symbol("pack:MediaRef");
|
|
6
|
+
|
|
1
7
|
// src/types/Metadata.ts
|
|
2
|
-
var Metadata = Symbol("@pack
|
|
8
|
+
var Metadata = Symbol("@palantir/pack.document-schema/metadata");
|
|
3
9
|
function getMetadata(obj) {
|
|
4
10
|
const metadata = obj[Metadata];
|
|
5
11
|
if (metadata == null) {
|
|
@@ -8,6 +14,26 @@ function getMetadata(obj) {
|
|
|
8
14
|
return metadata;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
// src/types/Model.ts
|
|
18
|
+
var ExternalRefType = {
|
|
19
|
+
DOC_REF: "docRef",
|
|
20
|
+
MEDIA_REF: "mediaRef",
|
|
21
|
+
OBJECT_REF: "objectRef",
|
|
22
|
+
USER_REF: "userRef"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/types/ObjectRef.ts
|
|
26
|
+
var ObjectRefBrand = Symbol("pack:ObjectRef");
|
|
27
|
+
|
|
28
|
+
// src/types/RecordCollectionRef.ts
|
|
29
|
+
var RecordCollectionRefBrand = Symbol("pack:RecordCollectionRef");
|
|
30
|
+
|
|
31
|
+
// src/types/RecordRef.ts
|
|
32
|
+
var RecordRefBrand = Symbol("pack:RecordRef");
|
|
33
|
+
|
|
34
|
+
// src/types/UserRef.ts
|
|
35
|
+
var UserRefBrand = Symbol("pack:UserRef");
|
|
36
|
+
|
|
37
|
+
export { DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata };
|
|
12
38
|
//# sourceMappingURL=index.js.map
|
|
13
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Metadata.ts"],"names":[],"mappings":";AAgBO,IAAM,QAAA,GAAW,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACAlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,QAAA,GAAW,IAAI,QAAQ,CAAA;AAC7B,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,QAAA;AACT;;;ACDO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;ACZO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // TS always treats symbol keys as optional\n const metadata = obj[Metadata];\n if (metadata == null) {\n throw new Error(\"Object does not have metadata\");\n }\n return metadata;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/types/DocumentRef.ts
|
|
4
|
+
var DocumentRefBrand = Symbol("pack:DocumentRef");
|
|
5
|
+
|
|
6
|
+
// src/types/MediaRef.ts
|
|
7
|
+
var MediaRefBrand = Symbol("pack:MediaRef");
|
|
8
|
+
|
|
3
9
|
// src/types/Metadata.ts
|
|
4
|
-
var Metadata = Symbol("@pack
|
|
10
|
+
var Metadata = Symbol("@palantir/pack.document-schema/metadata");
|
|
5
11
|
function getMetadata(obj) {
|
|
6
12
|
const metadata = obj[Metadata];
|
|
7
13
|
if (metadata == null) {
|
|
@@ -10,7 +16,34 @@ function getMetadata(obj) {
|
|
|
10
16
|
return metadata;
|
|
11
17
|
}
|
|
12
18
|
|
|
19
|
+
// src/types/Model.ts
|
|
20
|
+
var ExternalRefType = {
|
|
21
|
+
DOC_REF: "docRef",
|
|
22
|
+
MEDIA_REF: "mediaRef",
|
|
23
|
+
OBJECT_REF: "objectRef",
|
|
24
|
+
USER_REF: "userRef"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/types/ObjectRef.ts
|
|
28
|
+
var ObjectRefBrand = Symbol("pack:ObjectRef");
|
|
29
|
+
|
|
30
|
+
// src/types/RecordCollectionRef.ts
|
|
31
|
+
var RecordCollectionRefBrand = Symbol("pack:RecordCollectionRef");
|
|
32
|
+
|
|
33
|
+
// src/types/RecordRef.ts
|
|
34
|
+
var RecordRefBrand = Symbol("pack:RecordRef");
|
|
35
|
+
|
|
36
|
+
// src/types/UserRef.ts
|
|
37
|
+
var UserRefBrand = Symbol("pack:UserRef");
|
|
38
|
+
|
|
39
|
+
exports.DocumentRefBrand = DocumentRefBrand;
|
|
40
|
+
exports.ExternalRefType = ExternalRefType;
|
|
41
|
+
exports.MediaRefBrand = MediaRefBrand;
|
|
13
42
|
exports.Metadata = Metadata;
|
|
43
|
+
exports.ObjectRefBrand = ObjectRefBrand;
|
|
44
|
+
exports.RecordCollectionRefBrand = RecordCollectionRefBrand;
|
|
45
|
+
exports.RecordRefBrand = RecordRefBrand;
|
|
46
|
+
exports.UserRefBrand = UserRefBrand;
|
|
14
47
|
exports.getMetadata = getMetadata;
|
|
15
48
|
//# sourceMappingURL=index.cjs.map
|
|
16
49
|
//# sourceMappingURL=index.cjs.map
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Metadata.ts"],"names":[],"mappings":";;;AAgBO,IAAM,QAAA,GAAW,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";;;AAgBO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACAlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,QAAA,GAAW,IAAI,QAAQ,CAAA;AAC7B,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,QAAA;AACT;;;ACDO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;ACZO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.cjs","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // TS always treats symbol keys as optional\n const metadata = obj[Metadata];\n if (metadata == null) {\n throw new Error(\"Object does not have metadata\");\n }\n return metadata;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");"]}
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
|
+
import { Flavored } from '@palantir/pack.core';
|
|
1
2
|
import { ZodType } from 'zod';
|
|
2
3
|
|
|
4
|
+
interface DiscretionaryPrincipal_All {
|
|
5
|
+
"all": Record<string, never>;
|
|
6
|
+
"type": "all";
|
|
7
|
+
}
|
|
8
|
+
interface DiscretionaryPrincipal_UserId {
|
|
9
|
+
"type": "userId";
|
|
10
|
+
"userId": string;
|
|
11
|
+
}
|
|
12
|
+
interface DiscretionaryPrincipal_GroupId {
|
|
13
|
+
"groupId": string;
|
|
14
|
+
"type": "groupId";
|
|
15
|
+
}
|
|
16
|
+
type DiscretionaryPrincipal = DiscretionaryPrincipal_All | DiscretionaryPrincipal_GroupId | DiscretionaryPrincipal_UserId;
|
|
17
|
+
interface DocumentMetadata {
|
|
18
|
+
readonly documentTypeName: string;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly ontologyRid: string;
|
|
21
|
+
readonly security: {
|
|
22
|
+
readonly discretionary: {
|
|
23
|
+
readonly editors?: readonly DiscretionaryPrincipal[];
|
|
24
|
+
readonly owners: readonly DiscretionaryPrincipal[];
|
|
25
|
+
readonly viewers?: readonly DiscretionaryPrincipal[];
|
|
26
|
+
};
|
|
27
|
+
readonly mandatory: {
|
|
28
|
+
readonly classification?: readonly string[];
|
|
29
|
+
readonly markings?: readonly string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
3
34
|
declare const Metadata: symbol;
|
|
4
35
|
interface WithMetadata<T> {
|
|
5
36
|
readonly [Metadata]: T;
|
|
@@ -11,12 +42,20 @@ declare function getMetadata<T>(obj: WithMetadata<T>): T;
|
|
|
11
42
|
*
|
|
12
43
|
* It includes a zod schema for validation and type information.
|
|
13
44
|
*/
|
|
14
|
-
interface Model<T = unknown, Z extends ZodType<T> = ZodType<T>> extends WithMetadata<ModelMetadata
|
|
45
|
+
interface Model<T = unknown, Z extends ZodType<T> = ZodType<T>> extends WithMetadata<ModelMetadata<T>> {
|
|
15
46
|
readonly __type: T;
|
|
16
47
|
readonly zodSchema: Readonly<Z>;
|
|
17
48
|
}
|
|
18
49
|
type ModelData<M extends Model> = M["__type"];
|
|
19
|
-
|
|
50
|
+
declare const ExternalRefType: {
|
|
51
|
+
readonly DOC_REF: "docRef";
|
|
52
|
+
readonly MEDIA_REF: "mediaRef";
|
|
53
|
+
readonly OBJECT_REF: "objectRef";
|
|
54
|
+
readonly USER_REF: "userRef";
|
|
55
|
+
};
|
|
56
|
+
type ExternalRefType = typeof ExternalRefType[keyof typeof ExternalRefType];
|
|
57
|
+
interface ModelMetadata<T = unknown> {
|
|
58
|
+
readonly externalRefFieldTypes?: Readonly<Record<keyof T, ExternalRefType>>;
|
|
20
59
|
readonly name: string;
|
|
21
60
|
}
|
|
22
61
|
|
|
@@ -32,4 +71,77 @@ interface DocumentSchemaMetadata {
|
|
|
32
71
|
readonly version: number;
|
|
33
72
|
}
|
|
34
73
|
|
|
35
|
-
|
|
74
|
+
type Unsubscribe = () => void;
|
|
75
|
+
|
|
76
|
+
type RecordId = Flavored<"RecordId">;
|
|
77
|
+
declare const RecordRefBrand: unique symbol;
|
|
78
|
+
interface RecordRef<M extends Model = Model> {
|
|
79
|
+
readonly docRef: DocumentRef;
|
|
80
|
+
readonly id: RecordId;
|
|
81
|
+
readonly model: M;
|
|
82
|
+
readonly [RecordRefBrand]: typeof RecordRefBrand;
|
|
83
|
+
getSnapshot(): Promise<ModelData<M>>;
|
|
84
|
+
onChange(callback: (snapshot: ModelData<M>, recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
85
|
+
onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
86
|
+
set(record: ModelData<M>): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare const RecordCollectionRefBrand: unique symbol;
|
|
90
|
+
interface RecordCollectionRef<M extends Model = Model> {
|
|
91
|
+
readonly docRef: DocumentRef;
|
|
92
|
+
readonly model: M;
|
|
93
|
+
readonly [RecordCollectionRefBrand]: typeof RecordCollectionRefBrand;
|
|
94
|
+
delete(id: RecordId): Promise<void>;
|
|
95
|
+
get(id: RecordId): RecordRef<M> | undefined;
|
|
96
|
+
has(id: RecordId): boolean;
|
|
97
|
+
set(id: RecordId, state: ModelData<M>): Promise<void>;
|
|
98
|
+
readonly size: number;
|
|
99
|
+
[Symbol.iterator](): Iterator<RecordRef<M>>;
|
|
100
|
+
readonly onItemsAdded: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
101
|
+
readonly onItemsChanged: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
102
|
+
readonly onItemsDeleted: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type DocumentId = Flavored<"DocumentId">;
|
|
106
|
+
declare const DocumentRefBrand: unique symbol;
|
|
107
|
+
interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
|
|
108
|
+
readonly id: DocumentId;
|
|
109
|
+
readonly schema: D;
|
|
110
|
+
readonly [DocumentRefBrand]: typeof DocumentRefBrand;
|
|
111
|
+
readonly getDocSnapshot: () => Promise<DocumentState<D>>;
|
|
112
|
+
readonly getRecords: <R extends Model>(model: R) => RecordCollectionRef<R>;
|
|
113
|
+
readonly onMetadataChange: (callback: (docId: DocumentRef<D>, metadata: DocumentMetadata) => void) => Unsubscribe;
|
|
114
|
+
readonly onStateChange: (callback: (docRef: DocumentRef<D>) => void) => Unsubscribe;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type MediaId = Flavored<"MediaId">;
|
|
118
|
+
declare const MediaRefBrand: unique symbol;
|
|
119
|
+
/**
|
|
120
|
+
* @experimental
|
|
121
|
+
*/
|
|
122
|
+
interface MediaRef {
|
|
123
|
+
readonly mediaId: MediaId;
|
|
124
|
+
readonly [MediaRefBrand]: typeof MediaRefBrand;
|
|
125
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type ObjectId = Flavored<"ObjectId">;
|
|
129
|
+
declare const ObjectRefBrand: unique symbol;
|
|
130
|
+
/**
|
|
131
|
+
* @experimental
|
|
132
|
+
*/
|
|
133
|
+
interface ObjectRef {
|
|
134
|
+
readonly objectId: ObjectId;
|
|
135
|
+
readonly [ObjectRefBrand]: typeof ObjectRefBrand;
|
|
136
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
type UserId = Flavored<"pack:UserId">;
|
|
140
|
+
declare const UserRefBrand: unique symbol;
|
|
141
|
+
interface UserRef {
|
|
142
|
+
readonly userId: UserId;
|
|
143
|
+
readonly [UserRefBrand]: typeof UserRefBrand;
|
|
144
|
+
readonly get: (force?: boolean) => Promise<unknown>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { type DiscretionaryPrincipal, type DiscretionaryPrincipal_All, type DiscretionaryPrincipal_GroupId, type DiscretionaryPrincipal_UserId, type DocumentId, type DocumentMetadata, type DocumentRef, DocumentRefBrand, type DocumentSchema, type DocumentSchemaMetadata, type DocumentState, ExternalRefType, type MediaId, type MediaRef, MediaRefBrand, Metadata, type Model, type ModelData, type ModelMetadata, type ObjectId, type ObjectRef, ObjectRefBrand, type RecordCollectionRef, RecordCollectionRefBrand, type RecordId, type RecordRef, RecordRefBrand, type Unsubscribe, type UserId, type UserRef, UserRefBrand, type WithMetadata, getMetadata };
|
package/build/esm/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
// src/types/DocumentRef.ts
|
|
2
|
+
var DocumentRefBrand = Symbol("pack:DocumentRef");
|
|
3
|
+
|
|
4
|
+
// src/types/MediaRef.ts
|
|
5
|
+
var MediaRefBrand = Symbol("pack:MediaRef");
|
|
6
|
+
|
|
1
7
|
// src/types/Metadata.ts
|
|
2
|
-
var Metadata = Symbol("@pack
|
|
8
|
+
var Metadata = Symbol("@palantir/pack.document-schema/metadata");
|
|
3
9
|
function getMetadata(obj) {
|
|
4
10
|
const metadata = obj[Metadata];
|
|
5
11
|
if (metadata == null) {
|
|
@@ -8,6 +14,26 @@ function getMetadata(obj) {
|
|
|
8
14
|
return metadata;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
// src/types/Model.ts
|
|
18
|
+
var ExternalRefType = {
|
|
19
|
+
DOC_REF: "docRef",
|
|
20
|
+
MEDIA_REF: "mediaRef",
|
|
21
|
+
OBJECT_REF: "objectRef",
|
|
22
|
+
USER_REF: "userRef"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/types/ObjectRef.ts
|
|
26
|
+
var ObjectRefBrand = Symbol("pack:ObjectRef");
|
|
27
|
+
|
|
28
|
+
// src/types/RecordCollectionRef.ts
|
|
29
|
+
var RecordCollectionRefBrand = Symbol("pack:RecordCollectionRef");
|
|
30
|
+
|
|
31
|
+
// src/types/RecordRef.ts
|
|
32
|
+
var RecordRefBrand = Symbol("pack:RecordRef");
|
|
33
|
+
|
|
34
|
+
// src/types/UserRef.ts
|
|
35
|
+
var UserRefBrand = Symbol("pack:UserRef");
|
|
36
|
+
|
|
37
|
+
export { DocumentRefBrand, ExternalRefType, MediaRefBrand, Metadata, ObjectRefBrand, RecordCollectionRefBrand, RecordRefBrand, UserRefBrand, getMetadata };
|
|
12
38
|
//# sourceMappingURL=index.js.map
|
|
13
39
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/Metadata.ts"],"names":[],"mappings":";AAgBO,IAAM,QAAA,GAAW,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/types/DocumentRef.ts","../../src/types/MediaRef.ts","../../src/types/Metadata.ts","../../src/types/Model.ts","../../src/types/ObjectRef.ts","../../src/types/RecordCollectionRef.ts","../../src/types/RecordRef.ts","../../src/types/UserRef.ts"],"names":[],"mappings":";AAgBO,IAAM,gBAAA,GAAmB,OAAO,kBAAkB;;;ACAlD,IAAM,aAAA,GAAgB,OAAO,eAAe;;;ACA5C,IAAM,QAAA,GAAW,OAAO,yCAAyC;AACjE,SAAS,YAAY,GAAA,EAAK;AAE/B,EAAA,MAAM,QAAA,GAAW,IAAI,QAAQ,CAAA;AAC7B,EAAA,IAAI,YAAY,IAAA,EAAM;AACpB,IAAA,MAAM,IAAI,MAAM,+BAA+B,CAAA;AAAA,EACjD;AACA,EAAA,OAAO,QAAA;AACT;;;ACDO,IAAM,eAAA,GAAkB;AAAA,EAC7B,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,UAAA;AAAA,EACX,UAAA,EAAY,WAAA;AAAA,EACZ,QAAA,EAAU;AACZ;;;ACZO,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,wBAAA,GAA2B,OAAO,0BAA0B;;;ACAlE,IAAM,cAAA,GAAiB,OAAO,gBAAgB;;;ACA9C,IAAM,YAAA,GAAe,OAAO,cAAc","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const DocumentRefBrand = Symbol(\"pack:DocumentRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const MediaRefBrand = Symbol(\"pack:MediaRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Metadata = Symbol(\"@palantir/pack.document-schema/metadata\");\nexport function getMetadata(obj) {\n // TS always treats symbol keys as optional\n const metadata = obj[Metadata];\n if (metadata == null) {\n throw new Error(\"Object does not have metadata\");\n }\n return metadata;\n}","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A Model defines the structure of a document record or union.\n *\n * It includes a zod schema for validation and type information.\n */\n// TODO: I think we can/should hide the zod types\n\nexport const ExternalRefType = {\n DOC_REF: \"docRef\",\n MEDIA_REF: \"mediaRef\",\n OBJECT_REF: \"objectRef\",\n USER_REF: \"userRef\"\n};","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const ObjectRefBrand = Symbol(\"pack:ObjectRef\");\n\n/**\n * @experimental\n */","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordCollectionRefBrand = Symbol(\"pack:RecordCollectionRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const RecordRefBrand = Symbol(\"pack:RecordRef\");","/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const UserRefBrand = Symbol(\"pack:UserRef\");"]}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
export type { DiscretionaryPrincipal, DiscretionaryPrincipal_All, DiscretionaryPrincipal_GroupId, DiscretionaryPrincipal_UserId, DocumentMetadata } from "./types/DocumentMetadata.js";
|
|
2
|
+
export { DocumentRefBrand } from "./types/DocumentRef.js";
|
|
3
|
+
export type { DocumentId, DocumentRef } from "./types/DocumentRef.js";
|
|
1
4
|
export type { DocumentSchema, DocumentSchemaMetadata, DocumentState } from "./types/DocumentSchema.js";
|
|
5
|
+
export { MediaRefBrand } from "./types/MediaRef.js";
|
|
6
|
+
export type { MediaId, MediaRef } from "./types/MediaRef.js";
|
|
2
7
|
export { getMetadata, Metadata } from "./types/Metadata.js";
|
|
3
8
|
export type { WithMetadata } from "./types/Metadata.js";
|
|
9
|
+
export { ExternalRefType } from "./types/Model.js";
|
|
4
10
|
export type { Model, ModelData, ModelMetadata } from "./types/Model.js";
|
|
11
|
+
export { ObjectRefBrand } from "./types/ObjectRef.js";
|
|
12
|
+
export type { ObjectId, ObjectRef } from "./types/ObjectRef.js";
|
|
13
|
+
export { RecordCollectionRefBrand } from "./types/RecordCollectionRef.js";
|
|
14
|
+
export type { RecordCollectionRef } from "./types/RecordCollectionRef.js";
|
|
15
|
+
export { RecordRefBrand } from "./types/RecordRef.js";
|
|
16
|
+
export type { RecordId, RecordRef } from "./types/RecordRef.js";
|
|
17
|
+
export type { Unsubscribe } from "./types/Unsubscribe.js";
|
|
18
|
+
export { UserRefBrand } from "./types/UserRef.js";
|
|
19
|
+
export type { UserId, UserRef } from "./types/UserRef.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,gBACA,wBACA,qBACK;AACP,SAAS,aAAa,gBAAgB;AACtC,cAAc,oBAAoB;AAClC,cAAc,OAAO,WAAW,qBAAqB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,cACE,wBACA,4BACA,gCACA,+BACA,wBACK;AACP,SAAS,wBAAwB;AACjC,cAAc,YAAY,mBAAmB;AAC7C,cACE,gBACA,wBACA,qBACK;AACP,SAAS,qBAAqB;AAC9B,cAAc,SAAS,gBAAgB;AACvC,SAAS,aAAa,gBAAgB;AACtC,cAAc,oBAAoB;AAClC,SAAS,uBAAuB;AAChC,cAAc,OAAO,WAAW,qBAAqB;AACrD,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,SAAS,gCAAgC;AACzC,cAAc,2BAA2B;AACzC,SAAS,sBAAsB;AAC/B,cAAc,UAAU,iBAAiB;AACzC,cAAc,mBAAmB;AACjC,SAAS,oBAAoB;AAC7B,cAAc,QAAQ,eAAe","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface DiscretionaryPrincipal_All {
|
|
2
|
+
"all": Record<string, never>;
|
|
3
|
+
"type": "all";
|
|
4
|
+
}
|
|
5
|
+
export interface DiscretionaryPrincipal_UserId {
|
|
6
|
+
"type": "userId";
|
|
7
|
+
"userId": string;
|
|
8
|
+
}
|
|
9
|
+
export interface DiscretionaryPrincipal_GroupId {
|
|
10
|
+
"groupId": string;
|
|
11
|
+
"type": "groupId";
|
|
12
|
+
}
|
|
13
|
+
export type DiscretionaryPrincipal = DiscretionaryPrincipal_All | DiscretionaryPrincipal_GroupId | DiscretionaryPrincipal_UserId;
|
|
14
|
+
export interface DocumentMetadata {
|
|
15
|
+
readonly documentTypeName: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly ontologyRid: string;
|
|
18
|
+
readonly security: {
|
|
19
|
+
readonly discretionary: {
|
|
20
|
+
readonly editors?: readonly DiscretionaryPrincipal[];
|
|
21
|
+
readonly owners: readonly DiscretionaryPrincipal[];
|
|
22
|
+
readonly viewers?: readonly DiscretionaryPrincipal[];
|
|
23
|
+
};
|
|
24
|
+
readonly mandatory: {
|
|
25
|
+
readonly classification?: readonly string[];
|
|
26
|
+
readonly markings?: readonly string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,iBAAiB,2BAA2B;CAC1C,OAAO;CACP,QAAQ;;AAEV,iBAAiB,8BAA8B;CAC7C,QAAQ;CACR;;AAEF,iBAAiB,+BAA+B;CAC9C;CACA,QAAQ;;AAGV,YAAY,yBACR,6BACA,iCACA;AAEJ,iBAAiB,iBAAiB;UACvB;UACA;UACA;UACA,UAAU;WACR,eAAe;YACb,mBAAmB;YACnB,iBAAiB;YACjB,mBAAmB;;WAErB,WAAW;YACT;YACA","names":[],"sources":["../../../src/types/DocumentMetadata.ts"],"version":3,"file":"DocumentMetadata.d.ts"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
2
|
+
import type { DocumentMetadata } from "./DocumentMetadata.js";
|
|
3
|
+
import type { DocumentSchema, DocumentState } from "./DocumentSchema.js";
|
|
4
|
+
import type { Model } from "./Model.js";
|
|
5
|
+
import type { RecordCollectionRef } from "./RecordCollectionRef.js";
|
|
6
|
+
import type { Unsubscribe } from "./Unsubscribe.js";
|
|
7
|
+
export type DocumentId = Flavored<"DocumentId">;
|
|
8
|
+
export declare const DocumentRefBrand: unique symbol;
|
|
9
|
+
export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
|
|
10
|
+
readonly id: DocumentId;
|
|
11
|
+
readonly schema: D;
|
|
12
|
+
readonly [DocumentRefBrand]: typeof DocumentRefBrand;
|
|
13
|
+
readonly getDocSnapshot: () => Promise<DocumentState<D>>;
|
|
14
|
+
readonly getRecords: <R extends Model>(model: R) => RecordCollectionRef<R>;
|
|
15
|
+
readonly onMetadataChange: (callback: (docId: DocumentRef<D>, metadata: DocumentMetadata) => void) => Unsubscribe;
|
|
16
|
+
readonly onStateChange: (callback: (docRef: DocumentRef<D>) => void) => Unsubscribe;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,wBAAwB;AACtC,cAAc,gBAAgB,qBAAqB;AACnD,cAAc,aAAa;AAC3B,cAAc,2BAA2B;AACzC,cAAc,mBAAmB;AAEjC,YAAY,aAAa,SAAS;AAElC,OAAO,cAAMA;AAEb,iBAAiB,YAAY,UAAU,iBAAiB,gBAAgB;UAC7D,IAAI;UACJ,QAAQ;WACP,0BAA0B;UAE3B,sBAAsB,QAAQ,cAAc;UAC5C,aAAa,UAAU,OAAO,OAAO,MAAM,oBAAoB;UAC/D,mBACP,WAAW,OAAO,YAAY,IAAI,UAAU,8BACzC;UACI,gBACP,WAAW,QAAQ,YAAY,gBAC5B","names":["DocumentRefBrand: unique symbol"],"sources":["../../../src/types/DocumentRef.ts"],"version":3,"file":"DocumentRef.d.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
2
|
+
export type MediaId = Flavored<"MediaId">;
|
|
3
|
+
export declare const MediaRefBrand: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
export interface MediaRef {
|
|
8
|
+
readonly mediaId: MediaId;
|
|
9
|
+
readonly [MediaRefBrand]: typeof MediaRefBrand;
|
|
10
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAE9B,YAAY,UAAU,SAAS;AAE/B,OAAO,cAAMA;;;;AAKb,iBAAiB,SAAS;UACf,SAAS;WACR,uBAAuB;UAGxB,aAAa","names":["MediaRefBrand: unique symbol"],"sources":["../../../src/types/MediaRef.ts"],"version":3,"file":"MediaRef.d.ts"}
|
|
@@ -8,11 +8,19 @@ import type { WithMetadata } from "./Metadata.js";
|
|
|
8
8
|
export interface Model<
|
|
9
9
|
T = unknown,
|
|
10
10
|
Z extends ZodType<T> = ZodType<T>
|
|
11
|
-
> extends WithMetadata<ModelMetadata
|
|
11
|
+
> extends WithMetadata<ModelMetadata<T>> {
|
|
12
12
|
readonly __type: T;
|
|
13
13
|
readonly zodSchema: Readonly<Z>;
|
|
14
14
|
}
|
|
15
15
|
export type ModelData<M extends Model> = M["__type"];
|
|
16
|
-
export
|
|
16
|
+
export declare const ExternalRefType: {
|
|
17
|
+
readonly DOC_REF: "docRef";
|
|
18
|
+
readonly MEDIA_REF: "mediaRef";
|
|
19
|
+
readonly OBJECT_REF: "objectRef";
|
|
20
|
+
readonly USER_REF: "userRef";
|
|
21
|
+
};
|
|
22
|
+
export type ExternalRefType = typeof ExternalRefType[keyof typeof ExternalRefType];
|
|
23
|
+
export interface ModelMetadata<T = unknown> {
|
|
24
|
+
readonly externalRefFieldTypes?: Readonly<Record<keyof T, ExternalRefType>>;
|
|
17
25
|
readonly name: string;
|
|
18
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,eAAe;AAC7B,cAAc,oBAAoB;;;;;;AAQlC,iBAAiB;CAAM;CAAa,UAAU,QAAQ,KAAK,QAAQ;UACzD,aAAa,
|
|
1
|
+
{"mappings":"AAgBA,cAAc,eAAe;AAC7B,cAAc,oBAAoB;;;;;;AAQlC,iBAAiB;CAAM;CAAa,UAAU,QAAQ,KAAK,QAAQ;UACzD,aAAa,cAAc,IACrC;UACW,QAAQ;UACR,WAAW,SAAS;;AAG/B,YAAY,UAAU,UAAU,SAAS,EAAE;AAE3C,OAAO,cAAM;UACX,SAAS;UACT,WAAW;UACX,YAAY;UACZ,UAAU;;AAGZ,YAAY,yBAAyB,6BAA6B;AAElE,iBAAiB,cAAc,aAAa;UACjC,wBAAwB,SAAS,aAAa,GAAG;UACjD","names":[],"sources":["../../../src/types/Model.ts"],"version":3,"file":"Model.d.ts"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
2
|
+
export type ObjectId = Flavored<"ObjectId">;
|
|
3
|
+
export declare const ObjectRefBrand: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
export interface ObjectRef {
|
|
8
|
+
readonly objectId: ObjectId;
|
|
9
|
+
readonly [ObjectRefBrand]: typeof ObjectRefBrand;
|
|
10
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAE9B,YAAY,WAAW,SAAS;AAEhC,OAAO,cAAMA;;;;AAKb,iBAAiB,UAAU;UAChB,UAAU;WACT,wBAAwB;UAGzB,aAAa","names":["ObjectRefBrand: unique symbol"],"sources":["../../../src/types/ObjectRef.ts"],"version":3,"file":"ObjectRef.d.ts"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocumentRef } from "./DocumentRef.js";
|
|
2
|
+
import type { Model, ModelData } from "./Model.js";
|
|
3
|
+
import type { RecordId, RecordRef } from "./RecordRef.js";
|
|
4
|
+
export declare const RecordCollectionRefBrand: unique symbol;
|
|
5
|
+
export interface RecordCollectionRef<M extends Model = Model> {
|
|
6
|
+
readonly docRef: DocumentRef;
|
|
7
|
+
readonly model: M;
|
|
8
|
+
readonly [RecordCollectionRefBrand]: typeof RecordCollectionRefBrand;
|
|
9
|
+
delete(id: RecordId): Promise<void>;
|
|
10
|
+
get(id: RecordId): RecordRef<M> | undefined;
|
|
11
|
+
has(id: RecordId): boolean;
|
|
12
|
+
set(id: RecordId, state: ModelData<M>): Promise<void>;
|
|
13
|
+
readonly size: number;
|
|
14
|
+
[Symbol.iterator](): Iterator<RecordRef<M>>;
|
|
15
|
+
readonly onItemsAdded: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
16
|
+
readonly onItemsChanged: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
17
|
+
readonly onItemsDeleted: (callback: (items: readonly RecordRef<M>[]) => void) => () => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,UAAU,iBAAiB;AAEzC,OAAO,cAAMA;AAIb,iBAAiB,oBAAoB,UAAU,QAAQ,OAAO;UACnD,QAAQ;UACR,OAAO;WACN,kCAAkC;CAE5C,OAAO,IAAI,WAAW;CACtB,IAAI,IAAI,WAAW,UAAU;CAC7B,IAAI,IAAI;CACR,IAAI,IAAI,UAAU,OAAO,UAAU,KAAK;UAC/B;EAER,OAAO,aAAa,SAAS,UAAU;UAE/B,eACP,WAAW,gBAAgB,UAAU;UAG9B,iBACP,WAAW,gBAAgB,UAAU;UAG9B,iBACP,WAAW,gBAAgB,UAAU","names":["RecordCollectionRefBrand: unique symbol"],"sources":["../../../src/types/RecordCollectionRef.ts"],"version":3,"file":"RecordCollectionRef.d.ts"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
2
|
+
import type { DocumentRef } from "./DocumentRef.js";
|
|
3
|
+
import type { Model, ModelData } from "./Model.js";
|
|
4
|
+
import type { Unsubscribe } from "./Unsubscribe.js";
|
|
5
|
+
export type RecordId = Flavored<"RecordId">;
|
|
6
|
+
export declare const RecordRefBrand: unique symbol;
|
|
7
|
+
export interface RecordRef<M extends Model = Model> {
|
|
8
|
+
readonly docRef: DocumentRef;
|
|
9
|
+
readonly id: RecordId;
|
|
10
|
+
readonly model: M;
|
|
11
|
+
readonly [RecordRefBrand]: typeof RecordRefBrand;
|
|
12
|
+
getSnapshot(): Promise<ModelData<M>>;
|
|
13
|
+
onChange(callback: (snapshot: ModelData<M>, recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
14
|
+
onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
15
|
+
set(record: ModelData<M>): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,OAAO,iBAAiB;AACtC,cAAc,mBAAmB;AAEjC,YAAY,WAAW,SAAS;AAEhC,OAAO,cAAMA;AAEb,iBAAiB,UAAU,UAAU,QAAQ,OAAO;UACzC,QAAQ;UACR,IAAI;UACJ,OAAO;WACN,wBAAwB;CAElC,eAAe,QAAQ,UAAU;CACjC,SAAS,WAAW,UAAU,UAAU,IAAI,WAAW,UAAU,cAAc;CAC/E,UAAU,WAAW,WAAW,UAAU,cAAc;CACxD,IAAI,QAAQ,UAAU,KAAK","names":["RecordRefBrand: unique symbol"],"sources":["../../../src/types/RecordRef.ts"],"version":3,"file":"RecordRef.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Unsubscribe = () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,YAAY","names":[],"sources":["../../../src/types/Unsubscribe.ts"],"version":3,"file":"Unsubscribe.d.ts"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
2
|
+
export type UserId = Flavored<"pack:UserId">;
|
|
3
|
+
export declare const UserRefBrand: unique symbol;
|
|
4
|
+
export interface UserRef {
|
|
5
|
+
readonly userId: UserId;
|
|
6
|
+
readonly [UserRefBrand]: typeof UserRefBrand;
|
|
7
|
+
readonly get: (force?: boolean) => Promise<unknown>;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,gBAAgB;AAE9B,YAAY,SAAS,SAAS;AAE9B,OAAO,cAAMA;AAEb,iBAAiB,QAAQ;UACd,QAAQ;WACP,sBAAsB;UACvB,MAAM,oBAAoB","names":["UserRefBrand: unique symbol"],"sources":["../../../src/types/UserRef.ts"],"version":3,"file":"UserRef.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palantir/pack.document-schema.model-types",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"description": "Minimal types supporting generated PACK schemas",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,9 @@
|
|
|
27
27
|
"default": "./build/browser/public/*.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@palantir/pack.core": "~0.1.0-beta.2"
|
|
32
|
+
},
|
|
30
33
|
"peerDependencies": {
|
|
31
34
|
"zod": "^4.1.7"
|
|
32
35
|
},
|
package/src/index.ts
CHANGED
|
@@ -14,11 +14,32 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
export type {
|
|
18
|
+
DiscretionaryPrincipal,
|
|
19
|
+
DiscretionaryPrincipal_All,
|
|
20
|
+
DiscretionaryPrincipal_GroupId,
|
|
21
|
+
DiscretionaryPrincipal_UserId,
|
|
22
|
+
DocumentMetadata,
|
|
23
|
+
} from "./types/DocumentMetadata.js";
|
|
24
|
+
export { DocumentRefBrand } from "./types/DocumentRef.js";
|
|
25
|
+
export type { DocumentId, DocumentRef } from "./types/DocumentRef.js";
|
|
17
26
|
export type {
|
|
18
27
|
DocumentSchema,
|
|
19
28
|
DocumentSchemaMetadata,
|
|
20
29
|
DocumentState,
|
|
21
30
|
} from "./types/DocumentSchema.js";
|
|
31
|
+
export { MediaRefBrand } from "./types/MediaRef.js";
|
|
32
|
+
export type { MediaId, MediaRef } from "./types/MediaRef.js";
|
|
22
33
|
export { getMetadata, Metadata } from "./types/Metadata.js";
|
|
23
34
|
export type { WithMetadata } from "./types/Metadata.js";
|
|
35
|
+
export { ExternalRefType } from "./types/Model.js";
|
|
24
36
|
export type { Model, ModelData, ModelMetadata } from "./types/Model.js";
|
|
37
|
+
export { ObjectRefBrand } from "./types/ObjectRef.js";
|
|
38
|
+
export type { ObjectId, ObjectRef } from "./types/ObjectRef.js";
|
|
39
|
+
export { RecordCollectionRefBrand } from "./types/RecordCollectionRef.js";
|
|
40
|
+
export type { RecordCollectionRef } from "./types/RecordCollectionRef.js";
|
|
41
|
+
export { RecordRefBrand } from "./types/RecordRef.js";
|
|
42
|
+
export type { RecordId, RecordRef } from "./types/RecordRef.js";
|
|
43
|
+
export type { Unsubscribe } from "./types/Unsubscribe.js";
|
|
44
|
+
export { UserRefBrand } from "./types/UserRef.js";
|
|
45
|
+
export type { UserId, UserRef } from "./types/UserRef.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
export interface DiscretionaryPrincipal_All {
|
|
18
|
+
"all": Record<string, never>;
|
|
19
|
+
"type": "all";
|
|
20
|
+
}
|
|
21
|
+
export interface DiscretionaryPrincipal_UserId {
|
|
22
|
+
"type": "userId";
|
|
23
|
+
"userId": string;
|
|
24
|
+
}
|
|
25
|
+
export interface DiscretionaryPrincipal_GroupId {
|
|
26
|
+
"groupId": string;
|
|
27
|
+
"type": "groupId";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type DiscretionaryPrincipal =
|
|
31
|
+
| DiscretionaryPrincipal_All
|
|
32
|
+
| DiscretionaryPrincipal_GroupId
|
|
33
|
+
| DiscretionaryPrincipal_UserId;
|
|
34
|
+
|
|
35
|
+
export interface DocumentMetadata {
|
|
36
|
+
readonly documentTypeName: string;
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly ontologyRid: string;
|
|
39
|
+
readonly security: {
|
|
40
|
+
readonly discretionary: {
|
|
41
|
+
readonly editors?: readonly DiscretionaryPrincipal[];
|
|
42
|
+
readonly owners: readonly DiscretionaryPrincipal[];
|
|
43
|
+
readonly viewers?: readonly DiscretionaryPrincipal[];
|
|
44
|
+
};
|
|
45
|
+
readonly mandatory: {
|
|
46
|
+
readonly classification?: readonly string[];
|
|
47
|
+
readonly markings?: readonly string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
18
|
+
import type { DocumentMetadata } from "./DocumentMetadata.js";
|
|
19
|
+
import type { DocumentSchema, DocumentState } from "./DocumentSchema.js";
|
|
20
|
+
import type { Model } from "./Model.js";
|
|
21
|
+
import type { RecordCollectionRef } from "./RecordCollectionRef.js";
|
|
22
|
+
import type { Unsubscribe } from "./Unsubscribe.js";
|
|
23
|
+
|
|
24
|
+
export type DocumentId = Flavored<"DocumentId">;
|
|
25
|
+
|
|
26
|
+
export const DocumentRefBrand: unique symbol = Symbol("pack:DocumentRef");
|
|
27
|
+
|
|
28
|
+
export interface DocumentRef<D extends DocumentSchema = DocumentSchema> {
|
|
29
|
+
readonly id: DocumentId;
|
|
30
|
+
readonly schema: D;
|
|
31
|
+
readonly [DocumentRefBrand]: typeof DocumentRefBrand;
|
|
32
|
+
|
|
33
|
+
readonly getDocSnapshot: () => Promise<DocumentState<D>>;
|
|
34
|
+
readonly getRecords: <R extends Model>(model: R) => RecordCollectionRef<R>;
|
|
35
|
+
readonly onMetadataChange: (
|
|
36
|
+
callback: (docId: DocumentRef<D>, metadata: DocumentMetadata) => void,
|
|
37
|
+
) => Unsubscribe;
|
|
38
|
+
readonly onStateChange: (
|
|
39
|
+
callback: (docRef: DocumentRef<D>) => void,
|
|
40
|
+
) => Unsubscribe;
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
18
|
+
|
|
19
|
+
export type MediaId = Flavored<"MediaId">;
|
|
20
|
+
|
|
21
|
+
export const MediaRefBrand: unique symbol = Symbol("pack:MediaRef");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
26
|
+
export interface MediaRef {
|
|
27
|
+
readonly mediaId: MediaId;
|
|
28
|
+
readonly [MediaRefBrand]: typeof MediaRefBrand;
|
|
29
|
+
|
|
30
|
+
// TODO: implement this correctly
|
|
31
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
32
|
+
}
|
package/src/types/Metadata.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const Metadata: symbol = Symbol("@pack
|
|
17
|
+
export const Metadata: symbol = Symbol("@palantir/pack.document-schema/metadata");
|
|
18
18
|
|
|
19
19
|
export interface WithMetadata<T> {
|
|
20
20
|
readonly [Metadata]: T;
|
package/src/types/Model.ts
CHANGED
|
@@ -24,7 +24,7 @@ import type { WithMetadata } from "./Metadata.js";
|
|
|
24
24
|
*/
|
|
25
25
|
// TODO: I think we can/should hide the zod types
|
|
26
26
|
export interface Model<T = unknown, Z extends ZodType<T> = ZodType<T>>
|
|
27
|
-
extends WithMetadata<ModelMetadata
|
|
27
|
+
extends WithMetadata<ModelMetadata<T>>
|
|
28
28
|
{
|
|
29
29
|
readonly __type: T;
|
|
30
30
|
readonly zodSchema: Readonly<Z>;
|
|
@@ -32,6 +32,16 @@ export interface Model<T = unknown, Z extends ZodType<T> = ZodType<T>>
|
|
|
32
32
|
|
|
33
33
|
export type ModelData<M extends Model> = M["__type"];
|
|
34
34
|
|
|
35
|
-
export
|
|
35
|
+
export const ExternalRefType = {
|
|
36
|
+
DOC_REF: "docRef",
|
|
37
|
+
MEDIA_REF: "mediaRef",
|
|
38
|
+
OBJECT_REF: "objectRef",
|
|
39
|
+
USER_REF: "userRef",
|
|
40
|
+
} as const;
|
|
41
|
+
|
|
42
|
+
export type ExternalRefType = typeof ExternalRefType[keyof typeof ExternalRefType];
|
|
43
|
+
|
|
44
|
+
export interface ModelMetadata<T = unknown> {
|
|
45
|
+
readonly externalRefFieldTypes?: Readonly<Record<keyof T, ExternalRefType>>;
|
|
36
46
|
readonly name: string;
|
|
37
47
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
18
|
+
|
|
19
|
+
export type ObjectId = Flavored<"ObjectId">;
|
|
20
|
+
|
|
21
|
+
export const ObjectRefBrand: unique symbol = Symbol("pack:ObjectRef");
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @experimental
|
|
25
|
+
*/
|
|
26
|
+
export interface ObjectRef {
|
|
27
|
+
readonly objectId: ObjectId;
|
|
28
|
+
readonly [ObjectRefBrand]: typeof ObjectRefBrand;
|
|
29
|
+
|
|
30
|
+
// TODO: implement this correctly
|
|
31
|
+
readonly subscribe?: (callback: unknown) => unknown;
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { DocumentRef } from "./DocumentRef.js";
|
|
18
|
+
import type { Model, ModelData } from "./Model.js";
|
|
19
|
+
import type { RecordId, RecordRef } from "./RecordRef.js";
|
|
20
|
+
|
|
21
|
+
export const RecordCollectionRefBrand: unique symbol = Symbol(
|
|
22
|
+
"pack:RecordCollectionRef",
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export interface RecordCollectionRef<M extends Model = Model> {
|
|
26
|
+
readonly docRef: DocumentRef;
|
|
27
|
+
readonly model: M;
|
|
28
|
+
readonly [RecordCollectionRefBrand]: typeof RecordCollectionRefBrand;
|
|
29
|
+
|
|
30
|
+
delete(id: RecordId): Promise<void>;
|
|
31
|
+
get(id: RecordId): RecordRef<M> | undefined;
|
|
32
|
+
has(id: RecordId): boolean;
|
|
33
|
+
set(id: RecordId, state: ModelData<M>): Promise<void>;
|
|
34
|
+
readonly size: number;
|
|
35
|
+
|
|
36
|
+
[Symbol.iterator](): Iterator<RecordRef<M>>;
|
|
37
|
+
|
|
38
|
+
readonly onItemsAdded: (
|
|
39
|
+
callback: (items: readonly RecordRef<M>[]) => void,
|
|
40
|
+
) => () => void;
|
|
41
|
+
|
|
42
|
+
readonly onItemsChanged: (
|
|
43
|
+
callback: (items: readonly RecordRef<M>[]) => void,
|
|
44
|
+
) => () => void;
|
|
45
|
+
|
|
46
|
+
readonly onItemsDeleted: (
|
|
47
|
+
callback: (items: readonly RecordRef<M>[]) => void,
|
|
48
|
+
) => () => void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
18
|
+
import type { DocumentRef } from "./DocumentRef.js";
|
|
19
|
+
import type { Model, ModelData } from "./Model.js";
|
|
20
|
+
import type { Unsubscribe } from "./Unsubscribe.js";
|
|
21
|
+
|
|
22
|
+
export type RecordId = Flavored<"RecordId">;
|
|
23
|
+
|
|
24
|
+
export const RecordRefBrand: unique symbol = Symbol("pack:RecordRef");
|
|
25
|
+
|
|
26
|
+
export interface RecordRef<M extends Model = Model> {
|
|
27
|
+
readonly docRef: DocumentRef;
|
|
28
|
+
readonly id: RecordId;
|
|
29
|
+
readonly model: M;
|
|
30
|
+
readonly [RecordRefBrand]: typeof RecordRefBrand;
|
|
31
|
+
|
|
32
|
+
getSnapshot(): Promise<ModelData<M>>;
|
|
33
|
+
onChange(callback: (snapshot: ModelData<M>, recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
34
|
+
onDeleted(callback: (recordRef: RecordRef<M>) => void): Unsubscribe;
|
|
35
|
+
set(record: ModelData<M>): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
export type Unsubscribe = () => void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
import type { Flavored } from "@palantir/pack.core";
|
|
18
|
+
|
|
19
|
+
export type UserId = Flavored<"pack:UserId">;
|
|
20
|
+
|
|
21
|
+
export const UserRefBrand: unique symbol = Symbol("pack:UserRef");
|
|
22
|
+
|
|
23
|
+
export interface UserRef {
|
|
24
|
+
readonly userId: UserId;
|
|
25
|
+
readonly [UserRefBrand]: typeof UserRefBrand;
|
|
26
|
+
readonly get: (force?: boolean) => Promise<unknown>;
|
|
27
|
+
}
|