@osdk/maker 0.13.0-beta.4 → 0.13.0-beta.5
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/CHANGELOG.md +11 -0
- package/build/browser/api/defineOntology.js +32 -108
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/defineSpt.js.map +1 -1
- package/build/browser/api/defineValueType.js +2 -1
- package/build/browser/api/defineValueType.js.map +1 -1
- package/build/browser/api/markingconstraint.test.js +3 -3
- package/build/browser/api/markingconstraint.test.js.map +1 -1
- package/build/browser/api/objectStatus.test.js +4 -4
- package/build/browser/api/objectStatus.test.js.map +1 -1
- package/build/browser/api/overall.test.js +496 -268
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/api/propertyConversionUtils.js +3 -1
- package/build/browser/api/propertyConversionUtils.js.map +1 -1
- package/build/browser/api/types.js.map +1 -1
- package/build/browser/cli/main.js +11 -5
- package/build/browser/cli/main.js.map +1 -1
- package/build/cjs/index.cjs +49 -116
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +6 -9
- package/build/esm/api/defineOntology.js +32 -108
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/defineSpt.js.map +1 -1
- package/build/esm/api/defineValueType.js +2 -1
- package/build/esm/api/defineValueType.js.map +1 -1
- package/build/esm/api/markingconstraint.test.js +3 -3
- package/build/esm/api/markingconstraint.test.js.map +1 -1
- package/build/esm/api/objectStatus.test.js +4 -4
- package/build/esm/api/objectStatus.test.js.map +1 -1
- package/build/esm/api/overall.test.js +496 -268
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/api/propertyConversionUtils.js +3 -1
- package/build/esm/api/propertyConversionUtils.js.map +1 -1
- package/build/esm/api/types.js.map +1 -1
- package/build/esm/cli/main.js +11 -5
- package/build/esm/cli/main.js.map +1 -1
- package/build/types/api/defineOntology.d.ts +1 -6
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/defineSpt.d.ts +2 -2
- package/build/types/api/defineSpt.d.ts.map +1 -1
- package/build/types/api/propertyConversionUtils.d.ts +2 -2
- package/build/types/api/propertyConversionUtils.d.ts.map +1 -1
- package/build/types/api/types.d.ts +4 -13
- package/build/types/api/types.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -12,52 +12,53 @@
|
|
|
12
12
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
|
-
*/import*as fs from"fs";import path from"path";import{fileURLToPath}from"url";import{beforeEach,describe,expect,it}from"vitest";import{addDependency}from"./addDependency.js";import{defineAction,defineCreateInterfaceObjectAction,defineCreateObjectAction,defineCreateOrModifyObjectAction,defineDeleteObjectAction,defineModifyInterfaceObjectAction,defineModifyObjectAction}from"./defineAction.js";import{importSharedPropertyType}from"./defineImportSpt.js";import{defineInterface}from"./defineInterface.js";import{defineInterfaceLinkConstraint}from"./defineInterfaceLinkConstraint.js";import{defineLink}from"./defineLink.js";import{defineObject}from"./defineObject.js";import{defineOntology,dumpOntologyFullMetadata,dumpValueTypeWireType}from"./defineOntology.js";import{defineSharedPropertyType}from"./defineSpt.js";import{defineValueType}from"./defineValueType.js";import{importOntologyEntity}from"./importOntologyEntity.js";import{CREATE_OR_MODIFY_OBJECT_PARAMETER,MODIFY_OBJECT_PARAMETER,OntologyEntityTypeEnum}from"./types.js";describe("Ontology Defining",()=>{beforeEach(async()=>{await defineOntology("com.palantir.",()=>{},"/tmp/");});describe("ValueTypes",()=>{it("Fails to define value type with incorrect semver",()=>{expect(()=>defineValueType({apiName:"apiName",displayName:"displayName",type:{"type":"boolean",constraints:[{constraint:{"allowedValues":["TRUE_VALUE"]}}]},version:"not a version"})).toThrowErrorMatchingInlineSnapshot("[Error: Invariant failed: Version is not a valid semver]");});it("Tests convertProperty function with valueType constraints for string",()=>{const testStringValueType=defineValueType({apiName:"stringWithConstraints",displayName:"String With Constraints",description:"A string type with additional constraints",type:{"type":"string",constraints:[{constraint:{type:"length",length:{minSize:5,maxSize:20}},failureMessage:{message:"String must be between 5 and 20 characters"}}]},version:"1.0.0"});defineObject({titlePropertyApiName:"constrainedString",displayName:"Test Object",pluralDisplayName:"Test Objects",apiName:"testObject",primaryKeyPropertyApiName:"constrainedString",properties:{"constrainedString":{type:"string",displayName:"Constrained String",valueType:testStringValueType}}});const ontology=dumpOntologyFullMetadata();const objectPropertyType=ontology.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
15
|
+
*/import*as fs from"fs";import path from"path";import{fileURLToPath}from"url";import{beforeEach,describe,expect,it}from"vitest";import{addDependency}from"./addDependency.js";import{defineAction,defineCreateInterfaceObjectAction,defineCreateObjectAction,defineCreateOrModifyObjectAction,defineDeleteObjectAction,defineModifyInterfaceObjectAction,defineModifyObjectAction}from"./defineAction.js";import{importSharedPropertyType}from"./defineImportSpt.js";import{defineInterface}from"./defineInterface.js";import{defineInterfaceLinkConstraint}from"./defineInterfaceLinkConstraint.js";import{defineLink}from"./defineLink.js";import{defineObject}from"./defineObject.js";import{defineOntology,dumpOntologyFullMetadata,dumpValueTypeWireType}from"./defineOntology.js";import{defineSharedPropertyType}from"./defineSpt.js";import{defineValueType}from"./defineValueType.js";import{importOntologyEntity}from"./importOntologyEntity.js";import{CREATE_OR_MODIFY_OBJECT_PARAMETER,MODIFY_OBJECT_PARAMETER,OntologyEntityTypeEnum}from"./types.js";describe("Ontology Defining",()=>{beforeEach(async()=>{await defineOntology("com.palantir.",()=>{},"/tmp/");});describe("ValueTypes",()=>{it("Fails to define value type with incorrect semver",()=>{expect(()=>defineValueType({apiName:"apiName",displayName:"displayName",type:{"type":"boolean",constraints:[{constraint:{"allowedValues":["TRUE_VALUE"]}}]},version:"not a version"})).toThrowErrorMatchingInlineSnapshot("[Error: Invariant failed: Version is not a valid semver]");});it("Tests convertProperty function with valueType constraints for string",()=>{const testStringValueType=defineValueType({apiName:"stringWithConstraints",displayName:"String With Constraints",description:"A string type with additional constraints",type:{"type":"string",constraints:[{constraint:{type:"length",length:{minSize:5,maxSize:20}},failureMessage:{message:"String must be between 5 and 20 characters"}}]},version:"1.0.0"});defineObject({titlePropertyApiName:"constrainedString",displayName:"Test Object",pluralDisplayName:"Test Objects",apiName:"testObject",primaryKeyPropertyApiName:"constrainedString",properties:{"constrainedString":{type:"string",displayName:"Constrained String",valueType:testStringValueType}}});const ontology=dumpOntologyFullMetadata();const objectPropertyType=ontology.ontology.objectTypes["com.palantir.testObject"].objectType.propertyTypes["constrainedString"];expect(objectPropertyType.valueType).toEqual({apiName:"stringWithConstraints",version:"1.0.0",packageNamespace:"com.palantir",displayMetadata:{displayName:"String With Constraints",description:"A string type with additional constraints"}});expect(objectPropertyType.dataConstraints).toBeDefined();expect(objectPropertyType.dataConstraints?.propertyTypeConstraints).toHaveLength(1);const constraintWrapper=objectPropertyType.dataConstraints?.propertyTypeConstraints[0];expect(constraintWrapper?.constraints?.type).toBe("string");expect((constraintWrapper?.constraints).string.length.minSize).toBe(5);expect((constraintWrapper?.constraints).string.length.maxSize).toBe(20);expect(constraintWrapper?.failureMessage?.message).toBe("String must be between 5 and 20 characters");});it("Correctly serializes a value type",()=>{defineValueType({apiName:"apiName",displayName:"displayName",type:{"type":"boolean",constraints:[{constraint:{"allowedValues":["TRUE_VALUE"]}}]},version:"0.1.0"});expect(dumpValueTypeWireType()).toMatchInlineSnapshot(`
|
|
16
|
+
{
|
|
17
|
+
"valueTypes": [
|
|
18
|
+
{
|
|
19
|
+
"metadata": {
|
|
20
|
+
"apiName": "apiName",
|
|
21
|
+
"displayMetadata": {
|
|
22
|
+
"description": "",
|
|
23
|
+
"displayName": "displayName",
|
|
24
|
+
},
|
|
25
|
+
"packageNamespace": "com.palantir",
|
|
26
|
+
"status": {
|
|
27
|
+
"active": {},
|
|
28
|
+
"type": "active",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
"versions": [
|
|
32
|
+
{
|
|
33
|
+
"baseType": {
|
|
34
|
+
"boolean": {},
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
},
|
|
37
|
+
"constraints": [
|
|
38
|
+
{
|
|
39
|
+
"constraint": {
|
|
40
|
+
"constraint": {
|
|
41
|
+
"boolean": {
|
|
42
|
+
"allowedValues": [
|
|
43
|
+
"TRUE_VALUE",
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
},
|
|
48
|
+
"failureMessage": undefined,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
"exampleValues": [],
|
|
53
|
+
"version": "0.1.0",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
}
|
|
59
|
+
`);});// N.B Not sure what this is for but I don't want to break anything so I added the eslint ignore
|
|
59
60
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
60
|
-
defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it("doesn't let you define the same interface twice",()=>{defineInterface({apiName:"Foo"});expect(()=>{defineInterface({apiName:"Foo"});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Interface com.palantir.Foo already exists]`);});it("defaults displayName to apiName",()=>{const result=defineInterface({apiName:"Foo"});expect(result.displayMetadata.displayName).toBe("Foo");});it("defaults description to displayName",()=>{const result=defineInterface({apiName:"Foo",displayName:"d"});expect(result.displayMetadata.description).toBe("d");});it("defaults description to displayName to apiName",()=>{const result=defineInterface({apiName:"Foo"});expect(result.displayMetadata.description).toBe("Foo");});describe("auto spts",()=>{it("auto creates spts",()=>{defineInterface({apiName:"Foo",properties:{foo:"string"}});expect(dumpOntologyFullMetadata().
|
|
61
|
+
defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it("doesn't let you define the same interface twice",()=>{defineInterface({apiName:"Foo"});expect(()=>{defineInterface({apiName:"Foo"});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Interface com.palantir.Foo already exists]`);});it("defaults displayName to apiName",()=>{const result=defineInterface({apiName:"Foo"});expect(result.displayMetadata.displayName).toBe("Foo");});it("defaults description to displayName",()=>{const result=defineInterface({apiName:"Foo",displayName:"d"});expect(result.displayMetadata.description).toBe("d");});it("defaults description to displayName to apiName",()=>{const result=defineInterface({apiName:"Foo"});expect(result.displayMetadata.description).toBe("Foo");});describe("auto spts",()=>{it("auto creates spts",()=>{defineInterface({apiName:"Foo",properties:{foo:"string"}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
61
62
|
{
|
|
62
63
|
"actionTypes": {},
|
|
63
64
|
"blockPermissionInformation": {
|
|
@@ -72,7 +73,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
72
73
|
"displayMetadata": {
|
|
73
74
|
"description": "Foo",
|
|
74
75
|
"displayName": "Foo",
|
|
75
|
-
"icon": undefined,
|
|
76
76
|
},
|
|
77
77
|
"extendsInterfaces": [],
|
|
78
78
|
"links": [],
|
|
@@ -166,7 +166,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
166
166
|
},
|
|
167
167
|
},
|
|
168
168
|
}
|
|
169
|
-
`);});it("does not let you conflict spts",()=>{defineSharedPropertyType({apiName:"foo",type:"string"});expect(dumpOntologyFullMetadata().
|
|
169
|
+
`);});it("does not let you conflict spts",()=>{defineSharedPropertyType({apiName:"foo",type:"string"});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
170
170
|
{
|
|
171
171
|
"actionTypes": {},
|
|
172
172
|
"blockPermissionInformation": {
|
|
@@ -216,7 +216,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
216
216
|
},
|
|
217
217
|
},
|
|
218
218
|
}
|
|
219
|
-
`);expect(()=>{defineInterface({apiName:"Foo",properties:{foo:"string"}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);});});it("allows extends interfaces with InterfaceType provided",()=>{const parentInterface=defineInterface({apiName:"parentInterface",properties:{property1:"string"}});defineInterface({apiName:"childInterface",properties:{property2:"string"},extends:[parentInterface]});expect(dumpOntologyFullMetadata().
|
|
219
|
+
`);expect(()=>{defineInterface({apiName:"Foo",properties:{foo:"string"}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);});});it("allows extends interfaces with InterfaceType provided",()=>{const parentInterface=defineInterface({apiName:"parentInterface",properties:{property1:"string"}});defineInterface({apiName:"childInterface",properties:{property2:"string"},extends:[parentInterface]});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
220
220
|
{
|
|
221
221
|
"actionTypes": {},
|
|
222
222
|
"blockPermissionInformation": {
|
|
@@ -231,7 +231,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
231
231
|
"displayMetadata": {
|
|
232
232
|
"description": "childInterface",
|
|
233
233
|
"displayName": "childInterface",
|
|
234
|
-
"icon": undefined,
|
|
235
234
|
},
|
|
236
235
|
"extendsInterfaces": [
|
|
237
236
|
"com.palantir.parentInterface",
|
|
@@ -291,7 +290,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
291
290
|
"displayMetadata": {
|
|
292
291
|
"description": "parentInterface",
|
|
293
292
|
"displayName": "parentInterface",
|
|
294
|
-
"icon": undefined,
|
|
295
293
|
},
|
|
296
294
|
"extendsInterfaces": [],
|
|
297
295
|
"links": [],
|
|
@@ -421,7 +419,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
421
419
|
},
|
|
422
420
|
},
|
|
423
421
|
}
|
|
424
|
-
`);});it("supports optional properties",()=>{defineInterface({apiName:"parentInterface",properties:{property1:{required:false,propertyDefinition:"string"}}});expect(dumpOntologyFullMetadata().
|
|
422
|
+
`);});it("supports optional properties",()=>{defineInterface({apiName:"parentInterface",properties:{property1:{required:false,propertyDefinition:"string"}}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
425
423
|
{
|
|
426
424
|
"actionTypes": {},
|
|
427
425
|
"blockPermissionInformation": {
|
|
@@ -436,7 +434,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
436
434
|
"displayMetadata": {
|
|
437
435
|
"description": "parentInterface",
|
|
438
436
|
"displayName": "parentInterface",
|
|
439
|
-
"icon": undefined,
|
|
440
437
|
},
|
|
441
438
|
"extendsInterfaces": [],
|
|
442
439
|
"links": [],
|
|
@@ -530,7 +527,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
530
527
|
},
|
|
531
528
|
},
|
|
532
529
|
}
|
|
533
|
-
`);});it("allows extends interfaces with apiName provided",()=>{const parentInterface=defineInterface({apiName:"parentInterface",properties:{property1:"string"}});defineInterface({apiName:"childInterface",properties:{property2:"string"},extends:parentInterface});expect(dumpOntologyFullMetadata().
|
|
530
|
+
`);});it("allows extends interfaces with apiName provided",()=>{const parentInterface=defineInterface({apiName:"parentInterface",properties:{property1:"string"}});defineInterface({apiName:"childInterface",properties:{property2:"string"},extends:parentInterface});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
534
531
|
{
|
|
535
532
|
"actionTypes": {},
|
|
536
533
|
"blockPermissionInformation": {
|
|
@@ -545,7 +542,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
545
542
|
"displayMetadata": {
|
|
546
543
|
"description": "childInterface",
|
|
547
544
|
"displayName": "childInterface",
|
|
548
|
-
"icon": undefined,
|
|
549
545
|
},
|
|
550
546
|
"extendsInterfaces": [
|
|
551
547
|
"com.palantir.parentInterface",
|
|
@@ -605,7 +601,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
605
601
|
"displayMetadata": {
|
|
606
602
|
"description": "parentInterface",
|
|
607
603
|
"displayName": "parentInterface",
|
|
608
|
-
"icon": undefined,
|
|
609
604
|
},
|
|
610
605
|
"extendsInterfaces": [],
|
|
611
606
|
"links": [],
|
|
@@ -735,7 +730,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
735
730
|
},
|
|
736
731
|
},
|
|
737
732
|
}
|
|
738
|
-
`);});it("supports specifying searchable",()=>{defineInterface({apiName:"parentInterface",searchable:false});expect(dumpOntologyFullMetadata().
|
|
733
|
+
`);});it("supports specifying searchable",()=>{defineInterface({apiName:"parentInterface",searchable:false});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
739
734
|
{
|
|
740
735
|
"actionTypes": {},
|
|
741
736
|
"blockPermissionInformation": {
|
|
@@ -750,7 +745,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
750
745
|
"displayMetadata": {
|
|
751
746
|
"description": "parentInterface",
|
|
752
747
|
"displayName": "parentInterface",
|
|
753
|
-
"icon": undefined,
|
|
754
748
|
},
|
|
755
749
|
"extendsInterfaces": [],
|
|
756
750
|
"links": [],
|
|
@@ -769,7 +763,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
769
763
|
"objectTypes": {},
|
|
770
764
|
"sharedPropertyTypes": {},
|
|
771
765
|
}
|
|
772
|
-
`);});});describe("ILTs",()=>{let a;let b;beforeEach(()=>{a=defineInterface({apiName:"A"});b=defineInterface({apiName:"B"});});it("single link works",()=>{expect(a).not.toBeUndefined();defineInterfaceLinkConstraint({from:a,toOne:b,apiName:"singleLink"});expect(dumpOntologyFullMetadata().
|
|
766
|
+
`);});});describe("ILTs",()=>{let a;let b;beforeEach(()=>{a=defineInterface({apiName:"A"});b=defineInterface({apiName:"B"});});it("single link works",()=>{expect(a).not.toBeUndefined();defineInterfaceLinkConstraint({from:a,toOne:b,apiName:"singleLink"});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
773
767
|
{
|
|
774
768
|
"actionTypes": {},
|
|
775
769
|
"blockPermissionInformation": {
|
|
@@ -784,7 +778,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
784
778
|
"displayMetadata": {
|
|
785
779
|
"description": "A",
|
|
786
780
|
"displayName": "A",
|
|
787
|
-
"icon": undefined,
|
|
788
781
|
},
|
|
789
782
|
"extendsInterfaces": [],
|
|
790
783
|
"links": [
|
|
@@ -818,7 +811,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
818
811
|
"displayMetadata": {
|
|
819
812
|
"description": "B",
|
|
820
813
|
"displayName": "B",
|
|
821
|
-
"icon": undefined,
|
|
822
814
|
},
|
|
823
815
|
"extendsInterfaces": [],
|
|
824
816
|
"links": [],
|
|
@@ -837,7 +829,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
837
829
|
"objectTypes": {},
|
|
838
830
|
"sharedPropertyTypes": {},
|
|
839
831
|
}
|
|
840
|
-
`);});it("many link works",()=>{defineInterfaceLinkConstraint({from:a,toMany:b,apiName:"manyLink"});expect(dumpOntologyFullMetadata().
|
|
832
|
+
`);});it("many link works",()=>{defineInterfaceLinkConstraint({from:a,toMany:b,apiName:"manyLink"});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
841
833
|
{
|
|
842
834
|
"actionTypes": {},
|
|
843
835
|
"blockPermissionInformation": {
|
|
@@ -852,7 +844,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
852
844
|
"displayMetadata": {
|
|
853
845
|
"description": "A",
|
|
854
846
|
"displayName": "A",
|
|
855
|
-
"icon": undefined,
|
|
856
847
|
},
|
|
857
848
|
"extendsInterfaces": [],
|
|
858
849
|
"links": [
|
|
@@ -886,7 +877,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
886
877
|
"displayMetadata": {
|
|
887
878
|
"description": "B",
|
|
888
879
|
"displayName": "B",
|
|
889
|
-
"icon": undefined,
|
|
890
880
|
},
|
|
891
881
|
"extendsInterfaces": [],
|
|
892
882
|
"links": [],
|
|
@@ -905,7 +895,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
905
895
|
"objectTypes": {},
|
|
906
896
|
"sharedPropertyTypes": {},
|
|
907
897
|
}
|
|
908
|
-
`);});});describe("SPTs",()=>{it("doesn't let you create the same spt twice",()=>{defineSharedPropertyType({apiName:"foo",type:"string"});expect(()=>{defineSharedPropertyType({apiName:"foo",type:"string"});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);});});it("uses a predefined spt",()=>{const fooSpt=defineSharedPropertyType({apiName:"fooSpt",type:"string"});defineInterface({apiName:"FooInterface",displayName:"Foo Interface",properties:{fooSpt},icon:{color:"#00000",locator:"airplane"}});expect(dumpOntologyFullMetadata().
|
|
898
|
+
`);});});describe("SPTs",()=>{it("doesn't let you create the same spt twice",()=>{defineSharedPropertyType({apiName:"foo",type:"string"});expect(()=>{defineSharedPropertyType({apiName:"foo",type:"string"});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Shared property type com.palantir.foo already exists]`);});});it("uses a predefined spt",()=>{const fooSpt=defineSharedPropertyType({apiName:"fooSpt",type:"string"});defineInterface({apiName:"FooInterface",displayName:"Foo Interface",properties:{fooSpt},icon:{color:"#00000",locator:"airplane"}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
909
899
|
{
|
|
910
900
|
"actionTypes": {},
|
|
911
901
|
"blockPermissionInformation": {
|
|
@@ -920,13 +910,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
920
910
|
"displayMetadata": {
|
|
921
911
|
"description": "Foo Interface",
|
|
922
912
|
"displayName": "Foo Interface",
|
|
923
|
-
"icon": {
|
|
924
|
-
"blueprint": {
|
|
925
|
-
"color": "#00000",
|
|
926
|
-
"locator": "airplane",
|
|
927
|
-
},
|
|
928
|
-
"type": "blueprint",
|
|
929
|
-
},
|
|
930
913
|
},
|
|
931
914
|
"extendsInterfaces": [],
|
|
932
915
|
"links": [],
|
|
@@ -1020,7 +1003,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1020
1003
|
},
|
|
1021
1004
|
},
|
|
1022
1005
|
}
|
|
1023
|
-
`);});it("properly serializes both types of struct SPTs",()=>{defineSharedPropertyType({apiName:"fooSpt",type:{type:"struct",structDefinition:{"simpleProperty":"boolean","complexProperty":{fieldType:"date",displayMetadata:{displayName:"complex property",description:undefined}}}}});expect(dumpOntologyFullMetadata().
|
|
1006
|
+
`);});it("properly serializes both types of struct SPTs",()=>{defineSharedPropertyType({apiName:"fooSpt",type:{type:"struct",structDefinition:{"simpleProperty":"boolean","complexProperty":{fieldType:"date",displayMetadata:{displayName:"complex property",description:undefined}}}}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
1024
1007
|
{
|
|
1025
1008
|
"actionTypes": {},
|
|
1026
1009
|
"blockPermissionInformation": {
|
|
@@ -1084,7 +1067,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1084
1067
|
},
|
|
1085
1068
|
},
|
|
1086
1069
|
}
|
|
1087
|
-
`);});it("Custom string fields properly set",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:{type:"string",isLongText:true,supportsEfficientLeadingWildcard:true,supportsExactMatching:false}});defineInterface({apiName:"interface",properties:{foo:spt}});expect(dumpOntologyFullMetadata().
|
|
1070
|
+
`);});it("Custom string fields properly set",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:{type:"string",isLongText:true,supportsEfficientLeadingWildcard:true,supportsExactMatching:false}});defineInterface({apiName:"interface",properties:{foo:spt}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
1088
1071
|
{
|
|
1089
1072
|
"actionTypes": {},
|
|
1090
1073
|
"blockPermissionInformation": {
|
|
@@ -1099,7 +1082,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1099
1082
|
"displayMetadata": {
|
|
1100
1083
|
"description": "interface",
|
|
1101
1084
|
"displayName": "interface",
|
|
1102
|
-
"icon": undefined,
|
|
1103
1085
|
},
|
|
1104
1086
|
"extendsInterfaces": [],
|
|
1105
1087
|
"links": [],
|
|
@@ -1193,7 +1175,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1193
1175
|
},
|
|
1194
1176
|
},
|
|
1195
1177
|
}
|
|
1196
|
-
`);});it("defaults interface status to active",()=>{const result=defineInterface({apiName:"Foo"});expect(result.status).toEqual({type:"active",active:{}});});it("sets interface status as experimental from opts",()=>{const result=defineInterface({apiName:"Foo",status:{type:"experimental"}});expect(result.status).toEqual({type:"experimental",experimental:{}});});it("sets interface status as deprecated from opts",()=>{const result=defineInterface({apiName:"Foo",status:{type:"deprecated",message:"foo",deadline:"foo"}});expect(result.status).toEqual({type:"deprecated",deprecated:{message:"foo",deadline:"foo"}});});describe("Objects",()=>{it("Fails if any property reference does not exist",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:"string"});const sample=defineInterface({apiName:"interface",properties:{foo:spt}});expect(()=>{defineObject({titlePropertyApiName:"fizz",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Title property fizz is not defined on object foo]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"fizz",properties:{"bar":{type:"string"}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Primary key property fizz does not exist on object foo]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"com.palantir.foo",mapsTo:"fizz"}]}]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: \nOntology Definition Error: Object property mapped to interface does not exist. Object Property Mapped: fizz\n]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"com.palantir.fizz",mapsTo:"bar"},{interfaceProperty:"com.palantir.foo",mapsTo:"bar"}]}]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: \nOntology Definition Error: Interface property com.palantir.fizz referenced in foo object does not exist\n]`);});it("Objects properly defined",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:"string"});const sample=defineInterface({apiName:"interface",properties:{foo:spt}});defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string",displayName:"Bar"},"arrayProp":{type:"string",array:true,displayName:"Array Property Test"},"geopoint":{type:{type:"struct",structDefinition:{lat:"double",lng:"double"}},displayName:"geopoint"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"foo",mapsTo:"bar"}]}]});expect(dumpOntologyFullMetadata().
|
|
1178
|
+
`);});it("defaults interface status to active",()=>{const result=defineInterface({apiName:"Foo"});expect(result.status).toEqual({type:"active",active:{}});});it("sets interface status as experimental from opts",()=>{const result=defineInterface({apiName:"Foo",status:{type:"experimental"}});expect(result.status).toEqual({type:"experimental",experimental:{}});});it("sets interface status as deprecated from opts",()=>{const result=defineInterface({apiName:"Foo",status:{type:"deprecated",message:"foo",deadline:"foo"}});expect(result.status).toEqual({type:"deprecated",deprecated:{message:"foo",deadline:"foo"}});});describe("Objects",()=>{it("Fails if any property reference does not exist",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:"string"});const sample=defineInterface({apiName:"interface",properties:{foo:spt}});expect(()=>{defineObject({titlePropertyApiName:"fizz",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Title property fizz is not defined on object foo]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"fizz",properties:{"bar":{type:"string"}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Primary key property fizz does not exist on object foo]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"com.palantir.foo",mapsTo:"fizz"}]}]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: \nOntology Definition Error: Object property mapped to interface does not exist. Object Property Mapped: fizz\n]`);expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"com.palantir.fizz",mapsTo:"bar"},{interfaceProperty:"com.palantir.foo",mapsTo:"bar"}]}]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: \nOntology Definition Error: Interface property com.palantir.fizz referenced in foo object does not exist\n]`);});it("Objects properly defined",()=>{const spt=defineSharedPropertyType({apiName:"foo",type:"string"});const sample=defineInterface({apiName:"interface",properties:{foo:spt}});defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string",displayName:"Bar"},"arrayProp":{type:"string",array:true,displayName:"Array Property Test"},"geopoint":{type:{type:"struct",structDefinition:{lat:"double",lng:"double"}},displayName:"geopoint"}},implementsInterfaces:[{implements:sample,propertyMapping:[{interfaceProperty:"foo",mapsTo:"bar"}]}]});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
1197
1179
|
{
|
|
1198
1180
|
"actionTypes": {},
|
|
1199
1181
|
"blockPermissionInformation": {
|
|
@@ -1208,7 +1190,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1208
1190
|
"displayMetadata": {
|
|
1209
1191
|
"description": "interface",
|
|
1210
1192
|
"displayName": "interface",
|
|
1211
|
-
"icon": undefined,
|
|
1212
1193
|
},
|
|
1213
1194
|
"extendsInterfaces": [],
|
|
1214
1195
|
"links": [],
|
|
@@ -1529,7 +1510,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1529
1510
|
},
|
|
1530
1511
|
},
|
|
1531
1512
|
}
|
|
1532
|
-
`);});it("One To Many Links are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",one:{object:object,metadata:{apiName:"fizzes",displayName:"Foo",pluralDisplayName:"Foos"}},toMany:{object:otherObject,metadata:{displayName:"Fizz",pluralDisplayName:"Fizzes",apiName:"foos"}},manyForeignKeyProperty:"bar"});expect(dumpOntologyFullMetadata().
|
|
1513
|
+
`);});it("One To Many Links are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",one:{object:object,metadata:{apiName:"fizzes",displayName:"Foo",pluralDisplayName:"Foos"}},toMany:{object:otherObject,metadata:{displayName:"Fizz",pluralDisplayName:"Fizzes",apiName:"foos"}},manyForeignKeyProperty:"bar"});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
1533
1514
|
{
|
|
1534
1515
|
"actionTypes": {},
|
|
1535
1516
|
"blockPermissionInformation": {
|
|
@@ -1834,7 +1815,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
1834
1815
|
},
|
|
1835
1816
|
"sharedPropertyTypes": {},
|
|
1836
1817
|
}
|
|
1837
|
-
`);});it("Many To Many Links are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",many:{object:object,metadata:{displayName:"Foo",pluralDisplayName:"Foos",apiName:"fizzes"}},toMany:{object:otherObject,metadata:{displayName:"Fizz",pluralDisplayName:"Fizzes",apiName:"foos"}}});expect(dumpOntologyFullMetadata().
|
|
1818
|
+
`);});it("Many To Many Links are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",many:{object:object,metadata:{displayName:"Foo",pluralDisplayName:"Foos",apiName:"fizzes"}},toMany:{object:otherObject,metadata:{displayName:"Fizz",pluralDisplayName:"Fizzes",apiName:"foos"}}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
1838
1819
|
{
|
|
1839
1820
|
"actionTypes": {},
|
|
1840
1821
|
"blockPermissionInformation": {
|
|
@@ -2184,7 +2165,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
2184
2165
|
},
|
|
2185
2166
|
"sharedPropertyTypes": {},
|
|
2186
2167
|
}
|
|
2187
|
-
`);});it("Minimal link definitions are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",one:{object:object,metadata:{apiName:"fizzes"}},toMany:{object:otherObject,metadata:{apiName:"foos"}},manyForeignKeyProperty:"bar"});expect(dumpOntologyFullMetadata().
|
|
2168
|
+
`);});it("Minimal link definitions are properly defined",()=>{const object=defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}}});const otherObject=defineObject({titlePropertyApiName:"fizz",displayName:"Fizz",pluralDisplayName:"Fizz",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}}});defineLink({apiName:"fizzToFoo",one:{object:object,metadata:{apiName:"fizzes"}},toMany:{object:otherObject,metadata:{apiName:"foos"}},manyForeignKeyProperty:"bar"});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
2188
2169
|
{
|
|
2189
2170
|
"actionTypes": {},
|
|
2190
2171
|
"blockPermissionInformation": {
|
|
@@ -2489,7 +2470,7 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
2489
2470
|
},
|
|
2490
2471
|
"sharedPropertyTypes": {},
|
|
2491
2472
|
}
|
|
2492
|
-
`);});it("Explicit datasource definitions are properly defined",()=>{defineObject({titlePropertyApiName:"bar",displayName:"datasetBackedObject",pluralDisplayName:"datasetBackedObject",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},datasource:{type:"dataset"}});defineObject({titlePropertyApiName:"fizz",displayName:"streamBackedObjectNoRetention",pluralDisplayName:"streamBackedObjectNoRetention",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}},datasource:{type:"stream"}});defineObject({titlePropertyApiName:"buzz",displayName:"streamBackedObjectWithRetention",pluralDisplayName:"streamBackedObjectWithRetention",apiName:"buzz",primaryKeyPropertyApiName:"buzz",properties:{"buzz":{type:"string"}},datasource:{type:"stream",retentionPeriod:"PT1H"}});expect(dumpOntologyFullMetadata().
|
|
2473
|
+
`);});it("Explicit datasource definitions are properly defined",()=>{defineObject({titlePropertyApiName:"bar",displayName:"datasetBackedObject",pluralDisplayName:"datasetBackedObject",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},datasource:{type:"dataset"}});defineObject({titlePropertyApiName:"fizz",displayName:"streamBackedObjectNoRetention",pluralDisplayName:"streamBackedObjectNoRetention",apiName:"fizz",primaryKeyPropertyApiName:"fizz",properties:{"fizz":{type:"string"},"bar":{type:"string"}},datasource:{type:"stream"}});defineObject({titlePropertyApiName:"buzz",displayName:"streamBackedObjectWithRetention",pluralDisplayName:"streamBackedObjectWithRetention",apiName:"buzz",primaryKeyPropertyApiName:"buzz",properties:{"buzz":{type:"string"}},datasource:{type:"stream",retentionPeriod:"PT1H"}});expect(dumpOntologyFullMetadata().ontology).toMatchInlineSnapshot(`
|
|
2493
2474
|
{
|
|
2494
2475
|
"actionTypes": {},
|
|
2495
2476
|
"blockPermissionInformation": {
|
|
@@ -2840,7 +2821,22 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
2840
2821
|
}
|
|
2841
2822
|
`);});it("Restricted view datasources are properly defined",()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},datasource:{type:"restrictedView"}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
2842
2823
|
{
|
|
2843
|
-
"
|
|
2824
|
+
"importedOntology": {
|
|
2825
|
+
"actionTypes": {},
|
|
2826
|
+
"blockPermissionInformation": {
|
|
2827
|
+
"actionTypes": {},
|
|
2828
|
+
"linkTypes": {},
|
|
2829
|
+
"objectTypes": {},
|
|
2830
|
+
},
|
|
2831
|
+
"interfaceTypes": {},
|
|
2832
|
+
"linkTypes": {},
|
|
2833
|
+
"objectTypes": {},
|
|
2834
|
+
"sharedPropertyTypes": {},
|
|
2835
|
+
},
|
|
2836
|
+
"importedValueTypes": {
|
|
2837
|
+
"valueTypes": [],
|
|
2838
|
+
},
|
|
2839
|
+
"ontology": {
|
|
2844
2840
|
"actionTypes": {},
|
|
2845
2841
|
"blockPermissionInformation": {
|
|
2846
2842
|
"actionTypes": {},
|
|
@@ -2949,17 +2945,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
2949
2945
|
},
|
|
2950
2946
|
"sharedPropertyTypes": {},
|
|
2951
2947
|
},
|
|
2952
|
-
"
|
|
2953
|
-
"
|
|
2954
|
-
"interfaceTypes": [],
|
|
2955
|
-
"linkTypes": [],
|
|
2956
|
-
"objectTypes": [],
|
|
2957
|
-
"sharedPropertyTypes": [],
|
|
2948
|
+
"valueTypes": {
|
|
2949
|
+
"valueTypes": [],
|
|
2958
2950
|
},
|
|
2959
2951
|
}
|
|
2960
2952
|
`);});it("Edit only properties are properly defined",()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"fizz",properties:{"bar":{type:"string",editOnly:true},"fizz":{type:"string"}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
2961
2953
|
{
|
|
2962
|
-
"
|
|
2954
|
+
"importedOntology": {
|
|
2955
|
+
"actionTypes": {},
|
|
2956
|
+
"blockPermissionInformation": {
|
|
2957
|
+
"actionTypes": {},
|
|
2958
|
+
"linkTypes": {},
|
|
2959
|
+
"objectTypes": {},
|
|
2960
|
+
},
|
|
2961
|
+
"interfaceTypes": {},
|
|
2962
|
+
"linkTypes": {},
|
|
2963
|
+
"objectTypes": {},
|
|
2964
|
+
"sharedPropertyTypes": {},
|
|
2965
|
+
},
|
|
2966
|
+
"importedValueTypes": {
|
|
2967
|
+
"valueTypes": [],
|
|
2968
|
+
},
|
|
2969
|
+
"ontology": {
|
|
2963
2970
|
"actionTypes": {},
|
|
2964
2971
|
"blockPermissionInformation": {
|
|
2965
2972
|
"actionTypes": {},
|
|
@@ -3112,17 +3119,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
3112
3119
|
},
|
|
3113
3120
|
"sharedPropertyTypes": {},
|
|
3114
3121
|
},
|
|
3115
|
-
"
|
|
3116
|
-
"
|
|
3117
|
-
"interfaceTypes": [],
|
|
3118
|
-
"linkTypes": [],
|
|
3119
|
-
"objectTypes": [],
|
|
3120
|
-
"sharedPropertyTypes": [],
|
|
3122
|
+
"valueTypes": {
|
|
3123
|
+
"valueTypes": [],
|
|
3121
3124
|
},
|
|
3122
3125
|
}
|
|
3123
3126
|
`);});it("Fails if edit only property is primary key",()=>{expect(()=>{defineObject({titlePropertyApiName:"bar",displayName:"Foo",pluralDisplayName:"Foo",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string",editOnly:true}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Primary key property bar on object foo cannot be edit-only]`);});it("Fail if stream retention period is not ISO 8601 compliant",()=>{expect(()=>defineObject({titlePropertyApiName:"buzz",displayName:"streamBackedObjectWithRetention",pluralDisplayName:"streamBackedObjectWithRetention",apiName:"buzz",primaryKeyPropertyApiName:"buzz",properties:{"buzz":{type:"string"}},datasource:{type:"stream",retentionPeriod:"bad retention period string"}})).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Retention period "bad retention period string" on object "buzz" is not a valid ISO 8601 duration string]`);});it("Property-level datasources are properly defined",()=>{defineObject({titlePropertyApiName:"bar",displayName:"exampleObject",pluralDisplayName:"exampleObject",apiName:"fizz",primaryKeyPropertyApiName:"bar",properties:{"fizz":{type:"mediaReference"},"bar":{type:"string"}},datasource:{type:"stream"}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
3124
3127
|
{
|
|
3125
|
-
"
|
|
3128
|
+
"importedOntology": {
|
|
3129
|
+
"actionTypes": {},
|
|
3130
|
+
"blockPermissionInformation": {
|
|
3131
|
+
"actionTypes": {},
|
|
3132
|
+
"linkTypes": {},
|
|
3133
|
+
"objectTypes": {},
|
|
3134
|
+
},
|
|
3135
|
+
"interfaceTypes": {},
|
|
3136
|
+
"linkTypes": {},
|
|
3137
|
+
"objectTypes": {},
|
|
3138
|
+
"sharedPropertyTypes": {},
|
|
3139
|
+
},
|
|
3140
|
+
"importedValueTypes": {
|
|
3141
|
+
"valueTypes": [],
|
|
3142
|
+
},
|
|
3143
|
+
"ontology": {
|
|
3126
3144
|
"actionTypes": {},
|
|
3127
3145
|
"blockPermissionInformation": {
|
|
3128
3146
|
"actionTypes": {},
|
|
@@ -3276,17 +3294,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
3276
3294
|
},
|
|
3277
3295
|
"sharedPropertyTypes": {},
|
|
3278
3296
|
},
|
|
3279
|
-
"
|
|
3280
|
-
"
|
|
3281
|
-
"interfaceTypes": [],
|
|
3282
|
-
"linkTypes": [],
|
|
3283
|
-
"objectTypes": [],
|
|
3284
|
-
"sharedPropertyTypes": [],
|
|
3297
|
+
"valueTypes": {
|
|
3298
|
+
"valueTypes": [],
|
|
3285
3299
|
},
|
|
3286
3300
|
}
|
|
3287
|
-
`);});});describe("Marking Constraints",()=>{it("supports marking constraints with CBAC type and markingInputGroupName",()=>{defineObject({titlePropertyApiName:"title",displayName:"Document",pluralDisplayName:"Documents",apiName:"document",primaryKeyPropertyApiName:"title",properties:{"title":{type:"string",displayName:"Title"},"classification":{type:{type:"marking",markingType:"CBAC",markingInputGroupName:"classificationGroup"},displayName:"Classification"}}});const ontology=dumpOntologyFullMetadata();const classificationConstraint=ontology.
|
|
3301
|
+
`);});});describe("Marking Constraints",()=>{it("supports marking constraints with CBAC type and markingInputGroupName",()=>{defineObject({titlePropertyApiName:"title",displayName:"Document",pluralDisplayName:"Documents",apiName:"document",primaryKeyPropertyApiName:"title",properties:{"title":{type:"string",displayName:"Title"},"classification":{type:{type:"marking",markingType:"CBAC",markingInputGroupName:"classificationGroup"},displayName:"Classification"}}});const ontology=dumpOntologyFullMetadata();const classificationConstraint=ontology.ontology.objectTypes["com.palantir.document"].datasources[0].dataSecurity?.classificationConstraint;expect(classificationConstraint.markingGroupName).toEqual("classificationGroup");});});describe("Actions",()=>{it("Interface actions are properly defined",()=>{defineAction({apiName:"foo",displayName:"exampleAction",status:"active",rules:[{type:"addInterfaceRule",addInterfaceRule:{interfaceApiName:"foo",objectTypeParameter:"param1",sharedPropertyValues:{}}}],parameters:[{id:"param1",displayName:"param1",type:"boolean",validation:{required:true,allowedValues:{type:"boolean"}}}]});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
3288
3302
|
{
|
|
3289
|
-
"
|
|
3303
|
+
"importedOntology": {
|
|
3304
|
+
"actionTypes": {},
|
|
3305
|
+
"blockPermissionInformation": {
|
|
3306
|
+
"actionTypes": {},
|
|
3307
|
+
"linkTypes": {},
|
|
3308
|
+
"objectTypes": {},
|
|
3309
|
+
},
|
|
3310
|
+
"interfaceTypes": {},
|
|
3311
|
+
"linkTypes": {},
|
|
3312
|
+
"objectTypes": {},
|
|
3313
|
+
"sharedPropertyTypes": {},
|
|
3314
|
+
},
|
|
3315
|
+
"importedValueTypes": {
|
|
3316
|
+
"valueTypes": [],
|
|
3317
|
+
},
|
|
3318
|
+
"ontology": {
|
|
3290
3319
|
"actionTypes": {
|
|
3291
3320
|
"com.palantir.foo": {
|
|
3292
3321
|
"actionType": {
|
|
@@ -3422,17 +3451,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
3422
3451
|
"objectTypes": {},
|
|
3423
3452
|
"sharedPropertyTypes": {},
|
|
3424
3453
|
},
|
|
3425
|
-
"
|
|
3426
|
-
"
|
|
3427
|
-
"interfaceTypes": [],
|
|
3428
|
-
"linkTypes": [],
|
|
3429
|
-
"objectTypes": [],
|
|
3430
|
-
"sharedPropertyTypes": [],
|
|
3454
|
+
"valueTypes": {
|
|
3455
|
+
"valueTypes": [],
|
|
3431
3456
|
},
|
|
3432
3457
|
}
|
|
3433
3458
|
`);});it("Simple interface actions (with object types) are properly defined",()=>{const exampleStructPropertyType=defineSharedPropertyType({apiName:"property2",type:{type:"struct",structDefinition:{simpleProperty:"string"}}});const mySpt=defineSharedPropertyType({apiName:"mySpt",type:"string"});const exampleInterface=defineInterface({apiName:"exampleInterface",properties:{mySpt,property1:"string",property2:exampleStructPropertyType}});const exampleObjectType=defineObject({titlePropertyApiName:"bar",displayName:"exampleObjectType",pluralDisplayName:"exampleObjectTypes",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"},"property1":{type:"string"},"property2":{type:{type:"struct",structDefinition:{simpleProperty:"string"}}}},implementsInterfaces:[{implements:exampleInterface,propertyMapping:[{interfaceProperty:"com.palantir.mySpt",mapsTo:"bar"},{interfaceProperty:"com.palantir.property1",mapsTo:"property1"},{interfaceProperty:"com.palantir.property2",mapsTo:"property2"}]}]});defineCreateInterfaceObjectAction(exampleInterface,exampleObjectType);defineModifyInterfaceObjectAction(exampleInterface,exampleObjectType);expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
3434
3459
|
{
|
|
3435
|
-
"
|
|
3460
|
+
"importedOntology": {
|
|
3461
|
+
"actionTypes": {},
|
|
3462
|
+
"blockPermissionInformation": {
|
|
3463
|
+
"actionTypes": {},
|
|
3464
|
+
"linkTypes": {},
|
|
3465
|
+
"objectTypes": {},
|
|
3466
|
+
},
|
|
3467
|
+
"interfaceTypes": {},
|
|
3468
|
+
"linkTypes": {},
|
|
3469
|
+
"objectTypes": {},
|
|
3470
|
+
"sharedPropertyTypes": {},
|
|
3471
|
+
},
|
|
3472
|
+
"importedValueTypes": {
|
|
3473
|
+
"valueTypes": [],
|
|
3474
|
+
},
|
|
3475
|
+
"ontology": {
|
|
3436
3476
|
"actionTypes": {
|
|
3437
3477
|
"com.palantir.create-example-interface-foo": {
|
|
3438
3478
|
"actionType": {
|
|
@@ -3914,7 +3954,6 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
3914
3954
|
"displayMetadata": {
|
|
3915
3955
|
"description": "exampleInterface",
|
|
3916
3956
|
"displayName": "exampleInterface",
|
|
3917
|
-
"icon": undefined,
|
|
3918
3957
|
},
|
|
3919
3958
|
"extendsInterfaces": [],
|
|
3920
3959
|
"links": [],
|
|
@@ -4385,17 +4424,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
4385
4424
|
},
|
|
4386
4425
|
},
|
|
4387
4426
|
},
|
|
4388
|
-
"
|
|
4389
|
-
"
|
|
4390
|
-
"interfaceTypes": [],
|
|
4391
|
-
"linkTypes": [],
|
|
4392
|
-
"objectTypes": [],
|
|
4393
|
-
"sharedPropertyTypes": [],
|
|
4427
|
+
"valueTypes": {
|
|
4428
|
+
"valueTypes": [],
|
|
4394
4429
|
},
|
|
4395
4430
|
}
|
|
4396
4431
|
`);});it("Concrete actions are properly defined",()=>{defineAction({apiName:"foo",displayName:"exampleAction",status:"active",rules:[{type:"addOrModifyObjectRuleV2",addOrModifyObjectRuleV2:{objectToModify:"objectToModifyParameter",propertyValues:{"bar":{type:"parameterId",parameterId:"param1"}},structFieldValues:{}}}],parameters:[{id:"param1",displayName:"param1",type:"boolean",validation:{required:true,allowedValues:{type:"boolean"}}}]});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
4397
4432
|
{
|
|
4398
|
-
"
|
|
4433
|
+
"importedOntology": {
|
|
4434
|
+
"actionTypes": {},
|
|
4435
|
+
"blockPermissionInformation": {
|
|
4436
|
+
"actionTypes": {},
|
|
4437
|
+
"linkTypes": {},
|
|
4438
|
+
"objectTypes": {},
|
|
4439
|
+
},
|
|
4440
|
+
"interfaceTypes": {},
|
|
4441
|
+
"linkTypes": {},
|
|
4442
|
+
"objectTypes": {},
|
|
4443
|
+
"sharedPropertyTypes": {},
|
|
4444
|
+
},
|
|
4445
|
+
"importedValueTypes": {
|
|
4446
|
+
"valueTypes": [],
|
|
4447
|
+
},
|
|
4448
|
+
"ontology": {
|
|
4399
4449
|
"actionTypes": {
|
|
4400
4450
|
"com.palantir.foo": {
|
|
4401
4451
|
"actionType": {
|
|
@@ -4536,17 +4586,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
4536
4586
|
"objectTypes": {},
|
|
4537
4587
|
"sharedPropertyTypes": {},
|
|
4538
4588
|
},
|
|
4539
|
-
"
|
|
4540
|
-
"
|
|
4541
|
-
"interfaceTypes": [],
|
|
4542
|
-
"linkTypes": [],
|
|
4543
|
-
"objectTypes": [],
|
|
4544
|
-
"sharedPropertyTypes": [],
|
|
4589
|
+
"valueTypes": {
|
|
4590
|
+
"valueTypes": [],
|
|
4545
4591
|
},
|
|
4546
4592
|
}
|
|
4547
4593
|
`);});it("Conditional overrides on actions are properly defined",()=>{defineAction({apiName:"foo",displayName:"exampleAction",status:"active",rules:[{type:"modifyObjectRule",modifyObjectRule:{objectToModify:"objectToModifyParameter",propertyValues:{"bar":{type:"parameterId",parameterId:"param1"}},structFieldValues:{}}}],parameters:[{id:"param1",displayName:"param1",type:"boolean",validation:{required:true,allowedValues:{type:"boolean"},defaultVisibility:"editable",conditionalOverrides:[{type:"visibility",condition:{type:"group",name:"myGroup"}}]}},{id:"objectToModifyParameter",displayName:"objectToModifyParameter",type:"objectTypeReference",validation:{required:true,allowedValues:{type:"objectTypeReference",interfaceTypes:[]},defaultVisibility:"editable"}}]});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
4548
4594
|
{
|
|
4549
|
-
"
|
|
4595
|
+
"importedOntology": {
|
|
4596
|
+
"actionTypes": {},
|
|
4597
|
+
"blockPermissionInformation": {
|
|
4598
|
+
"actionTypes": {},
|
|
4599
|
+
"linkTypes": {},
|
|
4600
|
+
"objectTypes": {},
|
|
4601
|
+
},
|
|
4602
|
+
"interfaceTypes": {},
|
|
4603
|
+
"linkTypes": {},
|
|
4604
|
+
"objectTypes": {},
|
|
4605
|
+
"sharedPropertyTypes": {},
|
|
4606
|
+
},
|
|
4607
|
+
"importedValueTypes": {
|
|
4608
|
+
"valueTypes": [],
|
|
4609
|
+
},
|
|
4610
|
+
"ontology": {
|
|
4550
4611
|
"actionTypes": {
|
|
4551
4612
|
"com.palantir.foo": {
|
|
4552
4613
|
"actionType": {
|
|
@@ -4774,17 +4835,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
4774
4835
|
"objectTypes": {},
|
|
4775
4836
|
"sharedPropertyTypes": {},
|
|
4776
4837
|
},
|
|
4777
|
-
"
|
|
4778
|
-
"
|
|
4779
|
-
"interfaceTypes": [],
|
|
4780
|
-
"linkTypes": [],
|
|
4781
|
-
"objectTypes": [],
|
|
4782
|
-
"sharedPropertyTypes": [],
|
|
4838
|
+
"valueTypes": {
|
|
4839
|
+
"valueTypes": [],
|
|
4783
4840
|
},
|
|
4784
4841
|
}
|
|
4785
4842
|
`);});it("Simple concrete actions are properly defined",()=>{const exampleObjectType=defineObject({titlePropertyApiName:"bar",displayName:"exampleObjectType",pluralDisplayName:"exampleObjectTypes",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"},"structProp":{type:{type:"struct",structDefinition:{simpleProperty:"string"}}},"optionalProp":{type:"string"}}});defineCreateObjectAction({objectType:exampleObjectType});defineModifyObjectAction({objectType:exampleObjectType});defineDeleteObjectAction({objectType:exampleObjectType});defineCreateOrModifyObjectAction({objectType:exampleObjectType});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
4786
4843
|
{
|
|
4787
|
-
"
|
|
4844
|
+
"importedOntology": {
|
|
4845
|
+
"actionTypes": {},
|
|
4846
|
+
"blockPermissionInformation": {
|
|
4847
|
+
"actionTypes": {},
|
|
4848
|
+
"linkTypes": {},
|
|
4849
|
+
"objectTypes": {},
|
|
4850
|
+
},
|
|
4851
|
+
"interfaceTypes": {},
|
|
4852
|
+
"linkTypes": {},
|
|
4853
|
+
"objectTypes": {},
|
|
4854
|
+
"sharedPropertyTypes": {},
|
|
4855
|
+
},
|
|
4856
|
+
"importedValueTypes": {
|
|
4857
|
+
"valueTypes": [],
|
|
4858
|
+
},
|
|
4859
|
+
"ontology": {
|
|
4788
4860
|
"actionTypes": {
|
|
4789
4861
|
"com.palantir.create-object-foo": {
|
|
4790
4862
|
"actionType": {
|
|
@@ -5661,17 +5733,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
5661
5733
|
},
|
|
5662
5734
|
"sharedPropertyTypes": {},
|
|
5663
5735
|
},
|
|
5664
|
-
"
|
|
5665
|
-
"
|
|
5666
|
-
"interfaceTypes": [],
|
|
5667
|
-
"linkTypes": [],
|
|
5668
|
-
"objectTypes": [],
|
|
5669
|
-
"sharedPropertyTypes": [],
|
|
5736
|
+
"valueTypes": {
|
|
5737
|
+
"valueTypes": [],
|
|
5670
5738
|
},
|
|
5671
5739
|
}
|
|
5672
5740
|
`);});it("Customizations on CRUD actions are properly defined",()=>{const exampleObjectType=defineObject({titlePropertyApiName:"bar",displayName:"exampleObjectType",pluralDisplayName:"exampleObjectTypes",apiName:"foo",primaryKeyPropertyApiName:"primary",properties:{"bar":{type:"string"},"fizz":{type:"string"},"buzz":{type:"string"},"primary":{type:"string"}}});defineCreateObjectAction({objectType:exampleObjectType,actionLevelValidation:{condition:{type:"group",name:"actionLevelGroup"}},parameterOrdering:["bar","fizz","primary"],parameterConfiguration:{"fizz":{required:false,conditionalOverrides:[{type:"required",condition:{type:"and",conditions:[{type:"group",name:"parameterLevelGroup"},{type:"parameter",parameterId:"bar",matches:{type:"staticValue",staticValue:{type:"string",string:"bar"}}}]}}],defaultValue:{type:"staticValue",staticValue:{type:"string",string:"default_fizz"}},displayName:"fizz_display",description:"fizz_description"}},excludedProperties:["buzz"],defaultFormat:"TABLE",enableLayoutSwitch:true,submissionMetadata:{successMessage:"Custom success message",undoButtonConfiguration:true,submitButtonDisplayMetadata:{intent:"DANGER",text:"Custom button"}}});defineModifyObjectAction({objectType:exampleObjectType,actionLevelValidation:{condition:{type:"group",name:"actionLevelGroup"}},parameterOrdering:["bar","fizz"],parameterConfiguration:{"fizz":{required:false,conditionalOverrides:[{type:"required",condition:{type:"and",conditions:[{type:"group",name:"parameterLevelGroup"},{type:"parameter",parameterId:"bar",matches:{type:"staticValue",staticValue:{type:"string",string:"bar"}}}]}}],defaultValue:{type:"staticValue",staticValue:{type:"string",string:"default_fizz"}},displayName:"fizz_display",description:"fizz_description"}},excludedProperties:["buzz"],defaultFormat:"TABLE",enableLayoutSwitch:true,submissionMetadata:{successMessage:"Custom success message",undoButtonConfiguration:true,submitButtonDisplayMetadata:{intent:"DANGER",text:"Custom button"}}});defineCreateOrModifyObjectAction({objectType:exampleObjectType,actionLevelValidation:{condition:{type:"group",name:"actionLevelGroup"}},parameterOrdering:["bar","fizz"],parameterConfiguration:{"fizz":{required:false,conditionalOverrides:[{type:"required",condition:{type:"and",conditions:[{type:"group",name:"parameterLevelGroup"},{type:"parameter",parameterId:"bar",matches:{type:"staticValue",staticValue:{type:"string",string:"bar"}}}]}}],defaultValue:{type:"staticValue",staticValue:{type:"string",string:"default_fizz"}},displayName:"fizz_display",description:"fizz_description"}},excludedProperties:["buzz"],defaultFormat:"TABLE",enableLayoutSwitch:true,submissionMetadata:{successMessage:"Custom success message",undoButtonConfiguration:true,submitButtonDisplayMetadata:{intent:"DANGER",text:"Custom button"}},primaryKeyOption:"userInput"});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
5673
5741
|
{
|
|
5674
|
-
"
|
|
5742
|
+
"importedOntology": {
|
|
5743
|
+
"actionTypes": {},
|
|
5744
|
+
"blockPermissionInformation": {
|
|
5745
|
+
"actionTypes": {},
|
|
5746
|
+
"linkTypes": {},
|
|
5747
|
+
"objectTypes": {},
|
|
5748
|
+
},
|
|
5749
|
+
"interfaceTypes": {},
|
|
5750
|
+
"linkTypes": {},
|
|
5751
|
+
"objectTypes": {},
|
|
5752
|
+
"sharedPropertyTypes": {},
|
|
5753
|
+
},
|
|
5754
|
+
"importedValueTypes": {
|
|
5755
|
+
"valueTypes": [],
|
|
5756
|
+
},
|
|
5757
|
+
"ontology": {
|
|
5675
5758
|
"actionTypes": {
|
|
5676
5759
|
"com.palantir.create-object-foo": {
|
|
5677
5760
|
"actionType": {
|
|
@@ -6942,17 +7025,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
6942
7025
|
},
|
|
6943
7026
|
"sharedPropertyTypes": {},
|
|
6944
7027
|
},
|
|
6945
|
-
"
|
|
6946
|
-
"
|
|
6947
|
-
"interfaceTypes": [],
|
|
6948
|
-
"linkTypes": [],
|
|
6949
|
-
"objectTypes": [],
|
|
6950
|
-
"sharedPropertyTypes": [],
|
|
7028
|
+
"valueTypes": {
|
|
7029
|
+
"valueTypes": [],
|
|
6951
7030
|
},
|
|
6952
7031
|
}
|
|
6953
7032
|
`);});it("Non-parameter mapped properties are properly defined",()=>{const exampleObjectType=defineObject({titlePropertyApiName:"bar",displayName:"exampleObjectType",pluralDisplayName:"exampleObjectTypes",apiName:"foo",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"},"fizz":{type:"string"},"buzz":{type:"timestamp"}}});defineCreateObjectAction({objectType:exampleObjectType,nonParameterMappings:{"fizz":{type:"currentUser"},"buzz":{type:"currentTime"}}});defineModifyObjectAction({objectType:exampleObjectType,nonParameterMappings:{"fizz":{type:"currentUser"},"buzz":{type:"currentTime"}}});defineCreateOrModifyObjectAction({objectType:exampleObjectType,nonParameterMappings:{"fizz":{type:"currentUser"},"buzz":{type:"currentTime"}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
6954
7033
|
{
|
|
6955
|
-
"
|
|
7034
|
+
"importedOntology": {
|
|
7035
|
+
"actionTypes": {},
|
|
7036
|
+
"blockPermissionInformation": {
|
|
7037
|
+
"actionTypes": {},
|
|
7038
|
+
"linkTypes": {},
|
|
7039
|
+
"objectTypes": {},
|
|
7040
|
+
},
|
|
7041
|
+
"interfaceTypes": {},
|
|
7042
|
+
"linkTypes": {},
|
|
7043
|
+
"objectTypes": {},
|
|
7044
|
+
"sharedPropertyTypes": {},
|
|
7045
|
+
},
|
|
7046
|
+
"importedValueTypes": {
|
|
7047
|
+
"valueTypes": [],
|
|
7048
|
+
},
|
|
7049
|
+
"ontology": {
|
|
6956
7050
|
"actionTypes": {
|
|
6957
7051
|
"com.palantir.create-object-foo": {
|
|
6958
7052
|
"actionType": {
|
|
@@ -7558,17 +7652,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
7558
7652
|
},
|
|
7559
7653
|
"sharedPropertyTypes": {},
|
|
7560
7654
|
},
|
|
7561
|
-
"
|
|
7562
|
-
"
|
|
7563
|
-
"interfaceTypes": [],
|
|
7564
|
-
"linkTypes": [],
|
|
7565
|
-
"objectTypes": [],
|
|
7566
|
-
"sharedPropertyTypes": [],
|
|
7655
|
+
"valueTypes": {
|
|
7656
|
+
"valueTypes": [],
|
|
7567
7657
|
},
|
|
7568
7658
|
}
|
|
7569
7659
|
`);});it("Parameter configuration, property mapping, and excluded property validations work",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string"},"id":{type:"string"}}});expect(()=>{defineCreateObjectAction({objectType:sampleObject,parameterConfiguration:{"name":{displayName:"Name"},"custom_parameter":{displayName:"My Custom Param"}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Parameter custom_parameter does not exist as a property on com.palantir.sampleObject and its type is not explicitly defined]`);expect(()=>{defineCreateObjectAction({objectType:sampleObject,nonParameterMappings:{"custom_parameter":{type:"staticValue",staticValue:{type:"string",string:"custom_value"}}}});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Property custom_parameter does not exist as a property on com.palantir.sampleObject]`);expect(()=>{defineCreateObjectAction({objectType:sampleObject,excludedProperties:["custom_parameter"]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Property custom_parameter does not exist as a property on com.palantir.sampleObject]`);});it("Static default action parameters must match type",()=>{const exampleObjectType=defineObject({titlePropertyApiName:"bar",displayName:"exampleObjectType",pluralDisplayName:"exampleObjectTypes",apiName:"foo",primaryKeyPropertyApiName:"primary",properties:{"bar":{type:"string"},"fizz":{type:"string"},"buzz":{type:"string"},"primary":{type:"string"}}});expect(()=>defineCreateObjectAction({objectType:exampleObjectType,parameterConfiguration:{"buzz":{defaultValue:{type:"staticValue",staticValue:{type:"boolean",boolean:true}}}}})).toThrowError("Invariant failed: Default static value for parameter buzz does not match type");});it("ModifyObjectRule requires objectToModify parameter",()=>{defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string",description:"The name of the test object"},"id":{type:"string",description:"The ID of the test object"}}});expect(()=>defineAction({apiName:"foo",displayName:"exampleAction",status:"active",rules:[{type:"modifyObjectRule",modifyObjectRule:{objectToModify:"sampleObject",propertyValues:{"name":{type:"parameterId",parameterId:"name"}},structFieldValues:{}}}],parameters:[{id:"name",displayName:"Name",type:"string",validation:{required:true,allowedValues:{type:"text"}}}]})).toThrowError("Invariant failed: Object to modify parameter must be defined in parameters");});it("Target object parameters are configurable",()=>{const employeeObject=defineObject({apiName:"employee",displayName:"Employee",pluralDisplayName:"Employees",titlePropertyApiName:"id",primaryKeyPropertyApiName:"id",properties:{"id":{type:"string",displayName:"ID",description:"dummy"},"managedBy":{type:"string"}}});defineModifyObjectAction({objectType:employeeObject,parameterConfiguration:{[MODIFY_OBJECT_PARAMETER]:{displayName:"Chose a manager to modify",description:"Description",conditionalOverrides:[{type:"visibility",condition:{type:"group",name:"supervisors"}}]}}});defineCreateOrModifyObjectAction({objectType:employeeObject,parameterConfiguration:{[CREATE_OR_MODIFY_OBJECT_PARAMETER]:{displayName:"Chose a manager to modify or create a new one",description:"Description",conditionalOverrides:[{type:"visibility",condition:{type:"group",name:"supervisors"}}]}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
7570
7660
|
{
|
|
7571
|
-
"
|
|
7661
|
+
"importedOntology": {
|
|
7662
|
+
"actionTypes": {},
|
|
7663
|
+
"blockPermissionInformation": {
|
|
7664
|
+
"actionTypes": {},
|
|
7665
|
+
"linkTypes": {},
|
|
7666
|
+
"objectTypes": {},
|
|
7667
|
+
},
|
|
7668
|
+
"interfaceTypes": {},
|
|
7669
|
+
"linkTypes": {},
|
|
7670
|
+
"objectTypes": {},
|
|
7671
|
+
"sharedPropertyTypes": {},
|
|
7672
|
+
},
|
|
7673
|
+
"importedValueTypes": {
|
|
7674
|
+
"valueTypes": [],
|
|
7675
|
+
},
|
|
7676
|
+
"ontology": {
|
|
7572
7677
|
"actionTypes": {
|
|
7573
7678
|
"com.palantir.create-or-modify-employee": {
|
|
7574
7679
|
"actionType": {
|
|
@@ -8176,12 +8281,8 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
8176
8281
|
},
|
|
8177
8282
|
"sharedPropertyTypes": {},
|
|
8178
8283
|
},
|
|
8179
|
-
"
|
|
8180
|
-
"
|
|
8181
|
-
"interfaceTypes": [],
|
|
8182
|
-
"linkTypes": [],
|
|
8183
|
-
"objectTypes": [],
|
|
8184
|
-
"sharedPropertyTypes": [],
|
|
8284
|
+
"valueTypes": {
|
|
8285
|
+
"valueTypes": [],
|
|
8185
8286
|
},
|
|
8186
8287
|
}
|
|
8187
8288
|
`);});it("OAC defined object references as parameters are properly defined",()=>{// This test defines an action that creates an OAC-defined employee object type and also adds an additional parameter
|
|
@@ -8190,7 +8291,22 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
8190
8291
|
// id of the selected manager object type.
|
|
8191
8292
|
const employeeObject=defineObject({apiName:"employee",displayName:"Employee",pluralDisplayName:"Employees",titlePropertyApiName:"id",primaryKeyPropertyApiName:"id",properties:{"id":{type:"string",displayName:"ID",description:"dummy"},"managedBy":{type:"string"}}});const managerObject=defineObject({apiName:"manager",displayName:"Manager",pluralDisplayName:"Managers",titlePropertyApiName:"id",primaryKeyPropertyApiName:"id",properties:{"id":{type:"string",displayName:"ID",description:"dummy"}},editsEnabled:true});defineCreateObjectAction({objectType:employeeObject,parameterOrdering:["myManager","id","managedBy"],parameterConfiguration:{"myManager":{customParameterType:{type:"objectReference",objectReference:{objectTypeId:managerObject.apiName}}},"managedBy":{defaultValue:{type:"objectParameterPropertyValue",objectParameterPropertyValue:{parameterId:"myManager",propertyTypeId:"id"}}}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
8192
8293
|
{
|
|
8193
|
-
"
|
|
8294
|
+
"importedOntology": {
|
|
8295
|
+
"actionTypes": {},
|
|
8296
|
+
"blockPermissionInformation": {
|
|
8297
|
+
"actionTypes": {},
|
|
8298
|
+
"linkTypes": {},
|
|
8299
|
+
"objectTypes": {},
|
|
8300
|
+
},
|
|
8301
|
+
"interfaceTypes": {},
|
|
8302
|
+
"linkTypes": {},
|
|
8303
|
+
"objectTypes": {},
|
|
8304
|
+
"sharedPropertyTypes": {},
|
|
8305
|
+
},
|
|
8306
|
+
"importedValueTypes": {
|
|
8307
|
+
"valueTypes": [],
|
|
8308
|
+
},
|
|
8309
|
+
"ontology": {
|
|
8194
8310
|
"actionTypes": {
|
|
8195
8311
|
"com.palantir.create-object-employee": {
|
|
8196
8312
|
"actionType": {
|
|
@@ -8665,17 +8781,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
8665
8781
|
},
|
|
8666
8782
|
"sharedPropertyTypes": {},
|
|
8667
8783
|
},
|
|
8668
|
-
"
|
|
8669
|
-
"
|
|
8670
|
-
"interfaceTypes": [],
|
|
8671
|
-
"linkTypes": [],
|
|
8672
|
-
"objectTypes": [],
|
|
8673
|
-
"sharedPropertyTypes": [],
|
|
8784
|
+
"valueTypes": {
|
|
8785
|
+
"valueTypes": [],
|
|
8674
8786
|
},
|
|
8675
8787
|
}
|
|
8676
8788
|
`);});it("Simple interface actions (without object types) are properly defined",()=>{const exampleInterface=defineInterface({apiName:"exampleInterface",properties:{property1:"string"}});defineCreateInterfaceObjectAction(exampleInterface);defineModifyInterfaceObjectAction(exampleInterface);expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
8677
8789
|
{
|
|
8678
|
-
"
|
|
8790
|
+
"importedOntology": {
|
|
8791
|
+
"actionTypes": {},
|
|
8792
|
+
"blockPermissionInformation": {
|
|
8793
|
+
"actionTypes": {},
|
|
8794
|
+
"linkTypes": {},
|
|
8795
|
+
"objectTypes": {},
|
|
8796
|
+
},
|
|
8797
|
+
"interfaceTypes": {},
|
|
8798
|
+
"linkTypes": {},
|
|
8799
|
+
"objectTypes": {},
|
|
8800
|
+
"sharedPropertyTypes": {},
|
|
8801
|
+
},
|
|
8802
|
+
"importedValueTypes": {
|
|
8803
|
+
"valueTypes": [],
|
|
8804
|
+
},
|
|
8805
|
+
"ontology": {
|
|
8679
8806
|
"actionTypes": {
|
|
8680
8807
|
"com.palantir.create-example-interface": {
|
|
8681
8808
|
"actionType": {
|
|
@@ -9041,7 +9168,6 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9041
9168
|
"displayMetadata": {
|
|
9042
9169
|
"description": "exampleInterface",
|
|
9043
9170
|
"displayName": "exampleInterface",
|
|
9044
|
-
"icon": undefined,
|
|
9045
9171
|
},
|
|
9046
9172
|
"extendsInterfaces": [],
|
|
9047
9173
|
"links": [],
|
|
@@ -9135,17 +9261,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9135
9261
|
},
|
|
9136
9262
|
},
|
|
9137
9263
|
},
|
|
9138
|
-
"
|
|
9139
|
-
"
|
|
9140
|
-
"interfaceTypes": [],
|
|
9141
|
-
"linkTypes": [],
|
|
9142
|
-
"objectTypes": [],
|
|
9143
|
-
"sharedPropertyTypes": [],
|
|
9264
|
+
"valueTypes": {
|
|
9265
|
+
"valueTypes": [],
|
|
9144
9266
|
},
|
|
9145
9267
|
}
|
|
9146
9268
|
`);});it("Actions with group permissions are properly defined",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string",description:"The name of the test object"},"id":{type:"string",displayName:"ID",description:"The ID of the test object"}}});defineCreateObjectAction({objectType:sampleObject,actionLevelValidation:{condition:{type:"group",name:"testGroup"}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
9147
9269
|
{
|
|
9148
|
-
"
|
|
9270
|
+
"importedOntology": {
|
|
9271
|
+
"actionTypes": {},
|
|
9272
|
+
"blockPermissionInformation": {
|
|
9273
|
+
"actionTypes": {},
|
|
9274
|
+
"linkTypes": {},
|
|
9275
|
+
"objectTypes": {},
|
|
9276
|
+
},
|
|
9277
|
+
"interfaceTypes": {},
|
|
9278
|
+
"linkTypes": {},
|
|
9279
|
+
"objectTypes": {},
|
|
9280
|
+
"sharedPropertyTypes": {},
|
|
9281
|
+
},
|
|
9282
|
+
"importedValueTypes": {
|
|
9283
|
+
"valueTypes": [],
|
|
9284
|
+
},
|
|
9285
|
+
"ontology": {
|
|
9149
9286
|
"actionTypes": {
|
|
9150
9287
|
"com.palantir.create-object-sample-object": {
|
|
9151
9288
|
"actionType": {
|
|
@@ -9508,17 +9645,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9508
9645
|
},
|
|
9509
9646
|
"sharedPropertyTypes": {},
|
|
9510
9647
|
},
|
|
9511
|
-
"
|
|
9512
|
-
"
|
|
9513
|
-
"interfaceTypes": [],
|
|
9514
|
-
"linkTypes": [],
|
|
9515
|
-
"objectTypes": [],
|
|
9516
|
-
"sharedPropertyTypes": [],
|
|
9648
|
+
"valueTypes": {
|
|
9649
|
+
"valueTypes": [],
|
|
9517
9650
|
},
|
|
9518
9651
|
}
|
|
9519
9652
|
`);});it("Actions with custom permissions are properly defined",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string",description:"The name of the test object"},"id":{type:"string",displayName:"ID",description:"The ID of the test object"}}});defineCreateObjectAction({objectType:sampleObject,actionLevelValidation:{displayMetadata:{failureMessage:"Insufficient permissions. Missing organization membership required to submit action",typeClasses:[]},condition:{type:"comparison",comparison:{operator:"INTERSECTS",left:{type:"userProperty",userProperty:{userId:{type:"currentUser",currentUser:{}},propertyValue:{type:"organizationMarkingIds",organizationMarkingIds:{}}}},right:{type:"staticValue",staticValue:{type:"stringList",stringList:{strings:["87ef507e-f954-457e-ad68-e0df71ef7567"]}}}}}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
9520
9653
|
{
|
|
9521
|
-
"
|
|
9654
|
+
"importedOntology": {
|
|
9655
|
+
"actionTypes": {},
|
|
9656
|
+
"blockPermissionInformation": {
|
|
9657
|
+
"actionTypes": {},
|
|
9658
|
+
"linkTypes": {},
|
|
9659
|
+
"objectTypes": {},
|
|
9660
|
+
},
|
|
9661
|
+
"interfaceTypes": {},
|
|
9662
|
+
"linkTypes": {},
|
|
9663
|
+
"objectTypes": {},
|
|
9664
|
+
"sharedPropertyTypes": {},
|
|
9665
|
+
},
|
|
9666
|
+
"importedValueTypes": {
|
|
9667
|
+
"valueTypes": [],
|
|
9668
|
+
},
|
|
9669
|
+
"ontology": {
|
|
9522
9670
|
"actionTypes": {
|
|
9523
9671
|
"com.palantir.create-object-sample-object": {
|
|
9524
9672
|
"actionType": {
|
|
@@ -9881,17 +10029,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9881
10029
|
},
|
|
9882
10030
|
"sharedPropertyTypes": {},
|
|
9883
10031
|
},
|
|
9884
|
-
"
|
|
9885
|
-
"
|
|
9886
|
-
"interfaceTypes": [],
|
|
9887
|
-
"linkTypes": [],
|
|
9888
|
-
"objectTypes": [],
|
|
9889
|
-
"sharedPropertyTypes": [],
|
|
10032
|
+
"valueTypes": {
|
|
10033
|
+
"valueTypes": [],
|
|
9890
10034
|
},
|
|
9891
10035
|
}
|
|
9892
10036
|
`);});it("Array property validation is correctly structured for actions",()=>{const objectWithArrays=defineObject({apiName:"objectWithArrays",displayName:"Object With Arrays",primaryKeyPropertyApiName:"id",titlePropertyApiName:"id",pluralDisplayName:"Objects With Arrays",properties:{"id":{type:"string",displayName:"ID"},"tags":{type:"string",array:true,displayName:"Tags"},"numbers":{type:"integer",array:true,displayName:"Numbers"},"singleValue":{type:"string",displayName:"Single Value"}}});defineCreateObjectAction({objectType:objectWithArrays});defineModifyObjectAction({objectType:objectWithArrays});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
9893
10037
|
{
|
|
9894
|
-
"
|
|
10038
|
+
"importedOntology": {
|
|
10039
|
+
"actionTypes": {},
|
|
10040
|
+
"blockPermissionInformation": {
|
|
10041
|
+
"actionTypes": {},
|
|
10042
|
+
"linkTypes": {},
|
|
10043
|
+
"objectTypes": {},
|
|
10044
|
+
},
|
|
10045
|
+
"interfaceTypes": {},
|
|
10046
|
+
"linkTypes": {},
|
|
10047
|
+
"objectTypes": {},
|
|
10048
|
+
"sharedPropertyTypes": {},
|
|
10049
|
+
},
|
|
10050
|
+
"importedValueTypes": {
|
|
10051
|
+
"valueTypes": [],
|
|
10052
|
+
},
|
|
10053
|
+
"ontology": {
|
|
9895
10054
|
"actionTypes": {
|
|
9896
10055
|
"com.palantir.create-object-object-with-arrays": {
|
|
9897
10056
|
"actionType": {
|
|
@@ -10698,17 +10857,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
10698
10857
|
},
|
|
10699
10858
|
"sharedPropertyTypes": {},
|
|
10700
10859
|
},
|
|
10701
|
-
"
|
|
10702
|
-
"
|
|
10703
|
-
"interfaceTypes": [],
|
|
10704
|
-
"linkTypes": [],
|
|
10705
|
-
"objectTypes": [],
|
|
10706
|
-
"sharedPropertyTypes": [],
|
|
10860
|
+
"valueTypes": {
|
|
10861
|
+
"valueTypes": [],
|
|
10707
10862
|
},
|
|
10708
10863
|
}
|
|
10709
10864
|
`);});it("Action sections are properly defined",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string"},"id":{type:"string"}}});defineCreateObjectAction({objectType:sampleObject,sections:[{id:"section1",displayName:"Section 1",parameters:["id"],description:"Description for Section 1",conditionalOverrides:[{type:"visibility",condition:{type:"group",name:"testGroup"}}]}]});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
10710
10865
|
{
|
|
10711
|
-
"
|
|
10866
|
+
"importedOntology": {
|
|
10867
|
+
"actionTypes": {},
|
|
10868
|
+
"blockPermissionInformation": {
|
|
10869
|
+
"actionTypes": {},
|
|
10870
|
+
"linkTypes": {},
|
|
10871
|
+
"objectTypes": {},
|
|
10872
|
+
},
|
|
10873
|
+
"interfaceTypes": {},
|
|
10874
|
+
"linkTypes": {},
|
|
10875
|
+
"objectTypes": {},
|
|
10876
|
+
"sharedPropertyTypes": {},
|
|
10877
|
+
},
|
|
10878
|
+
"importedValueTypes": {
|
|
10879
|
+
"valueTypes": [],
|
|
10880
|
+
},
|
|
10881
|
+
"ontology": {
|
|
10712
10882
|
"actionTypes": {
|
|
10713
10883
|
"com.palantir.create-object-sample-object": {
|
|
10714
10884
|
"actionType": {
|
|
@@ -11117,12 +11287,8 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
11117
11287
|
},
|
|
11118
11288
|
"sharedPropertyTypes": {},
|
|
11119
11289
|
},
|
|
11120
|
-
"
|
|
11121
|
-
"
|
|
11122
|
-
"interfaceTypes": [],
|
|
11123
|
-
"linkTypes": [],
|
|
11124
|
-
"objectTypes": [],
|
|
11125
|
-
"sharedPropertyTypes": [],
|
|
11290
|
+
"valueTypes": {
|
|
11291
|
+
"valueTypes": [],
|
|
11126
11292
|
},
|
|
11127
11293
|
}
|
|
11128
11294
|
`);});it("Action section parameters must exist",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string"},"id":{type:"string"}}});expect(()=>{defineCreateObjectAction({objectType:sampleObject,sections:[{id:"section1",displayName:"Section 1",parameters:["foo"]}]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Parameters ["foo"] were referenced but not defined]`);});it("Custom parameter ordering is properly defined",()=>{const sampleObject=defineObject({apiName:"sampleObject",displayName:"Test Object",description:"Sample object description",primaryKeyPropertyApiName:"id",pluralDisplayName:"tests",titlePropertyApiName:"name",properties:{"name":{type:"string"},"id":{type:"string"},"foo":{type:"string"}}});expect(()=>{defineCreateObjectAction({objectType:sampleObject,parameterOrdering:["foo","id"],excludedProperties:["id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Action parameter ordering for create-object-sample-object does not match expected parameters. Extraneous parameters in ordering: {id}, Missing parameters in ordering: {name}]`);expect(()=>{defineModifyObjectAction({objectType:sampleObject,// primary keys should not be in modify action orderings
|
|
@@ -11132,7 +11298,22 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11132
11298
|
parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Action parameter ordering for modify-object-sample-object does not match expected parameters. Extraneous parameters in ordering: {foo,id}, Missing parameters in ordering: {name}]`);expect(()=>{defineCreateOrModifyObjectAction({objectType:sampleObject,nonParameterMappings:{"foo":{type:"currentUser"}},// non-parameter mapped properties should not be in action orderings
|
|
11133
11299
|
parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error: Invariant failed: Action parameter ordering for create-or-modify-sample-object does not match expected parameters. Extraneous parameters in ordering: {foo,id}, Missing parameters in ordering: {name}]`);defineCreateObjectAction({objectType:sampleObject,parameterOrdering:["foo","name","id"],parameterConfiguration:{"name":{conditionalOverrides:[{type:"visibility",condition:{type:"parameter",parameterId:"foo",matches:{type:"staticValue",staticValue:{type:"string",string:"foo"}}}}]}}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
11134
11300
|
{
|
|
11135
|
-
"
|
|
11301
|
+
"importedOntology": {
|
|
11302
|
+
"actionTypes": {},
|
|
11303
|
+
"blockPermissionInformation": {
|
|
11304
|
+
"actionTypes": {},
|
|
11305
|
+
"linkTypes": {},
|
|
11306
|
+
"objectTypes": {},
|
|
11307
|
+
},
|
|
11308
|
+
"interfaceTypes": {},
|
|
11309
|
+
"linkTypes": {},
|
|
11310
|
+
"objectTypes": {},
|
|
11311
|
+
"sharedPropertyTypes": {},
|
|
11312
|
+
},
|
|
11313
|
+
"importedValueTypes": {
|
|
11314
|
+
"valueTypes": [],
|
|
11315
|
+
},
|
|
11316
|
+
"ontology": {
|
|
11136
11317
|
"actionTypes": {
|
|
11137
11318
|
"com.palantir.create-object-sample-object": {
|
|
11138
11319
|
"actionType": {
|
|
@@ -11581,17 +11762,56 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11581
11762
|
},
|
|
11582
11763
|
"sharedPropertyTypes": {},
|
|
11583
11764
|
},
|
|
11584
|
-
"
|
|
11585
|
-
"
|
|
11586
|
-
"interfaceTypes": [],
|
|
11587
|
-
"linkTypes": [],
|
|
11588
|
-
"objectTypes": [],
|
|
11589
|
-
"sharedPropertyTypes": [],
|
|
11765
|
+
"valueTypes": {
|
|
11766
|
+
"valueTypes": [],
|
|
11590
11767
|
},
|
|
11591
11768
|
}
|
|
11592
11769
|
`);});});describe("Imports",()=>{it("Legacy importing works",()=>{const id=importSharedPropertyType({apiName:"id",packageName:"com.palantir.core.ontology.types",typeHint:"string"});defineInterface({apiName:"myInterface",properties:{id}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
11593
11770
|
{
|
|
11594
|
-
"
|
|
11771
|
+
"importedOntology": {
|
|
11772
|
+
"actionTypes": {},
|
|
11773
|
+
"blockPermissionInformation": {
|
|
11774
|
+
"actionTypes": {},
|
|
11775
|
+
"linkTypes": {},
|
|
11776
|
+
"objectTypes": {},
|
|
11777
|
+
},
|
|
11778
|
+
"interfaceTypes": {},
|
|
11779
|
+
"linkTypes": {},
|
|
11780
|
+
"objectTypes": {},
|
|
11781
|
+
"sharedPropertyTypes": {
|
|
11782
|
+
"com.palantir.core.ontology.types.id": {
|
|
11783
|
+
"sharedPropertyType": {
|
|
11784
|
+
"aliases": [],
|
|
11785
|
+
"apiName": "com.palantir.core.ontology.types.id",
|
|
11786
|
+
"baseFormatter": undefined,
|
|
11787
|
+
"dataConstraints": undefined,
|
|
11788
|
+
"displayMetadata": {
|
|
11789
|
+
"description": undefined,
|
|
11790
|
+
"displayName": "com.palantir.core.ontology.types.id",
|
|
11791
|
+
"visibility": "NORMAL",
|
|
11792
|
+
},
|
|
11793
|
+
"gothamMapping": undefined,
|
|
11794
|
+
"indexedForSearch": true,
|
|
11795
|
+
"type": {
|
|
11796
|
+
"string": {
|
|
11797
|
+
"analyzerOverride": undefined,
|
|
11798
|
+
"enableAsciiFolding": undefined,
|
|
11799
|
+
"isLongText": false,
|
|
11800
|
+
"supportsEfficientLeadingWildcard": false,
|
|
11801
|
+
"supportsExactMatching": true,
|
|
11802
|
+
},
|
|
11803
|
+
"type": "string",
|
|
11804
|
+
},
|
|
11805
|
+
"typeClasses": [],
|
|
11806
|
+
"valueType": undefined,
|
|
11807
|
+
},
|
|
11808
|
+
},
|
|
11809
|
+
},
|
|
11810
|
+
},
|
|
11811
|
+
"importedValueTypes": {
|
|
11812
|
+
"valueTypes": [],
|
|
11813
|
+
},
|
|
11814
|
+
"ontology": {
|
|
11595
11815
|
"actionTypes": {},
|
|
11596
11816
|
"blockPermissionInformation": {
|
|
11597
11817
|
"actionTypes": {},
|
|
@@ -11605,7 +11825,6 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11605
11825
|
"displayMetadata": {
|
|
11606
11826
|
"description": "myInterface",
|
|
11607
11827
|
"displayName": "myInterface",
|
|
11608
|
-
"icon": undefined,
|
|
11609
11828
|
},
|
|
11610
11829
|
"extendsInterfaces": [],
|
|
11611
11830
|
"links": [],
|
|
@@ -11653,35 +11872,57 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11653
11872
|
"objectTypes": {},
|
|
11654
11873
|
"sharedPropertyTypes": {},
|
|
11655
11874
|
},
|
|
11656
|
-
"
|
|
11657
|
-
"
|
|
11658
|
-
"interfaceTypes": [],
|
|
11659
|
-
"linkTypes": [],
|
|
11660
|
-
"objectTypes": [],
|
|
11661
|
-
"sharedPropertyTypes": [
|
|
11662
|
-
{
|
|
11663
|
-
"apiName": "com.palantir.core.ontology.types.id",
|
|
11664
|
-
"description": undefined,
|
|
11665
|
-
"displayName": "com.palantir.core.ontology.types.id",
|
|
11666
|
-
"type": {
|
|
11667
|
-
"string": {
|
|
11668
|
-
"analyzerOverride": undefined,
|
|
11669
|
-
"enableAsciiFolding": undefined,
|
|
11670
|
-
"isLongText": false,
|
|
11671
|
-
"supportsEfficientLeadingWildcard": false,
|
|
11672
|
-
"supportsExactMatching": true,
|
|
11673
|
-
},
|
|
11674
|
-
"type": "string",
|
|
11675
|
-
},
|
|
11676
|
-
"valueType": undefined,
|
|
11677
|
-
},
|
|
11678
|
-
],
|
|
11875
|
+
"valueTypes": {
|
|
11876
|
+
"valueTypes": [],
|
|
11679
11877
|
},
|
|
11680
11878
|
}
|
|
11681
11879
|
`);});it("Simple importing works",()=>{// does the same as "import { spt } from '@other/package'"
|
|
11682
11880
|
const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"string",__type:OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE};importOntologyEntity(spt);defineInterface({apiName:"myInterface",properties:{spt}});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
11683
11881
|
{
|
|
11684
|
-
"
|
|
11882
|
+
"importedOntology": {
|
|
11883
|
+
"actionTypes": {},
|
|
11884
|
+
"blockPermissionInformation": {
|
|
11885
|
+
"actionTypes": {},
|
|
11886
|
+
"linkTypes": {},
|
|
11887
|
+
"objectTypes": {},
|
|
11888
|
+
},
|
|
11889
|
+
"interfaceTypes": {},
|
|
11890
|
+
"linkTypes": {},
|
|
11891
|
+
"objectTypes": {},
|
|
11892
|
+
"sharedPropertyTypes": {
|
|
11893
|
+
"com.other.package.spt": {
|
|
11894
|
+
"sharedPropertyType": {
|
|
11895
|
+
"aliases": [],
|
|
11896
|
+
"apiName": "com.other.package.spt",
|
|
11897
|
+
"baseFormatter": undefined,
|
|
11898
|
+
"dataConstraints": undefined,
|
|
11899
|
+
"displayMetadata": {
|
|
11900
|
+
"description": undefined,
|
|
11901
|
+
"displayName": "com.other.package.spt",
|
|
11902
|
+
"visibility": "NORMAL",
|
|
11903
|
+
},
|
|
11904
|
+
"gothamMapping": undefined,
|
|
11905
|
+
"indexedForSearch": true,
|
|
11906
|
+
"type": {
|
|
11907
|
+
"string": {
|
|
11908
|
+
"analyzerOverride": undefined,
|
|
11909
|
+
"enableAsciiFolding": undefined,
|
|
11910
|
+
"isLongText": false,
|
|
11911
|
+
"supportsEfficientLeadingWildcard": false,
|
|
11912
|
+
"supportsExactMatching": true,
|
|
11913
|
+
},
|
|
11914
|
+
"type": "string",
|
|
11915
|
+
},
|
|
11916
|
+
"typeClasses": [],
|
|
11917
|
+
"valueType": undefined,
|
|
11918
|
+
},
|
|
11919
|
+
},
|
|
11920
|
+
},
|
|
11921
|
+
},
|
|
11922
|
+
"importedValueTypes": {
|
|
11923
|
+
"valueTypes": [],
|
|
11924
|
+
},
|
|
11925
|
+
"ontology": {
|
|
11685
11926
|
"actionTypes": {},
|
|
11686
11927
|
"blockPermissionInformation": {
|
|
11687
11928
|
"actionTypes": {},
|
|
@@ -11695,7 +11936,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11695
11936
|
"displayMetadata": {
|
|
11696
11937
|
"description": "myInterface",
|
|
11697
11938
|
"displayName": "myInterface",
|
|
11698
|
-
"icon": undefined,
|
|
11699
11939
|
},
|
|
11700
11940
|
"extendsInterfaces": [],
|
|
11701
11941
|
"links": [],
|
|
@@ -11743,29 +11983,8 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11743
11983
|
"objectTypes": {},
|
|
11744
11984
|
"sharedPropertyTypes": {},
|
|
11745
11985
|
},
|
|
11746
|
-
"
|
|
11747
|
-
"
|
|
11748
|
-
"interfaceTypes": [],
|
|
11749
|
-
"linkTypes": [],
|
|
11750
|
-
"objectTypes": [],
|
|
11751
|
-
"sharedPropertyTypes": [
|
|
11752
|
-
{
|
|
11753
|
-
"apiName": "com.other.package.spt",
|
|
11754
|
-
"description": undefined,
|
|
11755
|
-
"displayName": "com.other.package.spt",
|
|
11756
|
-
"type": {
|
|
11757
|
-
"string": {
|
|
11758
|
-
"analyzerOverride": undefined,
|
|
11759
|
-
"enableAsciiFolding": undefined,
|
|
11760
|
-
"isLongText": false,
|
|
11761
|
-
"supportsEfficientLeadingWildcard": false,
|
|
11762
|
-
"supportsExactMatching": true,
|
|
11763
|
-
},
|
|
11764
|
-
"type": "string",
|
|
11765
|
-
},
|
|
11766
|
-
"valueType": undefined,
|
|
11767
|
-
},
|
|
11768
|
-
],
|
|
11986
|
+
"valueTypes": {
|
|
11987
|
+
"valueTypes": [],
|
|
11769
11988
|
},
|
|
11770
11989
|
}
|
|
11771
11990
|
`);});it("Export files are generated correctly",async()=>{const generatedDir=path.resolve(path.join(__dirname,"..","generatedNoCheck","export_files_are_generated_correctly"));await defineOntology("com.my.package.",()=>{const mySpt=defineSharedPropertyType({apiName:"mySpt",type:"string"});const myInterface=defineInterface({apiName:"myInterface",properties:{mySpt}});defineObject({titlePropertyApiName:"bar",displayName:"My Object",pluralDisplayName:"myObjects",apiName:"myObject",primaryKeyPropertyApiName:"bar",properties:{"bar":{type:"string"}},implementsInterfaces:[{implements:myInterface,propertyMapping:[{interfaceProperty:"com.my.package.mySpt",mapsTo:"bar"}]}]});},generatedDir);expect(fs.readFileSync(path.join(generatedDir,"codegen/interface-types/myInterface.ts"),"utf8")).toMatchInlineSnapshot(`
|
|
@@ -11995,7 +12214,22 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11995
12214
|
"
|
|
11996
12215
|
`);fs.rmSync(path.join(generatedDir,".."),{recursive:true,force:true});});it("Extended interface properties are checked in object type property mapping",()=>{const parentInterface=defineInterface({apiName:"parentInterface",properties:{iProperty1:"string"}});const childInterface=defineInterface({apiName:"childInterface",properties:{iProperty2:"string"},extends:[parentInterface]});defineObject({apiName:"objectDef",primaryKeyPropertyApiName:"property1",titlePropertyApiName:"property1",displayName:"objectDef",pluralDisplayName:"objectDefs",properties:{"property1":{type:"string",displayName:"property1"},"property2":{type:"string",displayName:"property2"}},implementsInterfaces:[{implements:childInterface,propertyMapping:[{interfaceProperty:"com.palantir.iProperty1",mapsTo:"property1"},{interfaceProperty:"com.palantir.iProperty2",mapsTo:"property2"}]}]});expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
11997
12216
|
{
|
|
11998
|
-
"
|
|
12217
|
+
"importedOntology": {
|
|
12218
|
+
"actionTypes": {},
|
|
12219
|
+
"blockPermissionInformation": {
|
|
12220
|
+
"actionTypes": {},
|
|
12221
|
+
"linkTypes": {},
|
|
12222
|
+
"objectTypes": {},
|
|
12223
|
+
},
|
|
12224
|
+
"interfaceTypes": {},
|
|
12225
|
+
"linkTypes": {},
|
|
12226
|
+
"objectTypes": {},
|
|
12227
|
+
"sharedPropertyTypes": {},
|
|
12228
|
+
},
|
|
12229
|
+
"importedValueTypes": {
|
|
12230
|
+
"valueTypes": [],
|
|
12231
|
+
},
|
|
12232
|
+
"ontology": {
|
|
11999
12233
|
"actionTypes": {},
|
|
12000
12234
|
"blockPermissionInformation": {
|
|
12001
12235
|
"actionTypes": {},
|
|
@@ -12009,7 +12243,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12009
12243
|
"displayMetadata": {
|
|
12010
12244
|
"description": "childInterface",
|
|
12011
12245
|
"displayName": "childInterface",
|
|
12012
|
-
"icon": undefined,
|
|
12013
12246
|
},
|
|
12014
12247
|
"extendsInterfaces": [
|
|
12015
12248
|
"com.palantir.parentInterface",
|
|
@@ -12069,7 +12302,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12069
12302
|
"displayMetadata": {
|
|
12070
12303
|
"description": "parentInterface",
|
|
12071
12304
|
"displayName": "parentInterface",
|
|
12072
|
-
"icon": undefined,
|
|
12073
12305
|
},
|
|
12074
12306
|
"extendsInterfaces": [],
|
|
12075
12307
|
"links": [],
|
|
@@ -12354,12 +12586,8 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12354
12586
|
},
|
|
12355
12587
|
},
|
|
12356
12588
|
},
|
|
12357
|
-
"
|
|
12358
|
-
"
|
|
12359
|
-
"interfaceTypes": [],
|
|
12360
|
-
"linkTypes": [],
|
|
12361
|
-
"objectTypes": [],
|
|
12362
|
-
"sharedPropertyTypes": [],
|
|
12589
|
+
"valueTypes": {
|
|
12590
|
+
"valueTypes": [],
|
|
12363
12591
|
},
|
|
12364
12592
|
}
|
|
12365
12593
|
`);});});describe("Dependencies",()=>{it("Correctly adds dependencies",async()=>{const generatedDir=path.resolve(path.join(__dirname,"..","generatedNoCheck","correctly_adds_dependencies"));await defineOntology("com.palantir.",()=>{addDependency("com.palantir",fileURLToPath(import.meta.url));defineInterface({apiName:"myInterface",properties:{property1:"string"}});},generatedDir,path.join(generatedDir,"dependencies.json"));const packageJson=JSON.parse(fs.readFileSync(path.join(__dirname,"..","..","package.json"),"utf8"));expect(packageJson.version).toBeDefined();expect(fs.readFileSync(path.join(generatedDir,"dependencies.json"),"utf8")).toMatchInlineSnapshot(`
|