@osdk/client 2.3.0-beta.2 → 2.3.0-beta.4
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 +29 -0
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js +6 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/browser/createMediaReferenceProperty.js +7 -1
- package/build/browser/createMediaReferenceProperty.js.map +1 -1
- package/build/browser/derivedProperties/derivedPropertyRuntimeMetadata.js +2 -0
- package/build/browser/derivedProperties/derivedPropertyRuntimeMetadata.js.map +1 -0
- package/build/browser/intellisense.test.helpers/orderBySuggestionIsRight.js +30 -0
- package/build/browser/intellisense.test.helpers/orderBySuggestionIsRight.js.map +1 -0
- package/build/browser/intellisense.test.js +22 -0
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +57 -47
- package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js +27 -12
- package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +22 -9
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/media.test.js +20 -1
- package/build/browser/object/media.test.js.map +1 -1
- package/build/browser/object/object.test.js +6 -2
- package/build/browser/object/object.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +7 -0
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/tsserver.js +1 -0
- package/build/browser/tsserver.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/extractRdpDefinition.js +13 -2
- package/build/browser/util/extractRdpDefinition.js.map +1 -1
- package/build/browser/util/extractRdpDefinition.test.js +87 -5
- package/build/browser/util/extractRdpDefinition.test.js.map +1 -1
- package/build/cjs/{chunk-ZV5KKQ4R.cjs → chunk-C5D7744G.cjs} +15 -4
- package/build/cjs/chunk-C5D7744G.cjs.map +1 -0
- package/build/cjs/{chunk-JEHRAVC5.cjs → chunk-MZ4JZQUU.cjs} +14 -14
- package/build/cjs/{chunk-JEHRAVC5.cjs.map → chunk-MZ4JZQUU.cjs.map} +1 -1
- package/build/cjs/index.cjs +78 -56
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/internal.cjs +8 -8
- package/build/cjs/public/unstable-do-not-use.cjs +8 -8
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js +6 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/esm/createMediaReferenceProperty.js +7 -1
- package/build/esm/createMediaReferenceProperty.js.map +1 -1
- package/build/esm/derivedProperties/derivedPropertyRuntimeMetadata.js +2 -0
- package/build/esm/derivedProperties/derivedPropertyRuntimeMetadata.js.map +1 -0
- package/build/esm/intellisense.test.helpers/orderBySuggestionIsRight.js +30 -0
- package/build/esm/intellisense.test.helpers/orderBySuggestionIsRight.js.map +1 -0
- package/build/esm/intellisense.test.js +22 -0
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +57 -47
- package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js +27 -12
- package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.test.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +22 -9
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/media.test.js +20 -1
- package/build/esm/object/media.test.js.map +1 -1
- package/build/esm/object/object.test.js +6 -2
- package/build/esm/object/object.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +7 -0
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/tsserver.js +1 -0
- package/build/esm/tsserver.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/extractRdpDefinition.js +13 -2
- package/build/esm/util/extractRdpDefinition.js.map +1 -1
- package/build/esm/util/extractRdpDefinition.test.js +87 -5
- package/build/esm/util/extractRdpDefinition.test.js.map +1 -1
- package/build/types/createMediaReferenceProperty.d.ts +4 -1
- package/build/types/createMediaReferenceProperty.d.ts.map +1 -1
- package/build/types/derivedProperties/derivedPropertyRuntimeMetadata.d.ts +6 -0
- package/build/types/derivedProperties/derivedPropertyRuntimeMetadata.d.ts.map +1 -0
- package/build/types/intellisense.test.helpers/orderBySuggestionIsRight.d.ts +1 -0
- package/build/types/intellisense.test.helpers/orderBySuggestionIsRight.d.ts.map +1 -0
- package/build/types/object/convertWireToOsdkObjects.d.ts +5 -4
- package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/types/object/object.test.d.ts.map +1 -1
- package/build/types/tsserver.d.ts +1 -0
- package/build/types/tsserver.d.ts.map +1 -1
- package/build/types/util/extractRdpDefinition.d.ts +2 -2
- package/build/types/util/extractRdpDefinition.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/cjs/chunk-ZV5KKQ4R.cjs.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkMZ4JZQUU_cjs = require('../chunk-MZ4JZQUU.cjs');
|
|
4
|
+
var chunkC5D7744G_cjs = require('../chunk-C5D7744G.cjs');
|
|
5
5
|
|
|
6
6
|
// src/public-utils/createAndFetchTempObjectSetRid.ts
|
|
7
7
|
async function createAndFetchTempObjectSetRid(client, objectSet) {
|
|
8
|
-
const response = await
|
|
9
|
-
objectSet:
|
|
8
|
+
const response = await chunkC5D7744G_cjs.OntologyObjectSet_exports.createTemporary(client, await client[chunkC5D7744G_cjs.additionalContext].ontologyRid, {
|
|
9
|
+
objectSet: chunkMZ4JZQUU_cjs.getWireObjectSet(objectSet)
|
|
10
10
|
});
|
|
11
11
|
return response.objectSetRid;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// src/public-utils/hydrateObjectSetFromRid.ts
|
|
15
15
|
function hydrateObjectSetFromRid(client, definition, rid) {
|
|
16
|
-
return
|
|
16
|
+
return chunkMZ4JZQUU_cjs.createObjectSet(definition, client[chunkC5D7744G_cjs.additionalContext], {
|
|
17
17
|
type: "intersect",
|
|
18
18
|
objectSets: [{
|
|
19
19
|
type: "base",
|
|
@@ -51,7 +51,7 @@ var levelStyles = {
|
|
|
51
51
|
color: "orange"
|
|
52
52
|
})
|
|
53
53
|
};
|
|
54
|
-
var BrowserLogger = class _BrowserLogger extends
|
|
54
|
+
var BrowserLogger = class _BrowserLogger extends chunkMZ4JZQUU_cjs.BaseLogger {
|
|
55
55
|
constructor(bindings = {}, options = {}) {
|
|
56
56
|
super(bindings, {
|
|
57
57
|
...options,
|
|
@@ -77,11 +77,11 @@ var BrowserLogger = class _BrowserLogger extends chunkJEHRAVC5_cjs.BaseLogger {
|
|
|
77
77
|
|
|
78
78
|
Object.defineProperty(exports, "MinimalLogger", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkMZ4JZQUU_cjs.MinimalLogger; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "hydrateAttachmentFromRid", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkMZ4JZQUU_cjs.hydrateAttachmentFromRid; }
|
|
85
85
|
});
|
|
86
86
|
exports.BrowserLogger = BrowserLogger;
|
|
87
87
|
exports.createAndFetchTempObjectSetRid = createAndFetchTempObjectSetRid;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkT4NIFYZS_cjs = require('../chunk-T4NIFYZS.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkC5D7744G_cjs = require('../chunk-C5D7744G.cjs');
|
|
5
5
|
var rxjs = require('rxjs');
|
|
6
6
|
var invariant2 = require('tiny-invariant');
|
|
7
7
|
var mnemonist = require('mnemonist');
|
|
@@ -191,7 +191,7 @@ var OptimisticJob = class {
|
|
|
191
191
|
return this;
|
|
192
192
|
},
|
|
193
193
|
createObject(type, pk, properties) {
|
|
194
|
-
const create = store.client[
|
|
194
|
+
const create = store.client[chunkC5D7744G_cjs.additionalContext].objectFactory2(store.client[chunkC5D7744G_cjs.additionalContext], [{
|
|
195
195
|
$primaryKey: pk,
|
|
196
196
|
$apiName: type.apiName,
|
|
197
197
|
$objectType: type.apiName,
|
|
@@ -596,7 +596,7 @@ var BulkObjectLoader = class {
|
|
|
596
596
|
#maxEntries;
|
|
597
597
|
constructor(client, maxWait = 25, maxEntries = 100) {
|
|
598
598
|
this.#client = client;
|
|
599
|
-
this.#logger = client[
|
|
599
|
+
this.#logger = client[chunkC5D7744G_cjs.additionalContext].logger;
|
|
600
600
|
this.#maxWait = maxWait;
|
|
601
601
|
this.#maxEntries = maxEntries;
|
|
602
602
|
}
|
|
@@ -666,7 +666,7 @@ var Query = class {
|
|
|
666
666
|
this.cacheKey = cacheKey;
|
|
667
667
|
this.store = store;
|
|
668
668
|
this.#subject = observable;
|
|
669
|
-
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[
|
|
669
|
+
this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkC5D7744G_cjs.additionalContext].logger : store.client[chunkC5D7744G_cjs.additionalContext].logger?.child({}, {
|
|
670
670
|
msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
|
|
671
671
|
}));
|
|
672
672
|
}
|
|
@@ -773,7 +773,7 @@ var ObjectQuery = class extends Query {
|
|
|
773
773
|
#apiName;
|
|
774
774
|
#pk;
|
|
775
775
|
constructor(store, subject, type, pk, cacheKey, opts) {
|
|
776
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
776
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkC5D7744G_cjs.additionalContext].logger?.child({}, {
|
|
777
777
|
msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
778
778
|
}) : void 0);
|
|
779
779
|
this.#apiName = type;
|
|
@@ -934,7 +934,7 @@ var ListQuery = class extends BaseListQuery {
|
|
|
934
934
|
#objectSet;
|
|
935
935
|
#sortFns;
|
|
936
936
|
constructor(store, subject, apiType, apiName, whereClause, orderBy, cacheKey, opts) {
|
|
937
|
-
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[
|
|
937
|
+
super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkC5D7744G_cjs.additionalContext].logger?.child({}, {
|
|
938
938
|
msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
|
|
939
939
|
}) : void 0);
|
|
940
940
|
this.#type = apiType;
|
|
@@ -1563,7 +1563,7 @@ var Store = class {
|
|
|
1563
1563
|
#finalizationRegistry;
|
|
1564
1564
|
constructor(client) {
|
|
1565
1565
|
this.client = client;
|
|
1566
|
-
this.logger = client[
|
|
1566
|
+
this.logger = client[chunkC5D7744G_cjs.additionalContext].logger?.child({}, {
|
|
1567
1567
|
msgPrefix: "Store"
|
|
1568
1568
|
});
|
|
1569
1569
|
this.#topLayer = this.#truthLayer;
|
|
@@ -1893,7 +1893,7 @@ function getOsdkConfig(ontologyRid) {
|
|
|
1893
1893
|
|
|
1894
1894
|
Object.defineProperty(exports, "augment", {
|
|
1895
1895
|
enumerable: true,
|
|
1896
|
-
get: function () { return
|
|
1896
|
+
get: function () { return chunkC5D7744G_cjs.augment; }
|
|
1897
1897
|
});
|
|
1898
1898
|
exports.createObservableClient = createObservableClient;
|
|
1899
1899
|
exports.getMetaTagContent = getMetaTagContent;
|
|
@@ -69,7 +69,12 @@ export function createBulkLinksAsyncIterFactory(ctx) {
|
|
|
69
69
|
})))
|
|
70
70
|
}]
|
|
71
71
|
};
|
|
72
|
-
const bulkLinksIter = pageRequestAsAsyncIter(getBulkLinksPage.bind(undefined, makeConjureContext(ctx, "object-set-service/api")), getResults,
|
|
72
|
+
const bulkLinksIter = pageRequestAsAsyncIter(getBulkLinksPage.bind(undefined, makeConjureContext(ctx, "object-set-service/api")), getResults, (prevReq, prevResult) => applyPageToken({
|
|
73
|
+
...prevReq,
|
|
74
|
+
pageToken: prevResult.pageToken
|
|
75
|
+
}, {
|
|
76
|
+
pageToken: prevResult.pageToken
|
|
77
|
+
}), req);
|
|
73
78
|
for await (const item of bulkLinksIter) {
|
|
74
79
|
const {
|
|
75
80
|
objectIdentifier
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBulkLinksAsyncIterFactory.js","names":["getBulkLinksPage","invariant","conjureUnionType","makeConjureContext","applyPageToken","getResults","pageRequestAsAsyncIter","metadataCacheClient","createBulkLinksAsyncIterFactory","ctx","objs","linkTypes","length","logger","debug","every","a","$objectType","process","env","NODE_ENV","mcc","helper","forObjectByApiName","objectTypeRid","propertyMapping","fullLinkMapping","Promise","all","getRid","getPropertyMapping","getLinkMapping","linkMapping","Object","fromEntries","entries","filter","apiName","includes","linkType","req","objectSetContext","forkRid","undefined","objectSetFilterContext","parameterOverrides","ontologyBranchRid","owningRid","reportUsage","workstateRid","responseOptions","includeObjectSetEntities","includeUsageCost","pageSize","pageToken","linksRequests","directedLinkTypes","values","map","directedLinkTypeRid","objects","o","objectPrimaryKey","pk","rid","type","$primaryKey","bulkLinksIter","bind","item","objectIdentifier","obj","findObject","link","links","ref","linkSide","getPrimaryKeyOrThrow","otherObjectApiName","forObjectByRid","getApiName","mappedLink","find","linkTypeRid","Error","object","linkApiName","otherObjectPk","pkValue","pks","objectLocatorV2"],"sources":["createBulkLinksAsyncIterFactory.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 type { OsdkBase } from \"@osdk/api\";\nimport type { EXPERIMENTAL_BulkLinkResult as BulkLinkResult } from \"@osdk/api/unstable\";\nimport type {\n DirectedLinkTypeRid,\n FoundryObjectReference,\n GetBulkLinksPageRequest,\n ObjectIdentifier,\n} from \"@osdk/client.unstable\";\nimport { getBulkLinksPage } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { conjureUnionType } from \"../objectSet/conjureUnionType.js\";\nimport { makeConjureContext } from \"../ontology/makeConjureContext.js\";\nimport {\n applyPageToken,\n getResults,\n pageRequestAsAsyncIter,\n} from \"../pageRequestAsAsyncIter.js\";\nimport { metadataCacheClient } from \"./ConjureSupport.js\";\n\nexport function createBulkLinksAsyncIterFactory(ctx: MinimalClient) {\n return async function*(\n objs: Array<OsdkBase<any>>,\n linkTypes: string[],\n ): AsyncGenerator<BulkLinkResult, void, unknown> {\n if (objs.length === 0) {\n return;\n }\n\n ctx.logger?.debug(\"Preparing to fetch bulk links\");\n\n // require all objects to be the same type for now\n invariant(objs.every(a => a.$objectType === objs[0].$objectType));\n\n const mcc = await metadataCacheClient(ctx);\n const helper = await mcc.forObjectByApiName(objs[0].$objectType);\n\n const [objectTypeRid, propertyMapping, fullLinkMapping] = await Promise.all(\n [\n helper.getRid(),\n helper.getPropertyMapping(),\n helper.getLinkMapping(),\n ],\n );\n\n const linkMapping = Object.fromEntries(\n Object.entries(fullLinkMapping)\n .filter(([apiName]) => linkTypes.includes(apiName)),\n );\n\n // make sure the link being requested exists\n for (const linkType of linkTypes) {\n if (linkMapping[linkType] == null) {\n throw \"Unable to find link type: \" + linkType;\n }\n }\n\n const req: GetBulkLinksPageRequest = {\n objectSetContext: {\n forkRid: undefined,\n objectSetFilterContext: { parameterOverrides: {} },\n ontologyBranchRid: undefined,\n owningRid: undefined,\n reportUsage: undefined,\n workstateRid: undefined,\n },\n responseOptions: {\n includeObjectSetEntities: true,\n includeUsageCost: false,\n },\n pageSize: 1000,\n pageToken: undefined,\n linksRequests: [{\n directedLinkTypes: Object.values(linkMapping)\n .map<DirectedLinkTypeRid>(({ directedLinkTypeRid }) =>\n directedLinkTypeRid\n ),\n objects: conjureUnionType(\n \"objects\",\n objs.map<ObjectIdentifier>(o =>\n conjureUnionType(\"objectLocatorV2\", {\n objectTypeRid,\n objectPrimaryKey: {\n [propertyMapping.pk.rid]: conjureUnionType(\n propertyMapping.pk.type.type as \"string\",\n o.$primaryKey as string,\n ),\n },\n })\n ),\n ),\n }],\n };\n\n const bulkLinksIter = pageRequestAsAsyncIter(\n getBulkLinksPage.bind(\n undefined,\n makeConjureContext(ctx, \"object-set-service/api\"),\n ),\n getResults,\n applyPageToken,\n req,\n );\n\n for await (const item of bulkLinksIter) {\n const { objectIdentifier } = item;\n const obj = findObject(objectIdentifier, objs);\n\n for (const link of item.links) {\n const ref = link.link[\n link.linkSide === \"SOURCE\"\n ? \"objectSideB\"\n : \"objectSideA\"\n ];\n const pk = getPrimaryKeyOrThrow(ref);\n const otherObjectApiName =\n await (await mcc.forObjectByRid(pk.objectTypeRid))\n .getApiName();\n\n const mappedLink = Object.values(linkMapping).find(a =>\n a.directedLinkTypeRid.linkTypeRid === link.link.linkTypeRid\n && a.directedLinkTypeRid.linkSide === link.linkSide\n );\n if (!mappedLink) throw new Error(\"Could not find link type\"); // should not happens\n\n yield {\n object: obj,\n linkApiName: mappedLink.apiName,\n otherObjectApiName: otherObjectApiName,\n otherObjectPk: pk.pkValue,\n };\n }\n }\n };\n}\n\nfunction findObject(\n objectIdentifier: ObjectIdentifier,\n objs: (OsdkBase<any>)[],\n) {\n const { pkValue } = getPrimaryKeyOrThrow(objectIdentifier);\n\n const obj = objs.find(o => o.$primaryKey === pkValue);\n if (obj == null) {\n throw new Error(\n `Needed to find object with pk ${pkValue}} and could not`,\n );\n }\n return obj;\n}\n\nfunction getPrimaryKeyOrThrow(\n ref: FoundryObjectReference | ObjectIdentifier,\n) {\n if (\"type\" in ref && ref.type !== \"objectLocatorV2\") {\n throw new Error(\"We do not support looking up object by rid\");\n }\n\n const pks = Object.entries(ref.objectLocatorV2.objectPrimaryKey);\n if (pks.length !== 1) {\n throw new Error(\n \"Unable to support this request due to multiple pks\",\n );\n }\n\n return {\n objectTypeRid: ref.objectLocatorV2.objectTypeRid,\n pkValue: (pks[0][1] as any)[pks[0][1].type] as unknown,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,gBAAgB,QAAQ,uBAAuB;AACxD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,kBAAkB,QAAQ,mCAAmC;AACtE,SACEC,cAAc,EACdC,UAAU,EACVC,sBAAsB,QACjB,8BAA8B;AACrC,SAASC,mBAAmB,QAAQ,qBAAqB;AAEzD,OAAO,SAASC,+BAA+BA,CAACC,GAAkB,EAAE;EAClE,OAAO,iBACLC,IAA0B,EAC1BC,SAAmB,EAC4B;IAC/C,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;MACrB;IACF;IAEAH,GAAG,CAACI,MAAM,EAAEC,KAAK,CAAC,+BAA+B,CAAC;;IAElD;IACA,CAAUJ,IAAI,CAACK,KAAK,CAACC,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EAEA,OAAO;IACL5D,aAAa,EAAEmD,GAAG,CAACe,eAAe,CAAClE,aAAa;IAChDgE,OAAO,EAAGC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAASA,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACxB,IAAI;EAC5C,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createBulkLinksAsyncIterFactory.js","names":["getBulkLinksPage","invariant","conjureUnionType","makeConjureContext","applyPageToken","getResults","pageRequestAsAsyncIter","metadataCacheClient","createBulkLinksAsyncIterFactory","ctx","objs","linkTypes","length","logger","debug","every","a","$objectType","process","env","NODE_ENV","mcc","helper","forObjectByApiName","objectTypeRid","propertyMapping","fullLinkMapping","Promise","all","getRid","getPropertyMapping","getLinkMapping","linkMapping","Object","fromEntries","entries","filter","apiName","includes","linkType","req","objectSetContext","forkRid","undefined","objectSetFilterContext","parameterOverrides","ontologyBranchRid","owningRid","reportUsage","workstateRid","responseOptions","includeObjectSetEntities","includeUsageCost","pageSize","pageToken","linksRequests","directedLinkTypes","values","map","directedLinkTypeRid","objects","o","objectPrimaryKey","pk","rid","type","$primaryKey","bulkLinksIter","bind","prevReq","prevResult","item","objectIdentifier","obj","findObject","link","links","ref","linkSide","getPrimaryKeyOrThrow","otherObjectApiName","forObjectByRid","getApiName","mappedLink","find","linkTypeRid","Error","object","linkApiName","otherObjectPk","pkValue","pks","objectLocatorV2"],"sources":["createBulkLinksAsyncIterFactory.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 type { OsdkBase } from \"@osdk/api\";\nimport type { EXPERIMENTAL_BulkLinkResult as BulkLinkResult } from \"@osdk/api/unstable\";\nimport type {\n DirectedLinkTypeRid,\n FoundryObjectReference,\n GetBulkLinksPageRequest,\n ObjectIdentifier,\n} from \"@osdk/client.unstable\";\nimport { getBulkLinksPage } from \"@osdk/client.unstable\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { conjureUnionType } from \"../objectSet/conjureUnionType.js\";\nimport { makeConjureContext } from \"../ontology/makeConjureContext.js\";\nimport {\n applyPageToken,\n getResults,\n pageRequestAsAsyncIter,\n} from \"../pageRequestAsAsyncIter.js\";\nimport { metadataCacheClient } from \"./ConjureSupport.js\";\n\nexport function createBulkLinksAsyncIterFactory(ctx: MinimalClient) {\n return async function*(\n objs: Array<OsdkBase<any>>,\n linkTypes: string[],\n ): AsyncGenerator<BulkLinkResult, void, unknown> {\n if (objs.length === 0) {\n return;\n }\n\n ctx.logger?.debug(\"Preparing to fetch bulk links\");\n\n // require all objects to be the same type for now\n invariant(objs.every(a => a.$objectType === objs[0].$objectType));\n\n const mcc = await metadataCacheClient(ctx);\n const helper = await mcc.forObjectByApiName(objs[0].$objectType);\n\n const [objectTypeRid, propertyMapping, fullLinkMapping] = await Promise.all(\n [\n helper.getRid(),\n helper.getPropertyMapping(),\n helper.getLinkMapping(),\n ],\n );\n\n const linkMapping = Object.fromEntries(\n Object.entries(fullLinkMapping)\n .filter(([apiName]) => linkTypes.includes(apiName)),\n );\n\n // make sure the link being requested exists\n for (const linkType of linkTypes) {\n if (linkMapping[linkType] == null) {\n throw \"Unable to find link type: \" + linkType;\n }\n }\n\n const req: GetBulkLinksPageRequest = {\n objectSetContext: {\n forkRid: undefined,\n objectSetFilterContext: { parameterOverrides: {} },\n ontologyBranchRid: undefined,\n owningRid: undefined,\n reportUsage: undefined,\n workstateRid: undefined,\n },\n responseOptions: {\n includeObjectSetEntities: true,\n includeUsageCost: false,\n },\n pageSize: 1000,\n pageToken: undefined,\n linksRequests: [{\n directedLinkTypes: Object.values(linkMapping)\n .map<DirectedLinkTypeRid>(({ directedLinkTypeRid }) =>\n directedLinkTypeRid\n ),\n objects: conjureUnionType(\n \"objects\",\n objs.map<ObjectIdentifier>(o =>\n conjureUnionType(\"objectLocatorV2\", {\n objectTypeRid,\n objectPrimaryKey: {\n [propertyMapping.pk.rid]: conjureUnionType(\n propertyMapping.pk.type.type as \"string\",\n o.$primaryKey as string,\n ),\n },\n })\n ),\n ),\n }],\n };\n\n const bulkLinksIter = pageRequestAsAsyncIter(\n getBulkLinksPage.bind(\n undefined,\n makeConjureContext(ctx, \"object-set-service/api\"),\n ),\n getResults,\n (prevReq, prevResult) =>\n applyPageToken({ ...prevReq, pageToken: prevResult.pageToken }, {\n pageToken: prevResult.pageToken,\n }),\n req,\n );\n\n for await (const item of bulkLinksIter) {\n const { objectIdentifier } = item;\n const obj = findObject(objectIdentifier, objs);\n\n for (const link of item.links) {\n const ref = link.link[\n link.linkSide === \"SOURCE\"\n ? \"objectSideB\"\n : \"objectSideA\"\n ];\n const pk = getPrimaryKeyOrThrow(ref);\n const otherObjectApiName =\n await (await mcc.forObjectByRid(pk.objectTypeRid))\n .getApiName();\n\n const mappedLink = Object.values(linkMapping).find(a =>\n a.directedLinkTypeRid.linkTypeRid === link.link.linkTypeRid\n && a.directedLinkTypeRid.linkSide === link.linkSide\n );\n if (!mappedLink) throw new Error(\"Could not find link type\"); // should not happens\n\n yield {\n object: obj,\n linkApiName: mappedLink.apiName,\n otherObjectApiName: otherObjectApiName,\n otherObjectPk: pk.pkValue,\n };\n }\n }\n };\n}\n\nfunction findObject(\n objectIdentifier: ObjectIdentifier,\n objs: (OsdkBase<any>)[],\n) {\n const { pkValue } = getPrimaryKeyOrThrow(objectIdentifier);\n\n const obj = objs.find(o => o.$primaryKey === pkValue);\n if (obj == null) {\n throw new Error(\n `Needed to find object with pk ${pkValue}} and could not`,\n );\n }\n return obj;\n}\n\nfunction getPrimaryKeyOrThrow(\n ref: FoundryObjectReference | ObjectIdentifier,\n) {\n if (\"type\" in ref && ref.type !== \"objectLocatorV2\") {\n throw new Error(\"We do not support looking up object by rid\");\n }\n\n const pks = Object.entries(ref.objectLocatorV2.objectPrimaryKey);\n if (pks.length !== 1) {\n throw new Error(\n \"Unable to support this request due to multiple pks\",\n );\n }\n\n return {\n objectTypeRid: ref.objectLocatorV2.objectTypeRid,\n pkValue: (pks[0][1] as any)[pks[0][1].type] as unknown,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,gBAAgB,QAAQ,uBAAuB;AACxD,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,gBAAgB,QAAQ,kCAAkC;AACnE,SAASC,kBAAkB,QAAQ,mCAAmC;AACtE,SACEC,cAAc,EACdC,UAAU,EACVC,sBAAsB,QACjB,8BAA8B;AACrC,SAASC,mBAAmB,QAAQ,qBAAqB;AAEzD,OAAO,SAASC,+BAA+BA,CAACC,GAAkB,EAAE;EAClE,OAAO,iBACLC,IAA0B,EAC1BC,SAAmB,EAC4B;IAC/C,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;MACrB;IACF;IAEAH,GAAG,CAACI,MAAM,EAAEC,KAAK,CAAC,+BAA+B,CAAC;;IAElD;IACA,CAAUJ,IAAI,CAACK,KAAK,CAACC,CAAC,IAAIA,CAAC,CAACC,WAAW,KAAKP,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,CAAC,GAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAhEnB,SAAS,UAATA,SAAS;IAET,MAAMoB,GAAG,GAAG,MAAMd,mBAAmB,CAACE,GAAG,CAAC;IAC1C,MAAMa,MAAM,GAAG,MAAMD,GAAG,CAACE,kBAAkB,CAACb,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,CAAC;IAEhE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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC1B,IAAI;EAC5C,CAAC;AACH","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import * as OntologiesV2 from "@osdk/foundry.ontologies";
|
|
18
18
|
export class MediaReferencePropertyImpl {
|
|
19
|
+
#mediaReference;
|
|
19
20
|
#triplet;
|
|
20
21
|
#client;
|
|
21
22
|
constructor(args) {
|
|
@@ -23,10 +24,12 @@ export class MediaReferencePropertyImpl {
|
|
|
23
24
|
client,
|
|
24
25
|
objectApiName,
|
|
25
26
|
primaryKey,
|
|
26
|
-
propertyName
|
|
27
|
+
propertyName,
|
|
28
|
+
mediaReference
|
|
27
29
|
} = args;
|
|
28
30
|
this.#client = client;
|
|
29
31
|
this.#triplet = [objectApiName, primaryKey, propertyName];
|
|
32
|
+
this.#mediaReference = mediaReference;
|
|
30
33
|
}
|
|
31
34
|
async fetchContents() {
|
|
32
35
|
return OntologiesV2.MediaReferenceProperties.getMediaContent(this.#client, await this.#client.ontologyRid, ...this.#triplet, {
|
|
@@ -43,5 +46,8 @@ export class MediaReferencePropertyImpl {
|
|
|
43
46
|
mediaType: r.mediaType
|
|
44
47
|
};
|
|
45
48
|
}
|
|
49
|
+
getMediaReference() {
|
|
50
|
+
return this.#mediaReference;
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
//# sourceMappingURL=createMediaReferenceProperty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMediaReferenceProperty.js","names":["OntologiesV2","MediaReferencePropertyImpl","triplet","client","constructor","args","objectApiName","primaryKey","propertyName","fetchContents","MediaReferenceProperties","getMediaContent","ontologyRid","preview","fetchMetadata","r","getMediaMetadata","path","sizeBytes","Number","mediaType"],"sources":["createMediaReferenceProperty.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 type { Media, MediaMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\n\nexport class MediaReferencePropertyImpl implements Media {\n #triplet: [string, any, string];\n #client: MinimalClient;\n\n constructor(args: {\n client: MinimalClient;\n objectApiName: string;\n primaryKey: any;\n propertyName: string;\n }) {\n const {
|
|
1
|
+
{"version":3,"file":"createMediaReferenceProperty.js","names":["OntologiesV2","MediaReferencePropertyImpl","mediaReference","triplet","client","constructor","args","objectApiName","primaryKey","propertyName","fetchContents","MediaReferenceProperties","getMediaContent","ontologyRid","preview","fetchMetadata","r","getMediaMetadata","path","sizeBytes","Number","mediaType","getMediaReference"],"sources":["createMediaReferenceProperty.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 type { Media, MediaMetadata, MediaReference } from \"@osdk/api\";\nimport type { MediaReference as CoreMediaReference } from \"@osdk/foundry.core\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\n\nexport class MediaReferencePropertyImpl implements Media {\n #mediaReference: MediaReference;\n #triplet: [string, any, string];\n #client: MinimalClient;\n\n constructor(args: {\n client: MinimalClient;\n objectApiName: string;\n primaryKey: any;\n propertyName: string;\n mediaReference: CoreMediaReference;\n }) {\n const {\n client,\n objectApiName,\n primaryKey,\n propertyName,\n mediaReference,\n } = args;\n this.#client = client;\n this.#triplet = [objectApiName, primaryKey, propertyName];\n this.#mediaReference = mediaReference;\n }\n\n public async fetchContents(): Promise<Response> {\n return OntologiesV2.MediaReferenceProperties.getMediaContent(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n }\n\n public async fetchMetadata(): Promise<MediaMetadata> {\n const r = await OntologiesV2.MediaReferenceProperties.getMediaMetadata(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n return {\n path: r.path as string,\n sizeBytes: Number(r.sizeBytes),\n mediaType: r.mediaType,\n };\n }\n\n public getMediaReference(): MediaReference {\n return this.#mediaReference;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAGxD,OAAO,MAAMC,0BAA0B,CAAkB;EACvD,CAACC,cAAc;EACf,CAACC,OAAO;EACR,CAACC,MAAM;EAEPC,WAAWA,CAACC,IAMX,EAAE;IACD,MAAM;MACJF,MAAM;MACNG,aAAa;MACbC,UAAU;MACVC,YAAY;MACZP;IACF,CAAC,GAAGI,IAAI;IACR,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACD,OAAO,GAAG,CAACI,aAAa,EAAEC,UAAU,EAAEC,YAAY,CAAC;IACzD,IAAI,CAAC,CAACP,cAAc,GAAGA,cAAc;EACvC;EAEA,MAAaQ,aAAaA,CAAA,EAAsB;IAC9C,OAAOV,YAAY,CAACW,wBAAwB,CAACC,eAAe,CAC1D,IAAI,CAAC,CAACR,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;EACH;EAEA,MAAaC,aAAaA,CAAA,EAA2B;IACnD,MAAMC,CAAC,GAAG,MAAMhB,YAAY,CAACW,wBAAwB,CAACM,gBAAgB,CACpE,IAAI,CAAC,CAACb,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;IACD,OAAO;MACLI,IAAI,EAAEF,CAAC,CAACE,IAAc;MACtBC,SAAS,EAAEC,MAAM,CAACJ,CAAC,CAACG,SAAS,CAAC;MAC9BE,SAAS,EAAEL,CAAC,CAACK;IACf,CAAC;EACH;EAEOC,iBAAiBA,CAAA,EAAmB;IACzC,OAAO,IAAI,CAAC,CAACpB,cAAc;EAC7B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivedPropertyRuntimeMetadata.js","names":[],"sources":["derivedPropertyRuntimeMetadata.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectMetadata } from \"@osdk/api\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\n\nexport type DerivedPropertyRuntimeMetadata = Record<string, {\n definition: DerivedPropertyDefinition;\n selectedOrCollectedPropertyType: ObjectMetadata.Property | undefined;\n}>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// WARNING!
|
|
18
|
+
// WARNING!
|
|
19
|
+
// This file is used for tests that check intellisense. Editing this file by hand will likely
|
|
20
|
+
// break tests that have hard coded line numbers and line offsets.
|
|
21
|
+
|
|
22
|
+
import { Employee } from "@osdk/client.test.ontology";
|
|
23
|
+
void client(Employee).fetchPage({
|
|
24
|
+
$orderBy: {}
|
|
25
|
+
});
|
|
26
|
+
void client(Employee).fetchPage({
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
$orderBy
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=orderBySuggestionIsRight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderBySuggestionIsRight.js","names":["Employee","client","fetchPage","$orderBy"],"sources":["orderBySuggestionIsRight.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Client } from \"../Client.js\";\n\ndeclare const client: Client;\n\nvoid client(Employee).fetchPage({\n $orderBy: {},\n});\n\nvoid client(Employee).fetchPage({\n // @ts-expect-error\n $orderBy,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,4BAA4B;AAKrD,KAAKC,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;EAC9BC,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC;AAEF,KAAKF,MAAM,CAACD,QAAQ,CAAC,CAACE,SAAS,CAAC;EAC9B;EACAC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -101,5 +101,27 @@ describe("intellisense", () => {
|
|
|
101
101
|
});
|
|
102
102
|
expect(resp.body?.documentation).toMatchInlineSnapshot(`"description: Geotime series reference of the location of the employee"`);
|
|
103
103
|
});
|
|
104
|
+
it("orderBySuggestionIsRight", {
|
|
105
|
+
timeout: 40_000
|
|
106
|
+
}, async () => {
|
|
107
|
+
const {
|
|
108
|
+
resp
|
|
109
|
+
} = await tsServer.sendCompletionsRequest({
|
|
110
|
+
file: intellisenseFilePath,
|
|
111
|
+
line: 28,
|
|
112
|
+
offset: 14,
|
|
113
|
+
triggerKind: ts.CompletionTriggerKind.Invoked
|
|
114
|
+
});
|
|
115
|
+
expect(resp.body?.entries.length).toBeGreaterThan(2);
|
|
116
|
+
expect(resp.body?.entries.map(e => e.name)).toEqual(["class", "employeeId", "employeeLocation", "employeeSensor", "employeeStatus", "fullName", "office", "startDate"]);
|
|
117
|
+
const {
|
|
118
|
+
resp: resp2
|
|
119
|
+
} = await tsServer.sendQuickInfoRequest({
|
|
120
|
+
file: intellisenseFilePath,
|
|
121
|
+
line: 32,
|
|
122
|
+
offset: 3
|
|
123
|
+
});
|
|
124
|
+
expect(resp2.body?.documentation).not.toEqual("'(property) $orderBy: any'");
|
|
125
|
+
});
|
|
104
126
|
});
|
|
105
127
|
//# sourceMappingURL=intellisense.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intellisense.test.js","names":["findUpSync","path","invariant","ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","startTsServer","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","clientPackagePath","clientsPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","stop","timeout","resp","sendQuickInfoRequest","line","offset","body","documentation","toMatchInlineSnapshot"],"sources":["intellisense.test.ts"],"sourcesContent":["/*\n * Copyright 2023 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 type { Logger } from \"@osdk/api\";\nimport { findUpSync } from \"find-up\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport * as ts from \"typescript\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\nimport type { TsServer } from \"./tsserver.js\";\nimport { startTsServer } from \"./tsserver.js\";\n\n// it needs to be hoisted because its referenced from our mocked WebSocket\n// which must be hoisted to work\nconst rootLogger = await vi.hoisted(async (): Promise<Logger> => {\n const pino = (await import(\"pino\")).pino;\n const pinoPretty = await import(\"pino-pretty\");\n const { EventEmitter } = await import(\"node:events\");\n class PinoConsoleLogDestination extends EventEmitter {\n write(a: string) {\n // remove trailing newline since console.log adds one\n if (a.at(-1) === \"\\n\") a = a.slice(0, -1);\n\n // This lets the test framework aggregate the logs per test, whereas direct to stdout does not\n console.log(a);\n }\n }\n return Promise.resolve(pino(\n { level: \"info\" },\n (pinoPretty.build)({\n sync: true,\n timestampKey: undefined,\n errorLikeObjectKeys: [\"error\", \"err\", \"exception\"],\n errorProps: \"stack,cause,properties\",\n ignore: \"time,hostname,pid\",\n destination: new PinoConsoleLogDestination(),\n }),\n ));\n});\n\ndescribe(\"intellisense\", () => {\n let packagesDir: string;\n let clientPackagePath: string;\n\n beforeAll(() => {\n const clientsPackageJson = findUpSync(\"package.json\", {\n cwd: import.meta.dirname,\n });\n console.log({ clientsPackageJson });\n invariant(clientsPackageJson != null);\n packagesDir = path.join(\n path.dirname(clientsPackageJson),\n \"..\",\n );\n\n clientPackagePath = path.join(packagesDir, \"client\");\n });\n\n let tsServer: TsServer;\n let intellisenseFilePath: string;\n\n beforeEach(async (a) => {\n intellisenseFilePath = path.join(\n clientPackagePath,\n \"src\",\n \"intellisense.test.helpers\",\n `${a.task.name}.ts`,\n );\n\n console.log(intellisenseFilePath);\n\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n\n tsServer = await startTsServer(rootLogger);\n await tsServer.sendOpenRequest({ file: intellisenseFilePath });\n });\n\n afterEach(async () => {\n tsServer.stop();\n tsServer = undefined as any;\n });\n\n it(\"callsQueryAcceptsObject\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 27,\n offset: 6,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"(no ontology metadata)\"`,\n );\n });\n\n it(\"showsObjectPropertyJsdoc\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 26,\n offset: 13,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"description: Geotime series reference of the location of the employee\"`,\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,SAAS;AACpC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,KAAKC,EAAE,MAAM,YAAY;AAChC,SACEC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,EAAE,EACFC,EAAE,QACG,QAAQ;AAEf,SAASC,aAAa,QAAQ,eAAe;;AAE7C;AACA;AACA,MAAMC,UAAU,GAAG,MAAMF,EAAE,CAACG,OAAO,CAAC,YAA6B;EAC/D,MAAMC,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAEA,IAAI;EACxC,MAAMC,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAC9C,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAUpD,OAAOC,OAAO,CAACC,OAAO,CAACJ,IAAI,CACzB;IAAEK,KAAK,EAAE;EAAO,CAAC,EAChBJ,UAAU,CAACK,KAAK,CAAE;IACjBC,IAAI,EAAE,IAAI;IACVC,YAAY,EAAEC,SAAS;IACvBC,mBAAmB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC;IAClDC,UAAU,EAAE,wBAAwB;IACpCC,MAAM,EAAE,mBAAmB;IAC3BC,WAAW,EAAE,IAjBjB,cAAwCX,YAAY,CAA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BAAoB,CAAC,CAAC,CAACK,UAAU,CAAC,CAAC;IAE5DN,QAAQ,GAAG,MAAMlC,aAAa,CAACC,UAAU,CAAC;IAC1C,MAAMiC,QAAQ,CAACO,eAAe,CAAC;MAAEC,IAAI,EAAEP;IAAqB,CAAC,CAAC;EAChE,CAAC,CAAC;EAEF1C,SAAS,CAAC,YAAY;IACpByC,QAAQ,CAACS,IAAI,CAAC,CAAC;IACfT,QAAQ,GAAGtB,SAAgB;EAC7B,CAAC,CAAC;EAEFd,EAAE,CAAC,yBAAyB,EAAE;IAAE8C,OAAO,EAAE;EAAO,CAAC,EAAE,YAAY;IAC7D,MAAM;MAAEC;IAAK,CAAC,GAAG,MAAMX,QAAQ,CAACY,oBAAoB,CAAC;MACnDJ,IAAI,EAAEP,oBAAoB;MAC1BY,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE;IACV,CAAC,CAAC;IACFnD,MAAM,CAACgD,IAAI,CAACI,IAAI,EAAEC,aAAa,CAAC,CAACC,qBAAqB,CACpD,0BACF,CAAC;EACH,CAAC,CAAC;EAEFrD,EAAE,CAAC,0BAA0B,EAAE;IAAE8C,OAAO,EAAE;EAAO,CAAC,EAAE,YAAY;IAC9D,MAAM;MAAEC;IAAK,CAAC,GAAG,MAAMX,QAAQ,CAACY,oBAAoB,CAAC;MACnDJ,IAAI,EAAEP,oBAAoB;MAC1BY,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE;IACV,CAAC,CAAC;IACFnD,MAAM,CAACgD,IAAI,CAACI,IAAI,EAAEC,aAAa,CAAC,CAACC,qBAAqB,CACpD,yEACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"intellisense.test.js","names":["findUpSync","path","invariant","ts","afterEach","beforeAll","beforeEach","describe","expect","it","vi","startTsServer","rootLogger","hoisted","pino","pinoPretty","EventEmitter","Promise","resolve","level","build","sync","timestampKey","undefined","errorLikeObjectKeys","errorProps","ignore","destination","write","a","at","slice","console","log","packagesDir","clientPackagePath","clientsPackageJson","cwd","import","meta","dirname","process","env","NODE_ENV","join","tsServer","intellisenseFilePath","task","name","sys","fileExists","toBeTruthy","sendOpenRequest","file","stop","timeout","resp","sendQuickInfoRequest","line","offset","body","documentation","toMatchInlineSnapshot","sendCompletionsRequest","triggerKind","CompletionTriggerKind","Invoked","entries","length","toBeGreaterThan","map","e","toEqual","resp2","not"],"sources":["intellisense.test.ts"],"sourcesContent":["/*\n * Copyright 2023 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 type { Logger } from \"@osdk/api\";\nimport { findUpSync } from \"find-up\";\nimport * as path from \"node:path\";\nimport invariant from \"tiny-invariant\";\nimport * as ts from \"typescript\";\nimport {\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it,\n vi,\n} from \"vitest\";\nimport type { TsServer } from \"./tsserver.js\";\nimport { startTsServer } from \"./tsserver.js\";\n\n// it needs to be hoisted because its referenced from our mocked WebSocket\n// which must be hoisted to work\nconst rootLogger = await vi.hoisted(async (): Promise<Logger> => {\n const pino = (await import(\"pino\")).pino;\n const pinoPretty = await import(\"pino-pretty\");\n const { EventEmitter } = await import(\"node:events\");\n class PinoConsoleLogDestination extends EventEmitter {\n write(a: string) {\n // remove trailing newline since console.log adds one\n if (a.at(-1) === \"\\n\") a = a.slice(0, -1);\n\n // This lets the test framework aggregate the logs per test, whereas direct to stdout does not\n console.log(a);\n }\n }\n return Promise.resolve(pino(\n { level: \"info\" },\n (pinoPretty.build)({\n sync: true,\n timestampKey: undefined,\n errorLikeObjectKeys: [\"error\", \"err\", \"exception\"],\n errorProps: \"stack,cause,properties\",\n ignore: \"time,hostname,pid\",\n destination: new PinoConsoleLogDestination(),\n }),\n ));\n});\n\ndescribe(\"intellisense\", () => {\n let packagesDir: string;\n let clientPackagePath: string;\n\n beforeAll(() => {\n const clientsPackageJson = findUpSync(\"package.json\", {\n cwd: import.meta.dirname,\n });\n console.log({ clientsPackageJson });\n invariant(clientsPackageJson != null);\n packagesDir = path.join(\n path.dirname(clientsPackageJson),\n \"..\",\n );\n\n clientPackagePath = path.join(packagesDir, \"client\");\n });\n\n let tsServer: TsServer;\n let intellisenseFilePath: string;\n\n beforeEach(async (a) => {\n intellisenseFilePath = path.join(\n clientPackagePath,\n \"src\",\n \"intellisense.test.helpers\",\n `${a.task.name}.ts`,\n );\n\n console.log(intellisenseFilePath);\n\n expect(ts.sys.fileExists(intellisenseFilePath)).toBeTruthy();\n\n tsServer = await startTsServer(rootLogger);\n await tsServer.sendOpenRequest({ file: intellisenseFilePath });\n });\n\n afterEach(async () => {\n tsServer.stop();\n tsServer = undefined as any;\n });\n\n it(\"callsQueryAcceptsObject\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 27,\n offset: 6,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"(no ontology metadata)\"`,\n );\n });\n\n it(\"showsObjectPropertyJsdoc\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 26,\n offset: 13,\n });\n expect(resp.body?.documentation).toMatchInlineSnapshot(\n `\"description: Geotime series reference of the location of the employee\"`,\n );\n });\n\n it(\"orderBySuggestionIsRight\", { timeout: 40_000 }, async () => {\n const { resp } = await tsServer.sendCompletionsRequest({\n file: intellisenseFilePath,\n line: 28,\n offset: 14,\n triggerKind: ts.CompletionTriggerKind.Invoked,\n });\n expect(resp.body?.entries.length).toBeGreaterThan(2);\n expect(resp.body?.entries.map(e => e.name)).toEqual([\n \"class\",\n \"employeeId\",\n \"employeeLocation\",\n \"employeeSensor\",\n \"employeeStatus\",\n \"fullName\",\n \"office\",\n \"startDate\",\n ]);\n\n const { resp: resp2 } = await tsServer.sendQuickInfoRequest({\n file: intellisenseFilePath,\n line: 32,\n offset: 3,\n });\n expect(resp2.body?.documentation).not.toEqual(\"'(property) $orderBy: any'\");\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,UAAU,QAAQ,SAAS;AACpC,OAAO,KAAKC,IAAI,MAAM,WAAW;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,OAAO,KAAKC,EAAE,MAAM,YAAY;AAChC,SACEC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,MAAM,EACNC,EAAE,EACFC,EAAE,QACG,QAAQ;AAEf,SAASC,aAAa,QAAQ,eAAe;;AAE7C;AACA;AACA,MAAMC,UAAU,GAAG,MAAMF,EAAE,CAACG,OAAO,CAAC,YAA6B;EAC/D,MAAMC,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,EAAEA,IAAI;EACxC,MAAMC,UAAU,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAC9C,MAAM;IAAEC;EAAa,CAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC;EAUpD,OAAOC,OAAO,CAACC,OAAO,CAACJ,IAAI,CACzB;IAAEK,KAAK,EAAE;EAAO,CAAC,EAChBJ,UAAU,CAACK,KAAK,CAAE;IACjBC,IAAI,EAAE,IAAI;IACVC,YAAY,EAAEC,SAAS;IACvBC,mBAAmB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC;IAClDC,UAAU,EAAE,wBAAwB;IACpCC,MAAM,EAAE,mBAAmB;IAC3BC,WAAW,EAAE,IAjBjB,cAAwCX,YAAY,CAAC;MACnDY,KAAKA,CA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AAW,EAAE7D,EAAE,CAAC8D,qBAAqB,CAACC;IACxC,CAAC,CAAC;IACF1D,MAAM,CAACgD,IAAI,CAACI,IAAI,EAAEO,OAAO,CAACC,MAAM,CAAC,CAACC,eAAe,CAAC,CAAC,CAAC;IACpD7D,MAAM,CAACgD,IAAI,CAACI,IAAI,EAAEO,OAAO,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACvB,IAAI,CAAC,CAAC,CAACwB,OAAO,CAAC,CAClD,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,WAAW,CACZ,CAAC;IAEF,MAAM;MAAEhB,IAAI,EAAEiB;IAAM,CAAC,GAAG,MAAM5B,QAAQ,CAACY,oBAAoB,CAAC;MAC1DJ,IAAI,EAAEP,oBAAoB;MAC1BY,IAAI,EAAE,EAAE;MACRC,MAAM,EAAE;IACV,CAAC,CAAC;IACFnD,MAAM,CAACiE,KAAK,CAACb,IAAI,EAAEC,aAAa,CAAC,CAACa,GAAG,CAACF,OAAO,CAAC,4BAA4B,CAAC;EAC7E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -22,19 +22,7 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
22
22
|
describe("api namespaces", () => {
|
|
23
23
|
describe("interfaces", () => {
|
|
24
24
|
it("properly converts shortname to fqApiName", () => {
|
|
25
|
-
const
|
|
26
|
-
$and: [{
|
|
27
|
-
prop: {
|
|
28
|
-
$eq: 5
|
|
29
|
-
}
|
|
30
|
-
}, {
|
|
31
|
-
prop2: {
|
|
32
|
-
innerProp1: {
|
|
33
|
-
$eq: "myProp"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}]
|
|
37
|
-
}, {
|
|
25
|
+
const T = {
|
|
38
26
|
type: "interface",
|
|
39
27
|
apiName: "a.Foo",
|
|
40
28
|
__DefinitionMetadata: {
|
|
@@ -53,9 +41,23 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
53
41
|
apiName: "a.Foo",
|
|
54
42
|
displayName: "",
|
|
55
43
|
links: {},
|
|
56
|
-
rid: ""
|
|
44
|
+
rid: "",
|
|
45
|
+
description: undefined
|
|
57
46
|
}
|
|
58
|
-
}
|
|
47
|
+
};
|
|
48
|
+
const r = modernToLegacyWhereClause({
|
|
49
|
+
$and: [{
|
|
50
|
+
prop: {
|
|
51
|
+
$eq: 5
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
prop2: {
|
|
55
|
+
innerProp1: {
|
|
56
|
+
$eq: "myProp"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}]
|
|
60
|
+
}, T);
|
|
59
61
|
expect(r).toMatchInlineSnapshot(`
|
|
60
62
|
{
|
|
61
63
|
"type": "and",
|
|
@@ -80,15 +82,7 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
80
82
|
`);
|
|
81
83
|
});
|
|
82
84
|
it("properly does not convert when interface has no apiNamespace", () => {
|
|
83
|
-
const
|
|
84
|
-
"b.prop": 5,
|
|
85
|
-
foo: 6,
|
|
86
|
-
"c.prop2": {
|
|
87
|
-
innerProp1: {
|
|
88
|
-
$eq: "myProp"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
85
|
+
const T = {
|
|
92
86
|
type: "interface",
|
|
93
87
|
apiName: "Foo",
|
|
94
88
|
__DefinitionMetadata: {
|
|
@@ -113,9 +107,19 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
113
107
|
apiName: "Foo",
|
|
114
108
|
displayName: "",
|
|
115
109
|
links: {},
|
|
116
|
-
rid: ""
|
|
110
|
+
rid: "",
|
|
111
|
+
description: undefined
|
|
117
112
|
}
|
|
118
|
-
}
|
|
113
|
+
};
|
|
114
|
+
const r = modernToLegacyWhereClause({
|
|
115
|
+
"b.prop": 5,
|
|
116
|
+
foo: 6,
|
|
117
|
+
"c.prop2": {
|
|
118
|
+
innerProp1: {
|
|
119
|
+
$eq: "myProp"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}, T);
|
|
119
123
|
expect(r).toMatchInlineSnapshot(`
|
|
120
124
|
{
|
|
121
125
|
"type": "and",
|
|
@@ -145,15 +149,7 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
145
149
|
`);
|
|
146
150
|
});
|
|
147
151
|
it("gracefully handles redundant apiNamespace in property", () => {
|
|
148
|
-
const
|
|
149
|
-
"b.prop": 5,
|
|
150
|
-
"a.foo": 6,
|
|
151
|
-
"c.prop2": {
|
|
152
|
-
innerProp1: {
|
|
153
|
-
$eq: "myProp"
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}, {
|
|
152
|
+
const T = {
|
|
157
153
|
type: "interface",
|
|
158
154
|
apiName: "a.Foo",
|
|
159
155
|
__DefinitionMetadata: {
|
|
@@ -178,9 +174,19 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
178
174
|
apiName: "a.Foo",
|
|
179
175
|
displayName: "",
|
|
180
176
|
links: {},
|
|
181
|
-
rid: ""
|
|
177
|
+
rid: "",
|
|
178
|
+
description: undefined
|
|
182
179
|
}
|
|
183
|
-
}
|
|
180
|
+
};
|
|
181
|
+
const r = modernToLegacyWhereClause({
|
|
182
|
+
"b.prop": 5,
|
|
183
|
+
"a.foo": 6,
|
|
184
|
+
"c.prop2": {
|
|
185
|
+
innerProp1: {
|
|
186
|
+
$eq: "myProp"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}, T);
|
|
184
190
|
expect(r).toMatchInlineSnapshot(`
|
|
185
191
|
{
|
|
186
192
|
"type": "and",
|
|
@@ -210,9 +216,7 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
210
216
|
`);
|
|
211
217
|
});
|
|
212
218
|
it("properly does not convert different apiNamespaces", () => {
|
|
213
|
-
|
|
214
|
-
"b.prop": 5
|
|
215
|
-
}, {
|
|
219
|
+
const T = {
|
|
216
220
|
type: "interface",
|
|
217
221
|
apiName: "a.Foo",
|
|
218
222
|
__DefinitionMetadata: {
|
|
@@ -231,9 +235,13 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
231
235
|
apiName: "a.Foo",
|
|
232
236
|
displayName: "",
|
|
233
237
|
links: {},
|
|
234
|
-
rid: ""
|
|
238
|
+
rid: "",
|
|
239
|
+
description: undefined
|
|
235
240
|
}
|
|
236
|
-
}
|
|
241
|
+
};
|
|
242
|
+
expect(modernToLegacyWhereClause({
|
|
243
|
+
"b.prop": 5
|
|
244
|
+
}, T)).toMatchInlineSnapshot(`
|
|
237
245
|
{
|
|
238
246
|
"field": "b.prop",
|
|
239
247
|
"type": "eq",
|
|
@@ -244,9 +252,7 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
244
252
|
});
|
|
245
253
|
describe("objects", () => {
|
|
246
254
|
it("does not convert object short property names to fq", () => {
|
|
247
|
-
const
|
|
248
|
-
prop: 5
|
|
249
|
-
}, {
|
|
255
|
+
const T = {
|
|
250
256
|
type: "interface",
|
|
251
257
|
apiName: "a.Foo",
|
|
252
258
|
__DefinitionMetadata: {
|
|
@@ -262,9 +268,13 @@ describe(modernToLegacyWhereClause, () => {
|
|
|
262
268
|
apiName: "a.Foo",
|
|
263
269
|
displayName: "",
|
|
264
270
|
links: {},
|
|
265
|
-
rid: ""
|
|
271
|
+
rid: "",
|
|
272
|
+
description: undefined
|
|
266
273
|
}
|
|
267
|
-
}
|
|
274
|
+
};
|
|
275
|
+
const r = modernToLegacyWhereClause({
|
|
276
|
+
prop: 5
|
|
277
|
+
}, T);
|
|
268
278
|
expect(r).toMatchInlineSnapshot(`
|
|
269
279
|
{
|
|
270
280
|
"field": "a.prop",
|