@osdk/faux 0.6.0-beta.6 → 0.6.0-beta.7
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 +12 -0
- package/build/browser/handlers/createObjectSetHandlers.js +7 -2
- package/build/browser/handlers/createObjectSetHandlers.js.map +1 -1
- package/build/cjs/index.cjs +63 -38
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/handlers/createObjectSetHandlers.js +7 -2
- package/build/esm/handlers/createObjectSetHandlers.js.map +1 -1
- package/package.json +9 -9
|
@@ -58,11 +58,16 @@ OntologiesV2.OntologyObjectSets.aggregate(baseUrl, async ({
|
|
|
58
58
|
}
|
|
59
59
|
const {
|
|
60
60
|
field,
|
|
61
|
+
propertyIdentifier,
|
|
61
62
|
includeNullValues
|
|
62
63
|
} = exactGroupBys[0];
|
|
64
|
+
const groupField = field ?? (propertyIdentifier?.type === "property" ? propertyIdentifier.apiName : undefined);
|
|
65
|
+
if (groupField == null) {
|
|
66
|
+
throw new Error("FauxFoundry aggregate: exact groupBy requires a field");
|
|
67
|
+
}
|
|
63
68
|
const groups = new Map();
|
|
64
69
|
for (const obj of objects) {
|
|
65
|
-
const rawValue = obj[
|
|
70
|
+
const rawValue = obj[groupField];
|
|
66
71
|
const key = rawValue == null ? null : String(rawValue);
|
|
67
72
|
if (key == null && !includeNullValues) {
|
|
68
73
|
continue;
|
|
@@ -71,7 +76,7 @@ OntologiesV2.OntologyObjectSets.aggregate(baseUrl, async ({
|
|
|
71
76
|
}
|
|
72
77
|
const data = Array.from(groups.entries()).map(([key, count]) => ({
|
|
73
78
|
group: {
|
|
74
|
-
[
|
|
79
|
+
[groupField]: key
|
|
75
80
|
},
|
|
76
81
|
metrics: [{
|
|
77
82
|
name: "count",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createObjectSetHandlers.js","names":["getObjectsFromSet","OntologiesV2","createObjectSetHandlers","baseUrl","fauxFoundry","OntologyObjectSets","load","request","params","a","getDataStore","ontologyApiName","getObjectsFromObjectSet","json","aggregate","body","ds","objects","objectSet","undefined","exactGroupBys","groupBy","filter","g","type","length","Error","accuracy","data","group","metrics","name","value","field","includeNullValues","groups","Map","obj","rawValue","key","String","set","get","Array","from","entries","map","count","loadMultipleObjectTypes","pagedResponse","objectApiNames","Set","o","__apiName","interfaceToObjectTypeMappings","getOntology","getInterfaceToObjectTypeMappings","interfaceToObjectTypeMappingsV2","propertySecurities"],"sources":["createObjectSetHandlers.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 { RequestHandler } from \"msw\";\nimport type { FauxFoundry } from \"../FauxFoundry/FauxFoundry.js\";\nimport { getObjectsFromSet } from \"../FauxFoundry/getObjectsFromSet.js\";\nimport { OntologiesV2 } from \"../mock/index.js\";\n\nexport const createObjectSetHandlers = (\n baseUrl: string,\n fauxFoundry: FauxFoundry,\n): Array<RequestHandler> => [\n /**\n * Load ObjectSet Objects\n */\n OntologiesV2.OntologyObjectSets.load(\n baseUrl,\n async ({ request, params }) => {\n const a = fauxFoundry\n .getDataStore(params.ontologyApiName)\n .getObjectsFromObjectSet(await request.json());\n return a;\n },\n ),\n\n /**\n * Aggregate Objects in ObjectSet\n */\n OntologiesV2.OntologyObjectSets.aggregate(\n baseUrl,\n async ({ request, params }) => {\n const body = await request.json();\n const ds = fauxFoundry.getDataStore(params.ontologyApiName);\n const objects = getObjectsFromSet(ds, body.objectSet, undefined);\n\n const exactGroupBys = body.groupBy.filter(\n (g): g is Extract<typeof g, { type: \"exact\" }> => g.type === \"exact\",\n );\n\n if (exactGroupBys.length !== body.groupBy.length) {\n throw new Error(\n \"FauxFoundry aggregate: only 'exact' groupBy type is supported\",\n );\n }\n\n if (exactGroupBys.length === 0) {\n return {\n accuracy: \"ACCURATE\",\n data: [{\n group: {},\n metrics: [{ name: \"count\", value: objects.length }],\n }],\n };\n }\n\n if (exactGroupBys.length > 1) {\n throw new Error(\n `FauxFoundry aggregate: multi-dimensional groupBy not yet implemented (got ${exactGroupBys.length} fields)`,\n );\n }\n\n const { field, includeNullValues } = exactGroupBys[0];\n const groups = new Map<string | null, number>();\n\n for (const obj of objects) {\n const rawValue = obj[
|
|
1
|
+
{"version":3,"file":"createObjectSetHandlers.js","names":["getObjectsFromSet","OntologiesV2","createObjectSetHandlers","baseUrl","fauxFoundry","OntologyObjectSets","load","request","params","a","getDataStore","ontologyApiName","getObjectsFromObjectSet","json","aggregate","body","ds","objects","objectSet","undefined","exactGroupBys","groupBy","filter","g","type","length","Error","accuracy","data","group","metrics","name","value","field","propertyIdentifier","includeNullValues","groupField","apiName","groups","Map","obj","rawValue","key","String","set","get","Array","from","entries","map","count","loadMultipleObjectTypes","pagedResponse","objectApiNames","Set","o","__apiName","interfaceToObjectTypeMappings","getOntology","getInterfaceToObjectTypeMappings","interfaceToObjectTypeMappingsV2","propertySecurities"],"sources":["createObjectSetHandlers.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 { RequestHandler } from \"msw\";\nimport type { FauxFoundry } from \"../FauxFoundry/FauxFoundry.js\";\nimport { getObjectsFromSet } from \"../FauxFoundry/getObjectsFromSet.js\";\nimport { OntologiesV2 } from \"../mock/index.js\";\n\nexport const createObjectSetHandlers = (\n baseUrl: string,\n fauxFoundry: FauxFoundry,\n): Array<RequestHandler> => [\n /**\n * Load ObjectSet Objects\n */\n OntologiesV2.OntologyObjectSets.load(\n baseUrl,\n async ({ request, params }) => {\n const a = fauxFoundry\n .getDataStore(params.ontologyApiName)\n .getObjectsFromObjectSet(await request.json());\n return a;\n },\n ),\n\n /**\n * Aggregate Objects in ObjectSet\n */\n OntologiesV2.OntologyObjectSets.aggregate(\n baseUrl,\n async ({ request, params }) => {\n const body = await request.json();\n const ds = fauxFoundry.getDataStore(params.ontologyApiName);\n const objects = getObjectsFromSet(ds, body.objectSet, undefined);\n\n const exactGroupBys = body.groupBy.filter(\n (g): g is Extract<typeof g, { type: \"exact\" }> => g.type === \"exact\",\n );\n\n if (exactGroupBys.length !== body.groupBy.length) {\n throw new Error(\n \"FauxFoundry aggregate: only 'exact' groupBy type is supported\",\n );\n }\n\n if (exactGroupBys.length === 0) {\n return {\n accuracy: \"ACCURATE\",\n data: [{\n group: {},\n metrics: [{ name: \"count\", value: objects.length }],\n }],\n };\n }\n\n if (exactGroupBys.length > 1) {\n throw new Error(\n `FauxFoundry aggregate: multi-dimensional groupBy not yet implemented (got ${exactGroupBys.length} fields)`,\n );\n }\n\n const { field, propertyIdentifier, includeNullValues } = exactGroupBys[0];\n const groupField = field\n ?? (propertyIdentifier?.type === \"property\"\n ? propertyIdentifier.apiName\n : undefined);\n if (groupField == null) {\n throw new Error(\n \"FauxFoundry aggregate: exact groupBy requires a field\",\n );\n }\n const groups = new Map<string | null, number>();\n\n for (const obj of objects) {\n const rawValue = obj[groupField];\n const key = rawValue == null ? null : String(rawValue);\n\n if (key == null && !includeNullValues) {\n continue;\n }\n\n groups.set(key, (groups.get(key) ?? 0) + 1);\n }\n\n const data = Array.from(groups.entries()).map(\n ([key, count]: [string | null, number]) => ({\n group: { [groupField]: key },\n metrics: [{ name: \"count\", value: count }],\n }),\n );\n\n return { accuracy: \"ACCURATE\", data };\n },\n ),\n\n /**\n * Load interface objectset Objects\n */\n OntologiesV2.OntologyObjectSets.loadMultipleObjectTypes(\n baseUrl,\n async ({ params, request }) => {\n const pagedResponse = fauxFoundry\n .getDataStore(params.ontologyApiName)\n .getObjectsFromObjectSet(await request.json());\n\n const objectApiNames = new Set(pagedResponse.data.map(o => o.__apiName));\n\n return {\n interfaceToObjectTypeMappings: fauxFoundry\n .getOntology(params.ontologyApiName)\n .getInterfaceToObjectTypeMappings(objectApiNames),\n interfaceToObjectTypeMappingsV2: {},\n ...pagedResponse,\n propertySecurities: [],\n };\n },\n ),\n];\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,qCAAqC;AACvE,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,OAAO,MAAMC,uBAAuB,GAAGA,CACrCC,OAAe,EACfC,WAAwB,KACE;AAC1B;AACF;AACA;AACEH,YAAY,CAACI,kBAAkB,CAACC,IAAI,CAClCH,OAAO,EACP,OAAO;EAAEI,OAAO;EAAEC;AAAO,CAAC,KAAK;EAC7B,MAAMC,CAAC,GAAGL,WAAW,CAClBM,YAAY,CAACF,MAAM,CAACG,eAAe,CAAC,CACpCC,uBAAuB,CAAC,MAAML,OAAO,CAACM,IAAI,CAAC,CAAC,CAAC;EAChD,OAAOJ,CAAC;AACV,CACF,CAAC;AAED;AACF;AACA;AACER,YAAY,CAACI,kBAAkB,CAACS,SAAS,CACvCX,OAAO,EACP,OAAO;EAAEI,OAAO;EAAEC;AAAO,CAAC,KAAK;EAC7B,MAAMO,IAAI,GAAG,MAAMR,OAAO,CAACM,IAAI,CAAC,CAAC;EACjC,MAAMG,EAAE,GAAGZ,WAAW,CAACM,YAAY,CAACF,MAAM,CAACG,eAAe,CAAC;EAC3D,MAAMM,OAA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ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/faux",
|
|
3
|
-
"version": "0.6.0-beta.
|
|
3
|
+
"version": "0.6.0-beta.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "private",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@osdk/foundry.admin": "2.
|
|
33
|
-
"@osdk/foundry.core": "2.
|
|
34
|
-
"@osdk/foundry.geo": "2.
|
|
35
|
-
"@osdk/foundry.mediasets": "2.
|
|
36
|
-
"@osdk/foundry.ontologies": "2.
|
|
37
|
-
"@osdk/internal.foundry.ontologies": "2.
|
|
32
|
+
"@osdk/foundry.admin": "2.57.0",
|
|
33
|
+
"@osdk/foundry.core": "2.57.0",
|
|
34
|
+
"@osdk/foundry.geo": "2.57.0",
|
|
35
|
+
"@osdk/foundry.mediasets": "2.57.0",
|
|
36
|
+
"@osdk/foundry.ontologies": "2.57.0",
|
|
37
|
+
"@osdk/internal.foundry.ontologies": "2.57.0",
|
|
38
38
|
"date-fns": "^4.1.0",
|
|
39
39
|
"decimal.js": "^10.6.0",
|
|
40
40
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"semver": "^7.7.2",
|
|
45
45
|
"tiny-invariant": "^1.3.3",
|
|
46
46
|
"type-fest": "^4.41.0",
|
|
47
|
-
"@osdk/api": "~2.8.0-beta.
|
|
48
|
-
"@osdk/generator-converters": "~2.8.0-beta.
|
|
47
|
+
"@osdk/api": "~2.8.0-beta.32",
|
|
48
|
+
"@osdk/generator-converters": "~2.8.0-beta.32"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/json-stable-stringify": "^1.2.0",
|