@osdk/faux 0.6.0-beta.4 → 0.6.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/build/browser/FauxFoundry/FauxDataStore.js +3 -2
  3. package/build/browser/FauxFoundry/FauxDataStore.js.map +1 -1
  4. package/build/browser/FauxFoundry/collections/DefaultMap.js +30 -0
  5. package/build/browser/FauxFoundry/collections/DefaultMap.js.map +1 -0
  6. package/build/browser/FauxFoundry/collections/SetMultiMap.js +43 -0
  7. package/build/browser/FauxFoundry/collections/SetMultiMap.js.map +1 -0
  8. package/build/browser/handlers/createObjectSetHandlers.js +51 -2
  9. package/build/browser/handlers/createObjectSetHandlers.js.map +1 -1
  10. package/build/cjs/index.cjs +100 -10
  11. package/build/cjs/index.cjs.map +1 -1
  12. package/build/cjs/index.d.cts +3 -2
  13. package/build/esm/FauxFoundry/FauxDataStore.js +3 -2
  14. package/build/esm/FauxFoundry/FauxDataStore.js.map +1 -1
  15. package/build/esm/FauxFoundry/collections/DefaultMap.js +30 -0
  16. package/build/esm/FauxFoundry/collections/DefaultMap.js.map +1 -0
  17. package/build/esm/FauxFoundry/collections/SetMultiMap.js +43 -0
  18. package/build/esm/FauxFoundry/collections/SetMultiMap.js.map +1 -0
  19. package/build/esm/handlers/createObjectSetHandlers.js +51 -2
  20. package/build/esm/handlers/createObjectSetHandlers.js.map +1 -1
  21. package/build/types/FauxFoundry/FauxDataStore.d.ts +3 -2
  22. package/build/types/FauxFoundry/FauxDataStore.d.ts.map +1 -1
  23. package/build/types/FauxFoundry/collections/DefaultMap.d.ts +8 -0
  24. package/build/types/FauxFoundry/collections/DefaultMap.d.ts.map +1 -0
  25. package/build/types/FauxFoundry/collections/SetMultiMap.d.ts +10 -0
  26. package/build/types/FauxFoundry/collections/SetMultiMap.d.ts.map +1 -0
  27. package/build/types/handlers/createObjectSetHandlers.d.ts.map +1 -1
  28. package/package.json +6 -7
  29. package/build/browser/FauxFoundry/FauxAdmin.test.js +0 -248
  30. package/build/browser/FauxFoundry/FauxAdmin.test.js.map +0 -1
  31. package/build/browser/FauxFoundry/FauxDataStore.test.js +0 -477
  32. package/build/browser/FauxFoundry/FauxDataStore.test.js.map +0 -1
  33. package/build/browser/FauxFoundry/filterObjects.test.js +0 -216
  34. package/build/browser/FauxFoundry/filterObjects.test.js.map +0 -1
  35. package/build/browser/FauxFoundry/filterTimeSeriesData.test.js +0 -116
  36. package/build/browser/FauxFoundry/filterTimeSeriesData.test.js.map +0 -1
  37. package/build/browser/FauxFoundry/validateAction.test.js +0 -523
  38. package/build/browser/FauxFoundry/validateAction.test.js.map +0 -1
  39. package/build/esm/FauxFoundry/FauxAdmin.test.js +0 -248
  40. package/build/esm/FauxFoundry/FauxAdmin.test.js.map +0 -1
  41. package/build/esm/FauxFoundry/FauxDataStore.test.js +0 -477
  42. package/build/esm/FauxFoundry/FauxDataStore.test.js.map +0 -1
  43. package/build/esm/FauxFoundry/filterObjects.test.js +0 -216
  44. package/build/esm/FauxFoundry/filterObjects.test.js.map +0 -1
  45. package/build/esm/FauxFoundry/filterTimeSeriesData.test.js +0 -116
  46. package/build/esm/FauxFoundry/filterTimeSeriesData.test.js.map +0 -1
  47. package/build/esm/FauxFoundry/validateAction.test.js +0 -523
  48. package/build/esm/FauxFoundry/validateAction.test.js.map +0 -1
  49. package/build/types/FauxFoundry/FauxAdmin.test.d.ts +0 -1
  50. package/build/types/FauxFoundry/FauxAdmin.test.d.ts.map +0 -1
  51. package/build/types/FauxFoundry/FauxDataStore.test.d.ts +0 -1
  52. package/build/types/FauxFoundry/FauxDataStore.test.d.ts.map +0 -1
  53. package/build/types/FauxFoundry/filterObjects.test.d.ts +0 -1
  54. package/build/types/FauxFoundry/filterObjects.test.d.ts.map +0 -1
  55. package/build/types/FauxFoundry/filterTimeSeriesData.test.d.ts +0 -1
  56. package/build/types/FauxFoundry/filterTimeSeriesData.test.d.ts.map +0 -1
  57. package/build/types/FauxFoundry/validateAction.test.d.ts +0 -1
  58. package/build/types/FauxFoundry/validateAction.test.d.ts.map +0 -1
@@ -3,7 +3,6 @@
3
3
  var generatorConverters = require('@osdk/generator-converters');
4
4
  var crypto = require('crypto');
5
5
  var msw = require('msw');
6
- var mnemonist = require('mnemonist');
7
6
  var util = require('util');
8
7
  var invariant4 = require('tiny-invariant');
9
8
  var deepEqual = require('fast-deep-equal');
@@ -575,6 +574,49 @@ function pageThroughResponseSearchParams(iter, {
575
574
  function isBaseServerObject(obj) {
576
575
  return typeof obj === "object" && obj != null && "__primaryKey" in obj && "__apiName" in obj && !("$apiName" in obj) && !("$primaryKey" in obj);
577
576
  }
577
+
578
+ // src/FauxFoundry/collections/DefaultMap.ts
579
+ var DefaultMap = class extends Map {
580
+ #factory;
581
+ constructor(factory) {
582
+ super();
583
+ this.#factory = factory;
584
+ }
585
+ get(key) {
586
+ if (!super.has(key)) {
587
+ super.set(key, this.#factory(key));
588
+ }
589
+ return super.get(key);
590
+ }
591
+ };
592
+
593
+ // src/FauxFoundry/collections/SetMultiMap.ts
594
+ var SetMultiMap = class {
595
+ #map = /* @__PURE__ */ new Map();
596
+ set(key, value) {
597
+ let s = this.#map.get(key);
598
+ if (!s) {
599
+ s = /* @__PURE__ */ new Set();
600
+ this.#map.set(key, s);
601
+ }
602
+ s.add(value);
603
+ }
604
+ get(key) {
605
+ return this.#map.get(key);
606
+ }
607
+ remove(key, value) {
608
+ const s = this.#map.get(key);
609
+ if (s) {
610
+ s.delete(value);
611
+ if (s.size === 0) {
612
+ this.#map.delete(key);
613
+ }
614
+ }
615
+ }
616
+ delete(key) {
617
+ return this.#map.delete(key);
618
+ }
619
+ };
578
620
  var FauxDataStoreBatch = class {
579
621
  #fauxDataStore;
580
622
  objectEdits = {
@@ -1500,15 +1542,15 @@ function isValidDecimalString(value) {
1500
1542
 
1501
1543
  // src/FauxFoundry/FauxDataStore.ts
1502
1544
  var FauxDataStore = class {
1503
- #objects = new mnemonist.DefaultMap((key) => /* @__PURE__ */ new Map());
1504
- #objectsWithSecurities = new mnemonist.DefaultMap((key) => /* @__PURE__ */ new Map());
1505
- #singleLinks = new mnemonist.DefaultMap((_objectLocator) => /* @__PURE__ */ new Map());
1506
- #manyLinks = new mnemonist.DefaultMap((_objectLocator) => new mnemonist.MultiMap(Set));
1545
+ #objects = new DefaultMap((key) => /* @__PURE__ */ new Map());
1546
+ #objectsWithSecurities = new DefaultMap((key) => /* @__PURE__ */ new Map());
1547
+ #singleLinks = new DefaultMap((_objectLocator) => /* @__PURE__ */ new Map());
1548
+ #manyLinks = new DefaultMap((_objectLocator) => new SetMultiMap());
1507
1549
  #fauxOntology;
1508
1550
  #attachments;
1509
- #timeSeriesData = new mnemonist.DefaultMap((_objectType) => new mnemonist.DefaultMap((_pk) => new mnemonist.DefaultMap((_property) => [])));
1510
- #propertySecurities = new mnemonist.DefaultMap((_objectLocator) => [{}]);
1511
- #media = new mnemonist.DefaultMap((_objectType) => new mnemonist.DefaultMap((_propName) => {
1551
+ #timeSeriesData = new DefaultMap((_objectType) => new DefaultMap((_pk) => new DefaultMap((_property) => [])));
1552
+ #propertySecurities = new DefaultMap((_objectLocator) => [{}]);
1553
+ #media = new DefaultMap((_objectType) => new DefaultMap((_propName) => {
1512
1554
  return /* @__PURE__ */ new Map();
1513
1555
  }));
1514
1556
  #strict;
@@ -3143,9 +3185,57 @@ var createObjectSetHandlers = (baseUrl, fauxFoundry) => [
3143
3185
  * Aggregate Objects in ObjectSet
3144
3186
  */
3145
3187
  OntologiesV2_exports2.OntologyObjectSets.aggregate(baseUrl, async ({
3146
- request
3188
+ request,
3189
+ params
3147
3190
  }) => {
3148
- throw new Error("Not implemented");
3191
+ const body = await request.json();
3192
+ const ds = fauxFoundry.getDataStore(params.ontologyApiName);
3193
+ const objects = getObjectsFromSet(ds, body.objectSet, void 0);
3194
+ const exactGroupBys = body.groupBy.filter((g) => g.type === "exact");
3195
+ if (exactGroupBys.length !== body.groupBy.length) {
3196
+ throw new Error("FauxFoundry aggregate: only 'exact' groupBy type is supported");
3197
+ }
3198
+ if (exactGroupBys.length === 0) {
3199
+ return {
3200
+ accuracy: "ACCURATE",
3201
+ data: [{
3202
+ group: {},
3203
+ metrics: [{
3204
+ name: "count",
3205
+ value: objects.length
3206
+ }]
3207
+ }]
3208
+ };
3209
+ }
3210
+ if (exactGroupBys.length > 1) {
3211
+ throw new Error(`FauxFoundry aggregate: multi-dimensional groupBy not yet implemented (got ${exactGroupBys.length} fields)`);
3212
+ }
3213
+ const {
3214
+ field,
3215
+ includeNullValues
3216
+ } = exactGroupBys[0];
3217
+ const groups = /* @__PURE__ */ new Map();
3218
+ for (const obj of objects) {
3219
+ const rawValue = obj[field];
3220
+ const key = rawValue == null ? null : String(rawValue);
3221
+ if (key == null && !includeNullValues) {
3222
+ continue;
3223
+ }
3224
+ groups.set(key, (groups.get(key) ?? 0) + 1);
3225
+ }
3226
+ const data = Array.from(groups.entries()).map(([key, count2]) => ({
3227
+ group: {
3228
+ [field]: key
3229
+ },
3230
+ metrics: [{
3231
+ name: "count",
3232
+ value: count2
3233
+ }]
3234
+ }));
3235
+ return {
3236
+ accuracy: "ACCURATE",
3237
+ data
3238
+ };
3149
3239
  }),
3150
3240
  /**
3151
3241
  * Load interface objectset Objects