@osdk/maker 0.11.0-beta.2 → 0.11.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/browser/api/defineImportSpt.js +3 -1
- package/build/browser/api/defineImportSpt.js.map +1 -1
- package/build/browser/api/overall.test.js +105 -0
- package/build/browser/api/overall.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/cjs/index.cjs +4 -2
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +1 -0
- package/build/esm/api/defineImportSpt.js +3 -1
- package/build/esm/api/defineImportSpt.js.map +1 -1
- package/build/esm/api/overall.test.js +105 -0
- package/build/esm/api/overall.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/types/api/defineImportSpt.d.ts +1 -0
- package/build/types/api/defineImportSpt.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -25,7 +25,8 @@ export function importSharedPropertyType(opts) {
|
|
|
25
25
|
const {
|
|
26
26
|
apiName,
|
|
27
27
|
packageName,
|
|
28
|
-
typeHint
|
|
28
|
+
typeHint,
|
|
29
|
+
array
|
|
29
30
|
} = opts;
|
|
30
31
|
const fullApiName = packageName === undefined ? apiName : `${packageName}.${apiName}`;
|
|
31
32
|
if (packageName !== undefined) {
|
|
@@ -36,6 +37,7 @@ export function importSharedPropertyType(opts) {
|
|
|
36
37
|
apiName: fullApiName,
|
|
37
38
|
type: typeHint,
|
|
38
39
|
nonNameSpacedApiName: apiName,
|
|
40
|
+
array: array ?? false,
|
|
39
41
|
__type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE
|
|
40
42
|
};
|
|
41
43
|
importOntologyEntity(spt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineImportSpt.js","names":["invariant","importOntologyEntity","OntologyEntityTypeEnum","importSharedPropertyType","opts","apiName","packageName","typeHint","fullApiName","undefined","endsWith","process","env","NODE_ENV","match","spt","type","nonNameSpacedApiName","__type","SHARED_PROPERTY_TYPE"],"sources":["defineImportSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { importOntologyEntity } from \"./importOntologyEntity.js\";\nimport {\n OntologyEntityTypeEnum,\n type PropertyTypeType,\n type SharedPropertyType,\n} from \"./types.js\";\n\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(\n opts: {\n apiName: string;\n packageName?: string;\n typeHint: PropertyTypeType;\n },\n): SharedPropertyType {\n const { apiName, packageName, typeHint } = opts;\n const fullApiName = packageName === undefined\n ? apiName\n : `${packageName}.${apiName}`;\n if (packageName !== undefined) {\n invariant(\n !packageName.endsWith(\".\"),\n \"Package name format invalid ends with period\",\n );\n\n invariant(\n packageName.match(\"[A-Z]\") == null,\n \"Package name includes upper case characters\",\n );\n }\n const spt: SharedPropertyType = {\n apiName: fullApiName,\n type: typeHint,\n nonNameSpacedApiName: apiName,\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n importOntologyEntity(spt);\n return spt;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SACEC,sBAAsB,QAGjB,YAAY;;AAEnB;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,
|
|
1
|
+
{"version":3,"file":"defineImportSpt.js","names":["invariant","importOntologyEntity","OntologyEntityTypeEnum","importSharedPropertyType","opts","apiName","packageName","typeHint","array","fullApiName","undefined","endsWith","process","env","NODE_ENV","match","spt","type","nonNameSpacedApiName","__type","SHARED_PROPERTY_TYPE"],"sources":["defineImportSpt.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport invariant from \"tiny-invariant\";\nimport { importOntologyEntity } from \"./importOntologyEntity.js\";\nimport {\n OntologyEntityTypeEnum,\n type PropertyTypeType,\n type SharedPropertyType,\n} from \"./types.js\";\n\n/**\n * Defines a foreign shared property type you want to take as an input to your product. The typeHint field is used for OSDK generation\n */\nexport function importSharedPropertyType(\n opts: {\n apiName: string;\n packageName?: string;\n typeHint: PropertyTypeType;\n array?: boolean;\n },\n): SharedPropertyType {\n const { apiName, packageName, typeHint, array } = opts;\n const fullApiName = packageName === undefined\n ? apiName\n : `${packageName}.${apiName}`;\n if (packageName !== undefined) {\n invariant(\n !packageName.endsWith(\".\"),\n \"Package name format invalid ends with period\",\n );\n\n invariant(\n packageName.match(\"[A-Z]\") == null,\n \"Package name includes upper case characters\",\n );\n }\n const spt: SharedPropertyType = {\n apiName: fullApiName,\n type: typeHint,\n nonNameSpacedApiName: apiName,\n array: array ?? false,\n __type: OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE,\n };\n importOntologyEntity(spt);\n return spt;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SACEC,sBAAsB,QAGjB,YAAY;;AAEnB;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,IAKC,EACmB;EACpB,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAM,CAAC,GAAGJ,IAAI;EACtD,MAAMK,WAAW,GAAGH,WAAW,KAAKI,SAAS,GACzCL,OAAO,GACP,GAAGC,WAAW,IAAID,OAAO,EAAE;EAC/B,IAAIC,WAAW,KAAKI,SAAS,EAAE;IAC7B,CACE,CAACJ,WAAW,CAACK,QAAQ,CAAC,GAAG,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD5Bd,SAAS,QAEP,8CAA8C,IAFhDA,SAAS;IAKT,EACEM,WAAW,CAACS,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADpCd,SAAS,QAEP,6CAA6C,IAF/CA,SAAS;EAIX;EACA,MAAMgB,GAAuB,GAAG;IAC9BX,OAAO,EAAEI,WAAW;IACpBQ,IAAI,EAAEV,QAAQ;IACdW,oBAAoB,EAAEb,OAAO;IAC7BG,KAAK,EAAEA,KAAK,IAAI,KAAK;IACrBW,MAAM,EAAEjB,sBAAsB,CAACkB;EACjC,CAAC;EACDnB,oBAAoB,CAACe,GAAG,CAAC;EACzB,OAAOA,GAAG;AACZ","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ import * as fs from "fs";
|
|
|
18
18
|
import path from "path";
|
|
19
19
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
20
20
|
import { defineAction, defineCreateInterfaceObjectAction, defineCreateObjectAction, defineDeleteObjectAction, defineModifyInterfaceObjectAction, defineModifyObjectAction } from "./defineAction.js";
|
|
21
|
+
import { importSharedPropertyType } from "./defineImportSpt.js";
|
|
21
22
|
import { defineInterface } from "./defineInterface.js";
|
|
22
23
|
import { defineInterfaceLinkConstraint } from "./defineInterfaceLinkConstraint.js";
|
|
23
24
|
import { defineLink } from "./defineLink.js";
|
|
@@ -5133,6 +5134,110 @@ describe("Ontology Defining", () => {
|
|
|
5133
5134
|
});
|
|
5134
5135
|
});
|
|
5135
5136
|
describe("Imports", () => {
|
|
5137
|
+
it("Legacy importing works", () => {
|
|
5138
|
+
const id = importSharedPropertyType({
|
|
5139
|
+
apiName: "id",
|
|
5140
|
+
packageName: "com.palantir.core.ontology.types",
|
|
5141
|
+
typeHint: "string"
|
|
5142
|
+
});
|
|
5143
|
+
defineInterface({
|
|
5144
|
+
apiName: "myInterface",
|
|
5145
|
+
properties: {
|
|
5146
|
+
id
|
|
5147
|
+
}
|
|
5148
|
+
});
|
|
5149
|
+
expect(dumpOntologyFullMetadata()).toMatchInlineSnapshot(`
|
|
5150
|
+
{
|
|
5151
|
+
"blockData": {
|
|
5152
|
+
"actionTypes": {},
|
|
5153
|
+
"blockPermissionInformation": {
|
|
5154
|
+
"actionTypes": {},
|
|
5155
|
+
"linkTypes": {},
|
|
5156
|
+
"objectTypes": {},
|
|
5157
|
+
},
|
|
5158
|
+
"interfaceTypes": {
|
|
5159
|
+
"com.palantir.myInterface": {
|
|
5160
|
+
"interfaceType": {
|
|
5161
|
+
"allExtendsInterfaces": [],
|
|
5162
|
+
"allLinks": [],
|
|
5163
|
+
"allProperties": [],
|
|
5164
|
+
"allPropertiesV2": {},
|
|
5165
|
+
"apiName": "com.palantir.myInterface",
|
|
5166
|
+
"displayMetadata": {
|
|
5167
|
+
"description": "myInterface",
|
|
5168
|
+
"displayName": "myInterface",
|
|
5169
|
+
"icon": undefined,
|
|
5170
|
+
},
|
|
5171
|
+
"extendsInterfaces": [],
|
|
5172
|
+
"links": [],
|
|
5173
|
+
"properties": [],
|
|
5174
|
+
"propertiesV2": {
|
|
5175
|
+
"com.palantir.core.ontology.types.id": {
|
|
5176
|
+
"required": true,
|
|
5177
|
+
"sharedPropertyType": {
|
|
5178
|
+
"aliases": [],
|
|
5179
|
+
"apiName": "com.palantir.core.ontology.types.id",
|
|
5180
|
+
"baseFormatter": undefined,
|
|
5181
|
+
"dataConstraints": undefined,
|
|
5182
|
+
"displayMetadata": {
|
|
5183
|
+
"description": undefined,
|
|
5184
|
+
"displayName": "com.palantir.core.ontology.types.id",
|
|
5185
|
+
"visibility": "NORMAL",
|
|
5186
|
+
},
|
|
5187
|
+
"gothamMapping": undefined,
|
|
5188
|
+
"indexedForSearch": true,
|
|
5189
|
+
"type": {
|
|
5190
|
+
"string": {
|
|
5191
|
+
"analyzerOverride": undefined,
|
|
5192
|
+
"enableAsciiFolding": undefined,
|
|
5193
|
+
"isLongText": false,
|
|
5194
|
+
"supportsEfficientLeadingWildcard": false,
|
|
5195
|
+
"supportsExactMatching": true,
|
|
5196
|
+
},
|
|
5197
|
+
"type": "string",
|
|
5198
|
+
},
|
|
5199
|
+
"typeClasses": [],
|
|
5200
|
+
"valueType": undefined,
|
|
5201
|
+
},
|
|
5202
|
+
},
|
|
5203
|
+
},
|
|
5204
|
+
"status": {
|
|
5205
|
+
"active": {},
|
|
5206
|
+
"type": "active",
|
|
5207
|
+
},
|
|
5208
|
+
},
|
|
5209
|
+
},
|
|
5210
|
+
},
|
|
5211
|
+
"linkTypes": {},
|
|
5212
|
+
"objectTypes": {},
|
|
5213
|
+
"sharedPropertyTypes": {},
|
|
5214
|
+
},
|
|
5215
|
+
"importedTypes": {
|
|
5216
|
+
"actionTypes": [],
|
|
5217
|
+
"interfaceTypes": [],
|
|
5218
|
+
"linkTypes": [],
|
|
5219
|
+
"objectTypes": [],
|
|
5220
|
+
"sharedPropertyTypes": [
|
|
5221
|
+
{
|
|
5222
|
+
"apiName": "com.palantir.core.ontology.types.id",
|
|
5223
|
+
"description": undefined,
|
|
5224
|
+
"displayName": "com.palantir.core.ontology.types.id",
|
|
5225
|
+
"type": {
|
|
5226
|
+
"string": {
|
|
5227
|
+
"analyzerOverride": undefined,
|
|
5228
|
+
"enableAsciiFolding": undefined,
|
|
5229
|
+
"isLongText": false,
|
|
5230
|
+
"supportsEfficientLeadingWildcard": false,
|
|
5231
|
+
"supportsExactMatching": true,
|
|
5232
|
+
},
|
|
5233
|
+
"type": "string",
|
|
5234
|
+
},
|
|
5235
|
+
},
|
|
5236
|
+
],
|
|
5237
|
+
},
|
|
5238
|
+
}
|
|
5239
|
+
`);
|
|
5240
|
+
});
|
|
5136
5241
|
it("Simple importing works", () => {
|
|
5137
5242
|
// does the same as "import { spt } from '@other/package'"
|
|
5138
5243
|
const spt = {
|