@osdk/maker 0.13.0-beta.4 → 0.13.0-beta.6
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 +21 -0
- package/build/browser/api/defineAction.js +15 -13
- package/build/browser/api/defineAction.js.map +1 -1
- 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 +607 -271
- 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 +64 -129
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +8 -10
- package/build/esm/api/defineAction.js +15 -13
- package/build/esm/api/defineAction.js.map +1 -1
- 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 +607 -271
- 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/defineAction.d.ts.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 +6 -14
- package/build/types/api/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -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
|
-
`);});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(`
|
|
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"}},{condition:{type:"group",name:"actionLevelGroup2"},displayMetadata:{failureMessage:"Different custom failure message",typeClasses:[]}}],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"}},{condition:{type:"group",name:"actionLevelGroup2"},displayMetadata:{failureMessage:"Different custom failure message",typeClasses:[]}}],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"}},{condition:{type:"group",name:"actionLevelGroup2"},displayMetadata:{failureMessage:"Different custom failure message",typeClasses:[]}}],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": {
|
|
@@ -5740,6 +5823,42 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
5740
5823
|
"typeClasses": [],
|
|
5741
5824
|
},
|
|
5742
5825
|
},
|
|
5826
|
+
"1": {
|
|
5827
|
+
"condition": {
|
|
5828
|
+
"comparison": {
|
|
5829
|
+
"left": {
|
|
5830
|
+
"type": "userProperty",
|
|
5831
|
+
"userProperty": {
|
|
5832
|
+
"propertyValue": {
|
|
5833
|
+
"groupIds": {},
|
|
5834
|
+
"type": "groupIds",
|
|
5835
|
+
},
|
|
5836
|
+
"userId": {
|
|
5837
|
+
"currentUser": {},
|
|
5838
|
+
"type": "currentUser",
|
|
5839
|
+
},
|
|
5840
|
+
},
|
|
5841
|
+
},
|
|
5842
|
+
"operator": "INTERSECTS",
|
|
5843
|
+
"right": {
|
|
5844
|
+
"staticValue": {
|
|
5845
|
+
"stringList": {
|
|
5846
|
+
"strings": [
|
|
5847
|
+
"actionLevelGroup2",
|
|
5848
|
+
],
|
|
5849
|
+
},
|
|
5850
|
+
"type": "stringList",
|
|
5851
|
+
},
|
|
5852
|
+
"type": "staticValue",
|
|
5853
|
+
},
|
|
5854
|
+
},
|
|
5855
|
+
"type": "comparison",
|
|
5856
|
+
},
|
|
5857
|
+
"displayMetadata": {
|
|
5858
|
+
"failureMessage": "Different custom failure message",
|
|
5859
|
+
"typeClasses": [],
|
|
5860
|
+
},
|
|
5861
|
+
},
|
|
5743
5862
|
},
|
|
5744
5863
|
},
|
|
5745
5864
|
"parameterValidations": {
|
|
@@ -6067,6 +6186,42 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
6067
6186
|
"typeClasses": [],
|
|
6068
6187
|
},
|
|
6069
6188
|
},
|
|
6189
|
+
"1": {
|
|
6190
|
+
"condition": {
|
|
6191
|
+
"comparison": {
|
|
6192
|
+
"left": {
|
|
6193
|
+
"type": "userProperty",
|
|
6194
|
+
"userProperty": {
|
|
6195
|
+
"propertyValue": {
|
|
6196
|
+
"groupIds": {},
|
|
6197
|
+
"type": "groupIds",
|
|
6198
|
+
},
|
|
6199
|
+
"userId": {
|
|
6200
|
+
"currentUser": {},
|
|
6201
|
+
"type": "currentUser",
|
|
6202
|
+
},
|
|
6203
|
+
},
|
|
6204
|
+
},
|
|
6205
|
+
"operator": "INTERSECTS",
|
|
6206
|
+
"right": {
|
|
6207
|
+
"staticValue": {
|
|
6208
|
+
"stringList": {
|
|
6209
|
+
"strings": [
|
|
6210
|
+
"actionLevelGroup2",
|
|
6211
|
+
],
|
|
6212
|
+
},
|
|
6213
|
+
"type": "stringList",
|
|
6214
|
+
},
|
|
6215
|
+
"type": "staticValue",
|
|
6216
|
+
},
|
|
6217
|
+
},
|
|
6218
|
+
"type": "comparison",
|
|
6219
|
+
},
|
|
6220
|
+
"displayMetadata": {
|
|
6221
|
+
"failureMessage": "Different custom failure message",
|
|
6222
|
+
"typeClasses": [],
|
|
6223
|
+
},
|
|
6224
|
+
},
|
|
6070
6225
|
},
|
|
6071
6226
|
},
|
|
6072
6227
|
"parameterValidations": {
|
|
@@ -6407,6 +6562,42 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
6407
6562
|
"typeClasses": [],
|
|
6408
6563
|
},
|
|
6409
6564
|
},
|
|
6565
|
+
"1": {
|
|
6566
|
+
"condition": {
|
|
6567
|
+
"comparison": {
|
|
6568
|
+
"left": {
|
|
6569
|
+
"type": "userProperty",
|
|
6570
|
+
"userProperty": {
|
|
6571
|
+
"propertyValue": {
|
|
6572
|
+
"groupIds": {},
|
|
6573
|
+
"type": "groupIds",
|
|
6574
|
+
},
|
|
6575
|
+
"userId": {
|
|
6576
|
+
"currentUser": {},
|
|
6577
|
+
"type": "currentUser",
|
|
6578
|
+
},
|
|
6579
|
+
},
|
|
6580
|
+
},
|
|
6581
|
+
"operator": "INTERSECTS",
|
|
6582
|
+
"right": {
|
|
6583
|
+
"staticValue": {
|
|
6584
|
+
"stringList": {
|
|
6585
|
+
"strings": [
|
|
6586
|
+
"actionLevelGroup2",
|
|
6587
|
+
],
|
|
6588
|
+
},
|
|
6589
|
+
"type": "stringList",
|
|
6590
|
+
},
|
|
6591
|
+
"type": "staticValue",
|
|
6592
|
+
},
|
|
6593
|
+
},
|
|
6594
|
+
"type": "comparison",
|
|
6595
|
+
},
|
|
6596
|
+
"displayMetadata": {
|
|
6597
|
+
"failureMessage": "Different custom failure message",
|
|
6598
|
+
"typeClasses": [],
|
|
6599
|
+
},
|
|
6600
|
+
},
|
|
6410
6601
|
},
|
|
6411
6602
|
},
|
|
6412
6603
|
"parameterValidations": {
|
|
@@ -6942,17 +7133,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
6942
7133
|
},
|
|
6943
7134
|
"sharedPropertyTypes": {},
|
|
6944
7135
|
},
|
|
6945
|
-
"
|
|
6946
|
-
"
|
|
6947
|
-
"interfaceTypes": [],
|
|
6948
|
-
"linkTypes": [],
|
|
6949
|
-
"objectTypes": [],
|
|
6950
|
-
"sharedPropertyTypes": [],
|
|
7136
|
+
"valueTypes": {
|
|
7137
|
+
"valueTypes": [],
|
|
6951
7138
|
},
|
|
6952
7139
|
}
|
|
6953
7140
|
`);});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
7141
|
{
|
|
6955
|
-
"
|
|
7142
|
+
"importedOntology": {
|
|
7143
|
+
"actionTypes": {},
|
|
7144
|
+
"blockPermissionInformation": {
|
|
7145
|
+
"actionTypes": {},
|
|
7146
|
+
"linkTypes": {},
|
|
7147
|
+
"objectTypes": {},
|
|
7148
|
+
},
|
|
7149
|
+
"interfaceTypes": {},
|
|
7150
|
+
"linkTypes": {},
|
|
7151
|
+
"objectTypes": {},
|
|
7152
|
+
"sharedPropertyTypes": {},
|
|
7153
|
+
},
|
|
7154
|
+
"importedValueTypes": {
|
|
7155
|
+
"valueTypes": [],
|
|
7156
|
+
},
|
|
7157
|
+
"ontology": {
|
|
6956
7158
|
"actionTypes": {
|
|
6957
7159
|
"com.palantir.create-object-foo": {
|
|
6958
7160
|
"actionType": {
|
|
@@ -7558,17 +7760,28 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
7558
7760
|
},
|
|
7559
7761
|
"sharedPropertyTypes": {},
|
|
7560
7762
|
},
|
|
7561
|
-
"
|
|
7562
|
-
"
|
|
7563
|
-
"interfaceTypes": [],
|
|
7564
|
-
"linkTypes": [],
|
|
7565
|
-
"objectTypes": [],
|
|
7566
|
-
"sharedPropertyTypes": [],
|
|
7763
|
+
"valueTypes": {
|
|
7764
|
+
"valueTypes": [],
|
|
7567
7765
|
},
|
|
7568
7766
|
}
|
|
7569
7767
|
`);});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
7768
|
{
|
|
7571
|
-
"
|
|
7769
|
+
"importedOntology": {
|
|
7770
|
+
"actionTypes": {},
|
|
7771
|
+
"blockPermissionInformation": {
|
|
7772
|
+
"actionTypes": {},
|
|
7773
|
+
"linkTypes": {},
|
|
7774
|
+
"objectTypes": {},
|
|
7775
|
+
},
|
|
7776
|
+
"interfaceTypes": {},
|
|
7777
|
+
"linkTypes": {},
|
|
7778
|
+
"objectTypes": {},
|
|
7779
|
+
"sharedPropertyTypes": {},
|
|
7780
|
+
},
|
|
7781
|
+
"importedValueTypes": {
|
|
7782
|
+
"valueTypes": [],
|
|
7783
|
+
},
|
|
7784
|
+
"ontology": {
|
|
7572
7785
|
"actionTypes": {
|
|
7573
7786
|
"com.palantir.create-or-modify-employee": {
|
|
7574
7787
|
"actionType": {
|
|
@@ -8176,12 +8389,8 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
8176
8389
|
},
|
|
8177
8390
|
"sharedPropertyTypes": {},
|
|
8178
8391
|
},
|
|
8179
|
-
"
|
|
8180
|
-
"
|
|
8181
|
-
"interfaceTypes": [],
|
|
8182
|
-
"linkTypes": [],
|
|
8183
|
-
"objectTypes": [],
|
|
8184
|
-
"sharedPropertyTypes": [],
|
|
8392
|
+
"valueTypes": {
|
|
8393
|
+
"valueTypes": [],
|
|
8185
8394
|
},
|
|
8186
8395
|
}
|
|
8187
8396
|
`);});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 +8399,22 @@ defineOntology("com.palantir.",()=>{},"/tmp/");});describe("Interfaces",()=>{it(
|
|
|
8190
8399
|
// id of the selected manager object type.
|
|
8191
8400
|
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
8401
|
{
|
|
8193
|
-
"
|
|
8402
|
+
"importedOntology": {
|
|
8403
|
+
"actionTypes": {},
|
|
8404
|
+
"blockPermissionInformation": {
|
|
8405
|
+
"actionTypes": {},
|
|
8406
|
+
"linkTypes": {},
|
|
8407
|
+
"objectTypes": {},
|
|
8408
|
+
},
|
|
8409
|
+
"interfaceTypes": {},
|
|
8410
|
+
"linkTypes": {},
|
|
8411
|
+
"objectTypes": {},
|
|
8412
|
+
"sharedPropertyTypes": {},
|
|
8413
|
+
},
|
|
8414
|
+
"importedValueTypes": {
|
|
8415
|
+
"valueTypes": [],
|
|
8416
|
+
},
|
|
8417
|
+
"ontology": {
|
|
8194
8418
|
"actionTypes": {
|
|
8195
8419
|
"com.palantir.create-object-employee": {
|
|
8196
8420
|
"actionType": {
|
|
@@ -8665,17 +8889,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
8665
8889
|
},
|
|
8666
8890
|
"sharedPropertyTypes": {},
|
|
8667
8891
|
},
|
|
8668
|
-
"
|
|
8669
|
-
"
|
|
8670
|
-
"interfaceTypes": [],
|
|
8671
|
-
"linkTypes": [],
|
|
8672
|
-
"objectTypes": [],
|
|
8673
|
-
"sharedPropertyTypes": [],
|
|
8892
|
+
"valueTypes": {
|
|
8893
|
+
"valueTypes": [],
|
|
8674
8894
|
},
|
|
8675
8895
|
}
|
|
8676
8896
|
`);});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
8897
|
{
|
|
8678
|
-
"
|
|
8898
|
+
"importedOntology": {
|
|
8899
|
+
"actionTypes": {},
|
|
8900
|
+
"blockPermissionInformation": {
|
|
8901
|
+
"actionTypes": {},
|
|
8902
|
+
"linkTypes": {},
|
|
8903
|
+
"objectTypes": {},
|
|
8904
|
+
},
|
|
8905
|
+
"interfaceTypes": {},
|
|
8906
|
+
"linkTypes": {},
|
|
8907
|
+
"objectTypes": {},
|
|
8908
|
+
"sharedPropertyTypes": {},
|
|
8909
|
+
},
|
|
8910
|
+
"importedValueTypes": {
|
|
8911
|
+
"valueTypes": [],
|
|
8912
|
+
},
|
|
8913
|
+
"ontology": {
|
|
8679
8914
|
"actionTypes": {
|
|
8680
8915
|
"com.palantir.create-example-interface": {
|
|
8681
8916
|
"actionType": {
|
|
@@ -9041,7 +9276,6 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9041
9276
|
"displayMetadata": {
|
|
9042
9277
|
"description": "exampleInterface",
|
|
9043
9278
|
"displayName": "exampleInterface",
|
|
9044
|
-
"icon": undefined,
|
|
9045
9279
|
},
|
|
9046
9280
|
"extendsInterfaces": [],
|
|
9047
9281
|
"links": [],
|
|
@@ -9135,17 +9369,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9135
9369
|
},
|
|
9136
9370
|
},
|
|
9137
9371
|
},
|
|
9138
|
-
"
|
|
9139
|
-
"
|
|
9140
|
-
"interfaceTypes": [],
|
|
9141
|
-
"linkTypes": [],
|
|
9142
|
-
"objectTypes": [],
|
|
9143
|
-
"sharedPropertyTypes": [],
|
|
9372
|
+
"valueTypes": {
|
|
9373
|
+
"valueTypes": [],
|
|
9144
9374
|
},
|
|
9145
9375
|
}
|
|
9146
|
-
`);});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(`
|
|
9376
|
+
`);});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
9377
|
{
|
|
9148
|
-
"
|
|
9378
|
+
"importedOntology": {
|
|
9379
|
+
"actionTypes": {},
|
|
9380
|
+
"blockPermissionInformation": {
|
|
9381
|
+
"actionTypes": {},
|
|
9382
|
+
"linkTypes": {},
|
|
9383
|
+
"objectTypes": {},
|
|
9384
|
+
},
|
|
9385
|
+
"interfaceTypes": {},
|
|
9386
|
+
"linkTypes": {},
|
|
9387
|
+
"objectTypes": {},
|
|
9388
|
+
"sharedPropertyTypes": {},
|
|
9389
|
+
},
|
|
9390
|
+
"importedValueTypes": {
|
|
9391
|
+
"valueTypes": [],
|
|
9392
|
+
},
|
|
9393
|
+
"ontology": {
|
|
9149
9394
|
"actionTypes": {
|
|
9150
9395
|
"com.palantir.create-object-sample-object": {
|
|
9151
9396
|
"actionType": {
|
|
@@ -9508,17 +9753,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9508
9753
|
},
|
|
9509
9754
|
"sharedPropertyTypes": {},
|
|
9510
9755
|
},
|
|
9511
|
-
"
|
|
9512
|
-
"
|
|
9513
|
-
"interfaceTypes": [],
|
|
9514
|
-
"linkTypes": [],
|
|
9515
|
-
"objectTypes": [],
|
|
9516
|
-
"sharedPropertyTypes": [],
|
|
9756
|
+
"valueTypes": {
|
|
9757
|
+
"valueTypes": [],
|
|
9517
9758
|
},
|
|
9518
9759
|
}
|
|
9519
|
-
`);});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(`
|
|
9760
|
+
`);});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
9761
|
{
|
|
9521
|
-
"
|
|
9762
|
+
"importedOntology": {
|
|
9763
|
+
"actionTypes": {},
|
|
9764
|
+
"blockPermissionInformation": {
|
|
9765
|
+
"actionTypes": {},
|
|
9766
|
+
"linkTypes": {},
|
|
9767
|
+
"objectTypes": {},
|
|
9768
|
+
},
|
|
9769
|
+
"interfaceTypes": {},
|
|
9770
|
+
"linkTypes": {},
|
|
9771
|
+
"objectTypes": {},
|
|
9772
|
+
"sharedPropertyTypes": {},
|
|
9773
|
+
},
|
|
9774
|
+
"importedValueTypes": {
|
|
9775
|
+
"valueTypes": [],
|
|
9776
|
+
},
|
|
9777
|
+
"ontology": {
|
|
9522
9778
|
"actionTypes": {
|
|
9523
9779
|
"com.palantir.create-object-sample-object": {
|
|
9524
9780
|
"actionType": {
|
|
@@ -9881,17 +10137,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
9881
10137
|
},
|
|
9882
10138
|
"sharedPropertyTypes": {},
|
|
9883
10139
|
},
|
|
9884
|
-
"
|
|
9885
|
-
"
|
|
9886
|
-
"interfaceTypes": [],
|
|
9887
|
-
"linkTypes": [],
|
|
9888
|
-
"objectTypes": [],
|
|
9889
|
-
"sharedPropertyTypes": [],
|
|
10140
|
+
"valueTypes": {
|
|
10141
|
+
"valueTypes": [],
|
|
9890
10142
|
},
|
|
9891
10143
|
}
|
|
9892
10144
|
`);});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
10145
|
{
|
|
9894
|
-
"
|
|
10146
|
+
"importedOntology": {
|
|
10147
|
+
"actionTypes": {},
|
|
10148
|
+
"blockPermissionInformation": {
|
|
10149
|
+
"actionTypes": {},
|
|
10150
|
+
"linkTypes": {},
|
|
10151
|
+
"objectTypes": {},
|
|
10152
|
+
},
|
|
10153
|
+
"interfaceTypes": {},
|
|
10154
|
+
"linkTypes": {},
|
|
10155
|
+
"objectTypes": {},
|
|
10156
|
+
"sharedPropertyTypes": {},
|
|
10157
|
+
},
|
|
10158
|
+
"importedValueTypes": {
|
|
10159
|
+
"valueTypes": [],
|
|
10160
|
+
},
|
|
10161
|
+
"ontology": {
|
|
9895
10162
|
"actionTypes": {
|
|
9896
10163
|
"com.palantir.create-object-object-with-arrays": {
|
|
9897
10164
|
"actionType": {
|
|
@@ -10698,17 +10965,28 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
10698
10965
|
},
|
|
10699
10966
|
"sharedPropertyTypes": {},
|
|
10700
10967
|
},
|
|
10701
|
-
"
|
|
10702
|
-
"
|
|
10703
|
-
"interfaceTypes": [],
|
|
10704
|
-
"linkTypes": [],
|
|
10705
|
-
"objectTypes": [],
|
|
10706
|
-
"sharedPropertyTypes": [],
|
|
10968
|
+
"valueTypes": {
|
|
10969
|
+
"valueTypes": [],
|
|
10707
10970
|
},
|
|
10708
10971
|
}
|
|
10709
10972
|
`);});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
10973
|
{
|
|
10711
|
-
"
|
|
10974
|
+
"importedOntology": {
|
|
10975
|
+
"actionTypes": {},
|
|
10976
|
+
"blockPermissionInformation": {
|
|
10977
|
+
"actionTypes": {},
|
|
10978
|
+
"linkTypes": {},
|
|
10979
|
+
"objectTypes": {},
|
|
10980
|
+
},
|
|
10981
|
+
"interfaceTypes": {},
|
|
10982
|
+
"linkTypes": {},
|
|
10983
|
+
"objectTypes": {},
|
|
10984
|
+
"sharedPropertyTypes": {},
|
|
10985
|
+
},
|
|
10986
|
+
"importedValueTypes": {
|
|
10987
|
+
"valueTypes": [],
|
|
10988
|
+
},
|
|
10989
|
+
"ontology": {
|
|
10712
10990
|
"actionTypes": {
|
|
10713
10991
|
"com.palantir.create-object-sample-object": {
|
|
10714
10992
|
"actionType": {
|
|
@@ -11117,12 +11395,8 @@ const employeeObject=defineObject({apiName:"employee",displayName:"Employee",plu
|
|
|
11117
11395
|
},
|
|
11118
11396
|
"sharedPropertyTypes": {},
|
|
11119
11397
|
},
|
|
11120
|
-
"
|
|
11121
|
-
"
|
|
11122
|
-
"interfaceTypes": [],
|
|
11123
|
-
"linkTypes": [],
|
|
11124
|
-
"objectTypes": [],
|
|
11125
|
-
"sharedPropertyTypes": [],
|
|
11398
|
+
"valueTypes": {
|
|
11399
|
+
"valueTypes": [],
|
|
11126
11400
|
},
|
|
11127
11401
|
}
|
|
11128
11402
|
`);});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 +11406,22 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11132
11406
|
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
11407
|
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
11408
|
{
|
|
11135
|
-
"
|
|
11409
|
+
"importedOntology": {
|
|
11410
|
+
"actionTypes": {},
|
|
11411
|
+
"blockPermissionInformation": {
|
|
11412
|
+
"actionTypes": {},
|
|
11413
|
+
"linkTypes": {},
|
|
11414
|
+
"objectTypes": {},
|
|
11415
|
+
},
|
|
11416
|
+
"interfaceTypes": {},
|
|
11417
|
+
"linkTypes": {},
|
|
11418
|
+
"objectTypes": {},
|
|
11419
|
+
"sharedPropertyTypes": {},
|
|
11420
|
+
},
|
|
11421
|
+
"importedValueTypes": {
|
|
11422
|
+
"valueTypes": [],
|
|
11423
|
+
},
|
|
11424
|
+
"ontology": {
|
|
11136
11425
|
"actionTypes": {
|
|
11137
11426
|
"com.palantir.create-object-sample-object": {
|
|
11138
11427
|
"actionType": {
|
|
@@ -11581,17 +11870,56 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11581
11870
|
},
|
|
11582
11871
|
"sharedPropertyTypes": {},
|
|
11583
11872
|
},
|
|
11584
|
-
"
|
|
11585
|
-
"
|
|
11586
|
-
"interfaceTypes": [],
|
|
11587
|
-
"linkTypes": [],
|
|
11588
|
-
"objectTypes": [],
|
|
11589
|
-
"sharedPropertyTypes": [],
|
|
11873
|
+
"valueTypes": {
|
|
11874
|
+
"valueTypes": [],
|
|
11590
11875
|
},
|
|
11591
11876
|
}
|
|
11592
11877
|
`);});});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
11878
|
{
|
|
11594
|
-
"
|
|
11879
|
+
"importedOntology": {
|
|
11880
|
+
"actionTypes": {},
|
|
11881
|
+
"blockPermissionInformation": {
|
|
11882
|
+
"actionTypes": {},
|
|
11883
|
+
"linkTypes": {},
|
|
11884
|
+
"objectTypes": {},
|
|
11885
|
+
},
|
|
11886
|
+
"interfaceTypes": {},
|
|
11887
|
+
"linkTypes": {},
|
|
11888
|
+
"objectTypes": {},
|
|
11889
|
+
"sharedPropertyTypes": {
|
|
11890
|
+
"com.palantir.core.ontology.types.id": {
|
|
11891
|
+
"sharedPropertyType": {
|
|
11892
|
+
"aliases": [],
|
|
11893
|
+
"apiName": "com.palantir.core.ontology.types.id",
|
|
11894
|
+
"baseFormatter": undefined,
|
|
11895
|
+
"dataConstraints": undefined,
|
|
11896
|
+
"displayMetadata": {
|
|
11897
|
+
"description": undefined,
|
|
11898
|
+
"displayName": "com.palantir.core.ontology.types.id",
|
|
11899
|
+
"visibility": "NORMAL",
|
|
11900
|
+
},
|
|
11901
|
+
"gothamMapping": undefined,
|
|
11902
|
+
"indexedForSearch": true,
|
|
11903
|
+
"type": {
|
|
11904
|
+
"string": {
|
|
11905
|
+
"analyzerOverride": undefined,
|
|
11906
|
+
"enableAsciiFolding": undefined,
|
|
11907
|
+
"isLongText": false,
|
|
11908
|
+
"supportsEfficientLeadingWildcard": false,
|
|
11909
|
+
"supportsExactMatching": true,
|
|
11910
|
+
},
|
|
11911
|
+
"type": "string",
|
|
11912
|
+
},
|
|
11913
|
+
"typeClasses": [],
|
|
11914
|
+
"valueType": undefined,
|
|
11915
|
+
},
|
|
11916
|
+
},
|
|
11917
|
+
},
|
|
11918
|
+
},
|
|
11919
|
+
"importedValueTypes": {
|
|
11920
|
+
"valueTypes": [],
|
|
11921
|
+
},
|
|
11922
|
+
"ontology": {
|
|
11595
11923
|
"actionTypes": {},
|
|
11596
11924
|
"blockPermissionInformation": {
|
|
11597
11925
|
"actionTypes": {},
|
|
@@ -11605,7 +11933,6 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11605
11933
|
"displayMetadata": {
|
|
11606
11934
|
"description": "myInterface",
|
|
11607
11935
|
"displayName": "myInterface",
|
|
11608
|
-
"icon": undefined,
|
|
11609
11936
|
},
|
|
11610
11937
|
"extendsInterfaces": [],
|
|
11611
11938
|
"links": [],
|
|
@@ -11653,35 +11980,57 @@ parameterOrdering:["foo","id"]});}).toThrowErrorMatchingInlineSnapshot(`[Error:
|
|
|
11653
11980
|
"objectTypes": {},
|
|
11654
11981
|
"sharedPropertyTypes": {},
|
|
11655
11982
|
},
|
|
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
|
-
],
|
|
11983
|
+
"valueTypes": {
|
|
11984
|
+
"valueTypes": [],
|
|
11679
11985
|
},
|
|
11680
11986
|
}
|
|
11681
11987
|
`);});it("Simple importing works",()=>{// does the same as "import { spt } from '@other/package'"
|
|
11682
11988
|
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
11989
|
{
|
|
11684
|
-
"
|
|
11990
|
+
"importedOntology": {
|
|
11991
|
+
"actionTypes": {},
|
|
11992
|
+
"blockPermissionInformation": {
|
|
11993
|
+
"actionTypes": {},
|
|
11994
|
+
"linkTypes": {},
|
|
11995
|
+
"objectTypes": {},
|
|
11996
|
+
},
|
|
11997
|
+
"interfaceTypes": {},
|
|
11998
|
+
"linkTypes": {},
|
|
11999
|
+
"objectTypes": {},
|
|
12000
|
+
"sharedPropertyTypes": {
|
|
12001
|
+
"com.other.package.spt": {
|
|
12002
|
+
"sharedPropertyType": {
|
|
12003
|
+
"aliases": [],
|
|
12004
|
+
"apiName": "com.other.package.spt",
|
|
12005
|
+
"baseFormatter": undefined,
|
|
12006
|
+
"dataConstraints": undefined,
|
|
12007
|
+
"displayMetadata": {
|
|
12008
|
+
"description": undefined,
|
|
12009
|
+
"displayName": "com.other.package.spt",
|
|
12010
|
+
"visibility": "NORMAL",
|
|
12011
|
+
},
|
|
12012
|
+
"gothamMapping": undefined,
|
|
12013
|
+
"indexedForSearch": true,
|
|
12014
|
+
"type": {
|
|
12015
|
+
"string": {
|
|
12016
|
+
"analyzerOverride": undefined,
|
|
12017
|
+
"enableAsciiFolding": undefined,
|
|
12018
|
+
"isLongText": false,
|
|
12019
|
+
"supportsEfficientLeadingWildcard": false,
|
|
12020
|
+
"supportsExactMatching": true,
|
|
12021
|
+
},
|
|
12022
|
+
"type": "string",
|
|
12023
|
+
},
|
|
12024
|
+
"typeClasses": [],
|
|
12025
|
+
"valueType": undefined,
|
|
12026
|
+
},
|
|
12027
|
+
},
|
|
12028
|
+
},
|
|
12029
|
+
},
|
|
12030
|
+
"importedValueTypes": {
|
|
12031
|
+
"valueTypes": [],
|
|
12032
|
+
},
|
|
12033
|
+
"ontology": {
|
|
11685
12034
|
"actionTypes": {},
|
|
11686
12035
|
"blockPermissionInformation": {
|
|
11687
12036
|
"actionTypes": {},
|
|
@@ -11695,7 +12044,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11695
12044
|
"displayMetadata": {
|
|
11696
12045
|
"description": "myInterface",
|
|
11697
12046
|
"displayName": "myInterface",
|
|
11698
|
-
"icon": undefined,
|
|
11699
12047
|
},
|
|
11700
12048
|
"extendsInterfaces": [],
|
|
11701
12049
|
"links": [],
|
|
@@ -11743,29 +12091,8 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11743
12091
|
"objectTypes": {},
|
|
11744
12092
|
"sharedPropertyTypes": {},
|
|
11745
12093
|
},
|
|
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
|
-
],
|
|
12094
|
+
"valueTypes": {
|
|
12095
|
+
"valueTypes": [],
|
|
11769
12096
|
},
|
|
11770
12097
|
}
|
|
11771
12098
|
`);});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 +12322,22 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
11995
12322
|
"
|
|
11996
12323
|
`);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
12324
|
{
|
|
11998
|
-
"
|
|
12325
|
+
"importedOntology": {
|
|
12326
|
+
"actionTypes": {},
|
|
12327
|
+
"blockPermissionInformation": {
|
|
12328
|
+
"actionTypes": {},
|
|
12329
|
+
"linkTypes": {},
|
|
12330
|
+
"objectTypes": {},
|
|
12331
|
+
},
|
|
12332
|
+
"interfaceTypes": {},
|
|
12333
|
+
"linkTypes": {},
|
|
12334
|
+
"objectTypes": {},
|
|
12335
|
+
"sharedPropertyTypes": {},
|
|
12336
|
+
},
|
|
12337
|
+
"importedValueTypes": {
|
|
12338
|
+
"valueTypes": [],
|
|
12339
|
+
},
|
|
12340
|
+
"ontology": {
|
|
11999
12341
|
"actionTypes": {},
|
|
12000
12342
|
"blockPermissionInformation": {
|
|
12001
12343
|
"actionTypes": {},
|
|
@@ -12009,7 +12351,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12009
12351
|
"displayMetadata": {
|
|
12010
12352
|
"description": "childInterface",
|
|
12011
12353
|
"displayName": "childInterface",
|
|
12012
|
-
"icon": undefined,
|
|
12013
12354
|
},
|
|
12014
12355
|
"extendsInterfaces": [
|
|
12015
12356
|
"com.palantir.parentInterface",
|
|
@@ -12069,7 +12410,6 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12069
12410
|
"displayMetadata": {
|
|
12070
12411
|
"description": "parentInterface",
|
|
12071
12412
|
"displayName": "parentInterface",
|
|
12072
|
-
"icon": undefined,
|
|
12073
12413
|
},
|
|
12074
12414
|
"extendsInterfaces": [],
|
|
12075
12415
|
"links": [],
|
|
@@ -12354,12 +12694,8 @@ const spt={apiName:"com.other.package.spt",nonNameSpacedApiName:"spt",type:"stri
|
|
|
12354
12694
|
},
|
|
12355
12695
|
},
|
|
12356
12696
|
},
|
|
12357
|
-
"
|
|
12358
|
-
"
|
|
12359
|
-
"interfaceTypes": [],
|
|
12360
|
-
"linkTypes": [],
|
|
12361
|
-
"objectTypes": [],
|
|
12362
|
-
"sharedPropertyTypes": [],
|
|
12697
|
+
"valueTypes": {
|
|
12698
|
+
"valueTypes": [],
|
|
12363
12699
|
},
|
|
12364
12700
|
}
|
|
12365
12701
|
`);});});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(`
|