@osdk/maker 0.14.0-beta.9 → 0.15.0-beta.1

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 (63) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/README.md +0 -1
  3. package/build/browser/api/code-snippets/createCodeSnippets.js +7 -4
  4. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
  5. package/build/browser/api/code-snippets/snippetTypes.js +1 -0
  6. package/build/browser/api/code-snippets/snippetTypes.js.map +1 -1
  7. package/build/browser/api/defineAction.js +6 -0
  8. package/build/browser/api/defineAction.js.map +1 -1
  9. package/build/browser/api/defineCreateInterfaceObjectAction.js +8 -7
  10. package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
  11. package/build/browser/api/defineModifyInterfaceObjectAction.js +8 -7
  12. package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
  13. package/build/browser/api/defineObject.js +1 -2
  14. package/build/browser/api/defineObject.js.map +1 -1
  15. package/build/browser/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
  16. package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
  17. package/build/browser/api/test/actions.test.js +1243 -1
  18. package/build/browser/api/test/actions.test.js.map +1 -1
  19. package/build/browser/api/test/misc.test.js +2 -2
  20. package/build/browser/api/test/misc.test.js.map +1 -1
  21. package/build/browser/api/test/spt.test.js +204 -105
  22. package/build/browser/api/test/spt.test.js.map +1 -1
  23. package/build/browser/cli/main.js +1 -1
  24. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
  25. package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  26. package/build/cjs/index.cjs +52 -1167
  27. package/build/cjs/index.cjs.map +1 -1
  28. package/build/cjs/index.d.cts +14 -5
  29. package/build/esm/api/code-snippets/createCodeSnippets.js +7 -4
  30. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
  31. package/build/esm/api/code-snippets/snippetTypes.js +1 -0
  32. package/build/esm/api/code-snippets/snippetTypes.js.map +1 -1
  33. package/build/esm/api/defineAction.js +6 -0
  34. package/build/esm/api/defineAction.js.map +1 -1
  35. package/build/esm/api/defineCreateInterfaceObjectAction.js +8 -7
  36. package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
  37. package/build/esm/api/defineModifyInterfaceObjectAction.js +8 -7
  38. package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
  39. package/build/esm/api/defineObject.js +1 -2
  40. package/build/esm/api/defineObject.js.map +1 -1
  41. package/build/esm/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
  42. package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
  43. package/build/esm/api/test/actions.test.js +1243 -1
  44. package/build/esm/api/test/actions.test.js.map +1 -1
  45. package/build/esm/api/test/misc.test.js +2 -2
  46. package/build/esm/api/test/misc.test.js.map +1 -1
  47. package/build/esm/api/test/spt.test.js +204 -105
  48. package/build/esm/api/test/spt.test.js.map +1 -1
  49. package/build/esm/cli/main.js +1 -1
  50. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
  51. package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
  52. package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -1
  53. package/build/types/api/code-snippets/snippetTypes.d.ts +1 -0
  54. package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -1
  55. package/build/types/api/defineAction.d.ts +3 -0
  56. package/build/types/api/defineAction.d.ts.map +1 -1
  57. package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
  58. package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
  59. package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts +1 -1
  60. package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts.map +1 -1
  61. package/build/types/api/properties/PropertyTypeType.d.ts +11 -4
  62. package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
  63. package/package.json +8 -6
@@ -9,6 +9,8 @@ var invariant7 = require('tiny-invariant');
9
9
  var yargs = require('yargs');
10
10
  var helpers = require('yargs/helpers');
11
11
  var fs2 = require('fs');
12
+ var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
13
+ var Mustache = require('mustache');
12
14
  var crypto = require('crypto');
13
15
 
14
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -36,6 +38,7 @@ var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
36
38
  var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
37
39
  var yargs__default = /*#__PURE__*/_interopDefault(yargs);
38
40
  var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
41
+ var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
39
42
 
40
43
  // src/cli/main.ts
41
44
 
@@ -343,7 +346,7 @@ function defineObject(objectDef) {
343
346
  const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
344
347
  !(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant7__default.default(false) : void 0;
345
348
  });
346
- const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(property.apiName ?? apiName2, property));
349
+ const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
347
350
  const finalObject = {
348
351
  ...objectDef,
349
352
  apiName,
@@ -383,7 +386,6 @@ function convertToPluralDisplayName(s) {
383
386
  return s === void 0 || s == null ? "" : s.endsWith("s") ? uppercaseFirstLetter(s) : uppercaseFirstLetter(s) + "s";
384
387
  }
385
388
  function convertUserObjectPropertyType(apiName, property) {
386
- property.apiName = apiName;
387
389
  property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);
388
390
  return {
389
391
  ...property,
@@ -782,14 +784,14 @@ function distributeTypeHelper(type) {
782
784
  // src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
783
785
  function propertyTypeTypeToOntologyIrType(type) {
784
786
  switch (true) {
785
- case (typeof type === "object" && "markingType" in type):
787
+ case (typeof type === "object" && type.type === "marking"):
786
788
  return {
787
789
  "type": "marking",
788
790
  marking: {
789
791
  markingType: type.markingType
790
792
  }
791
793
  };
792
- case (typeof type === "object" && "structDefinition" in type):
794
+ case (typeof type === "object" && type.type === "struct"):
793
795
  const structFields = new Array();
794
796
  for (const key in type.structDefinition) {
795
797
  const fieldTypeDefinition = type.structDefinition[key];
@@ -835,15 +837,24 @@ function propertyTypeTypeToOntologyIrType(type) {
835
837
  structFields
836
838
  }
837
839
  };
838
- case (typeof type === "object" && "isLongText" in type):
840
+ case (typeof type === "object" && type.type === "string"):
839
841
  return {
840
842
  "type": "string",
841
843
  "string": {
842
844
  analyzerOverride: void 0,
843
- enableAsciiFolding: void 0,
844
- isLongText: type.isLongText,
845
- supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard,
846
- supportsExactMatching: type.supportsExactMatching
845
+ enableAsciiFolding: type.enableAsciiFolding,
846
+ isLongText: type.isLongText ?? false,
847
+ supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard ?? false,
848
+ supportsExactMatching: type.supportsExactMatching ?? true,
849
+ supportsFullTextRegex: type.supportsFullTextRegex
850
+ }
851
+ };
852
+ case (typeof type === "object" && type.type === "decimal"):
853
+ return {
854
+ "type": "decimal",
855
+ "decimal": {
856
+ precision: type.precision,
857
+ scale: type.scale
847
858
  }
848
859
  };
849
860
  case type === "geopoint":
@@ -881,6 +892,9 @@ function propertyTypeTypeToOntologyIrType(type) {
881
892
  geotimeSeriesReference: {}
882
893
  };
883
894
  default:
895
+ if (typeof type === "object") {
896
+ throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
897
+ }
884
898
  return distributeTypeHelper(type);
885
899
  }
886
900
  }
@@ -1443,1139 +1457,6 @@ function getFormContentOrdering(action, parameterOrdering) {
1443
1457
  return formContentOrdering;
1444
1458
  }
1445
1459
 
1446
- // ../../node_modules/.pnpm/outdent@0.8.0/node_modules/outdent/lib-module/index.js
1447
- function noop() {
1448
- }
1449
- function createWeakMap() {
1450
- if (typeof WeakMap !== "undefined") {
1451
- return /* @__PURE__ */ new WeakMap();
1452
- } else {
1453
- return fakeSetOrMap();
1454
- }
1455
- }
1456
- function fakeSetOrMap() {
1457
- return {
1458
- add: noop,
1459
- delete: noop,
1460
- get: noop,
1461
- set: noop,
1462
- has: function(k) {
1463
- return false;
1464
- }
1465
- };
1466
- }
1467
- var hop = Object.prototype.hasOwnProperty;
1468
- var has = function(obj, prop) {
1469
- return hop.call(obj, prop);
1470
- };
1471
- function extend(target, source) {
1472
- for (var prop in source) {
1473
- if (has(source, prop)) {
1474
- target[prop] = source[prop];
1475
- }
1476
- }
1477
- return target;
1478
- }
1479
- var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
1480
- var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
1481
- var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
1482
- var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
1483
- var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
1484
- function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
1485
- var indentationLevel = 0;
1486
- var match = strings[0].match(reDetectIndentation);
1487
- if (match) {
1488
- indentationLevel = match[1].length;
1489
- }
1490
- var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
1491
- var reMatchIndent = new RegExp(reSource, "g");
1492
- if (firstInterpolatedValueSetsIndentationLevel) {
1493
- strings = strings.slice(1);
1494
- }
1495
- var newline = options.newline, trimLeadingNewline = options.trimLeadingNewline, trimTrailingNewline = options.trimTrailingNewline;
1496
- var normalizeNewlines = typeof newline === "string";
1497
- var l = strings.length;
1498
- var outdentedStrings = strings.map(function(v, i) {
1499
- v = v.replace(reMatchIndent, "$1");
1500
- if (i === 0 && trimLeadingNewline) {
1501
- v = v.replace(reLeadingNewline, "");
1502
- }
1503
- if (i === l - 1 && trimTrailingNewline) {
1504
- v = v.replace(reTrailingNewline, "");
1505
- }
1506
- if (normalizeNewlines) {
1507
- v = v.replace(/\r\n|\n|\r/g, function(_) {
1508
- return newline;
1509
- });
1510
- }
1511
- return v;
1512
- });
1513
- return outdentedStrings;
1514
- }
1515
- function concatStringsAndValues(strings, values) {
1516
- var ret = "";
1517
- for (var i = 0, l = strings.length; i < l; i++) {
1518
- ret += strings[i];
1519
- if (i < l - 1) {
1520
- ret += values[i];
1521
- }
1522
- }
1523
- return ret;
1524
- }
1525
- function isTemplateStringsArray(v) {
1526
- return has(v, "raw") && has(v, "length");
1527
- }
1528
- function createInstance(options) {
1529
- var arrayAutoIndentCache = createWeakMap();
1530
- var arrayFirstInterpSetsIndentCache = createWeakMap();
1531
- function outdent(stringsOrOptions) {
1532
- var values = [];
1533
- for (var _i = 1; _i < arguments.length; _i++) {
1534
- values[_i - 1] = arguments[_i];
1535
- }
1536
- if (isTemplateStringsArray(stringsOrOptions)) {
1537
- var strings = stringsOrOptions;
1538
- var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]);
1539
- var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
1540
- var renderedArray = cache.get(strings);
1541
- if (!renderedArray) {
1542
- renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
1543
- cache.set(strings, renderedArray);
1544
- }
1545
- if (values.length === 0) {
1546
- return renderedArray[0];
1547
- }
1548
- var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
1549
- return rendered;
1550
- } else {
1551
- return createInstance(extend(extend({}, options), stringsOrOptions || {}));
1552
- }
1553
- }
1554
- var fullOutdent = extend(outdent, {
1555
- string: function(str) {
1556
- return _outdentArray([str], false, options)[0];
1557
- }
1558
- });
1559
- return fullOutdent;
1560
- }
1561
- var defaultOutdent = createInstance({
1562
- trimLeadingNewline: true,
1563
- trimTrailingNewline: true
1564
- });
1565
- if (typeof module !== "undefined") {
1566
- try {
1567
- module.exports = defaultOutdent;
1568
- Object.defineProperty(defaultOutdent, "__esModule", {
1569
- value: true
1570
- });
1571
- defaultOutdent.default = defaultOutdent;
1572
- defaultOutdent.outdent = defaultOutdent;
1573
- } catch (e) {
1574
- }
1575
- }
1576
-
1577
- // ../../node_modules/.pnpm/@osdk+typescript-sdk-docs@0.2.0/node_modules/@osdk/typescript-sdk-docs/build/esm/generatedNoCheck/docsNoComputedVariables.js
1578
- var snippets = {
1579
- "kind": "sdk",
1580
- "versions": {
1581
- "1.0.0": {
1582
- "snippets": {
1583
- "loadSingleObjectGuide": [{
1584
- "template": 'import { type GetObjectError, isOk, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst result: Result<{{objectType}}, GetObjectError> = await client.ontology.objects.{{objectType}}.get("primaryKey");\nif (isOk(result)) {\n const object: {{objectType}} = result.value;\n} else {\n console.error(result.error.errorType);\n}'
1585
- }],
1586
- "loadObjectPageGuide": [{
1587
- "template": 'import { isOk, type LoadObjectSetError, Page, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst firstPage: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}.page({ pageSize: 30 });\n\nif (isOk(firstPage)) {\n const secondPage: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .page({ pageSize: 30, pageToken: firstPage.value.nextPageToken });\n\n const objects = isOk(secondPage) ? [...firstPage.value.data, ...secondPage.value.data] : firstPage.value.data;\n const object = objects[0];\n}'
1588
- }],
1589
- "orderObjectsGuide": [{
1590
- "template": 'import { isOk, Page, type Result, type SearchObjectsError } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst page: Result<Page<{{objectType}}>, SearchObjectsError> = await client.ontology.objects.{{objectType}}\n .orderBy(sortBy => sortBy.{{titleProperty}}.asc())\n .page({ pageSize: 30 });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1591
- }],
1592
- "searchObjectsGuide": [{
1593
- "template": 'import { isOk, type LoadObjectSetError, Page, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst page: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .where(query => query.{{titleProperty}}.isNull())\n .page({ pageSize: 30 });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1594
- }],
1595
- "loadSingleObjectReference": [{
1596
- "template": 'import { type GetObjectError, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst response: Result<{{objectType}}, GetObjectError> = await client.ontology.objects.{{objectType}}.get("primaryKey");'
1597
- }],
1598
- "loadObjectsReference": [{
1599
- "template": 'import { type LoadObjectSetError, Page, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst response: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .page({ pageSize: 30 });'
1600
- }],
1601
- "loadAllObjectsReference": [{
1602
- "template": 'import { isOk, type LoadObjectSetError, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objects: Result<{{objectType}}[], LoadObjectSetError> = await client.ontology.objects.{{objectType}}.all();\n\nif (isOk(objects)) {\n const object = objects.value[0];\n}'
1603
- }],
1604
- "loadLinkedObjectReference": [{
1605
- "template": 'import { type GetLinkedObjectError, type Result } from "{{{packageName}}}";\nimport { {{sourceObjectType}}, {{linkedObjectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getLinked{{linkedObjectType}}(source: {{sourceObjectType}}, linkedObjectPrimaryKey: {{linkedPrimaryKeyPropertyV1.type}}) {\n return source.{{linkApiName}}.get(linkedObjectPrimaryKey);\n}',
1606
- "computedVariables": ["linkedPrimaryKeyPropertyV1"]
1607
- }],
1608
- "loadLinkedObjectsReference": [{
1609
- "template": 'import { type GetLinkedObjectError, type Result } from "{{{packageName}}}";\nimport { {{sourceObjectType}}, {{linkedObjectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getLinked{{linkedObjectType}}(source: {{sourceObjectType}}) {\n {{#isLinkManySided}}\n return source.{{linkApiName}}.page({ pageSize: 30 });\n {{/isLinkManySided}}\n {{^isLinkManySided}}\n return source.{{linkApiName}}.get();\n {{/isLinkManySided}}\n}'
1610
- }],
1611
- "aggregationTemplate": [{
1612
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst num{{objectType}} = await client.ontology.objects.{{objectType}}\n .where(query => Op.not(query.{{property}}.isNull()))\n .groupBy(property => property.{{property}}.exact())\n .count()\n .compute()'
1613
- }],
1614
- "countAggregationTemplate": [{
1615
- "template": "const num{{objectType}} = await client.ontology.objects.{{objectType}}\n .count()\n .compute()"
1616
- }],
1617
- "approximateDistinctAggregationTemplate": [{
1618
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nconst distinct{{objectType}} = await client.ontology.objects.{{objectType}}\n .approximateDistinct(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses metricName as the metric name instead of the default "distinctCount"\nconst distinct{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.approximateDistinct(),\n }))\n .compute()'
1619
- }],
1620
- "exactDistinctAggregationTemplate": [{
1621
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nconst distinct{{objectType}} = await client.ontology.objects.{{objectType}}\n .exactDistinct(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses metricName as the metric name instead of the default "exactDistinctCount"\nconst distinct{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.exactDistinct(),\n }))\n .compute()'
1622
- }],
1623
- "numericAggregationTemplate": [{
1624
- "template": 'const {{operation}}{{objectType}} = await client.ontology.objects.{{objectType}}\n .{{operation}}(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses "metricName" as the metric name instead of the default "{{operation}}"\nconst {{operation}}{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.{{operation}}(),\n }))\n .compute()'
1625
- }],
1626
- "fixedWidthGroupByTemplate": [{
1627
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.fixedWidth(10))\n .count()\n .compute()"
1628
- }],
1629
- "durationGroupByTemplate": [{
1630
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.by{{duration}}({{#durationText}}{{arg}}{{/durationText}}))\n .count()\n .compute()"
1631
- }],
1632
- "exactGroupByTemplate": [{
1633
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.exact())\n .count()\n .compute()"
1634
- }],
1635
- "rangeGroupByTemplate": [{
1636
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.ranges([{\n startValue: {{propertyValueV1}},\n endValue: {{propertyValueIncrementedV1}}\n }]))\n .count()\n .compute()',
1637
- "computedVariables": ["propertyValueV1", "propertyValueIncrementedV1"]
1638
- }],
1639
- "applyAction": [{
1640
- "template": 'import { ActionValidationResult, ActionExecutionMode, ReturnEditsMode{{#hasAttachmentImports}}, Attachment{{/hasAttachmentImports}}{{#hasDateInputs}}, LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}, Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.actions.{{actionApiName}}({{^hasParameters}}{},{{/hasParameters}}{{#hasParameters}}{\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n},{{/hasParameters}} {\n mode: ActionExecutionMode.VALIDATE_AND_EXECUTE,\n returnEdits: ReturnEditsMode.ALL,\n }\n);\n// Check if http request was successful\nif (!isOk(result)) {\n throw result.error;\n}\n// Check if the validation was successful\nconsole.log(result.value.validation);\nif (result.value.validation.result === ActionValidationResult.VALID) {\n // If ReturnEditsMode.ALL is used, new and updated objects edits will contain the primary key of the object\n if (result.value.edits.type === "edits") {\n console.log(result.value.edits);\n }\n}',
1641
- "computedVariables": ["actionParameterSampleValuesV1"]
1642
- }],
1643
- "batchApplyAction": [{
1644
- "template": 'import { ActionExecutionMode, ReturnEditsMode{{#hasAttachmentImports}}, Attachment{{/hasAttachmentImports}}{{#hasDateInputs}}, LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}, Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.bulkActions.{{actionApiName}}(\n [\n {{^hasParameters}}{},{}{{/hasParameters}}{{#hasParameters}}{\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n },\n {\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n },{{/hasParameters}}\n ],\n {\n returnEdits: ReturnEditsMode.NONE,\n }\n);',
1645
- "computedVariables": ["actionParameterSampleValuesV1"]
1646
- }],
1647
- "uploadAttachment": [{
1648
- "template": 'import { type Result, isOk, Attachment, type AttachmentsError } from "{{{packageName}}}";\n\nasync function uploadMyFile() {\n const file = await fetch("file.json");\n const blob = await file.blob();\n return client.ontology.attachments.upload("myFile", blob);\n}\n\nconst result: Result<Attachment, AttachmentsError> = await uploadMyFile();\n\nif (isOk(result)) {\n const attachment = result.value;\n console.log(attachment);\n} else {\n console.error(result.error.errorType);\n}'
1649
- }],
1650
- "executeFunction": [{
1651
- "template": '{{#needsImports}}\nimport { {{#hasAttachmentImports}}Attachment{{#hasDateInputs}},{{/hasDateInputs}}{{^hasDateInputs}}{{#hasTimestampInputs}},{{/hasTimestampInputs}}{{/hasDateInputs}}{{/hasAttachmentImports}}{{#hasDateInputs}}LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{/needsImports}}\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.queries.{{funcApiName}}({{{functionInputValuesV1}}});',
1652
- "computedVariables": ["functionInputValuesV1"]
1653
- }],
1654
- "stringStartsWithTemplate": [{
1655
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.startsWith("foo"));'
1656
- }],
1657
- "containsAllTermsInOrderTemplate": [{
1658
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAllTermsInOrder("foo bar"));'
1659
- }],
1660
- "containsAnyTermTemplate": [{
1661
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAnyTerm("foo bar"));'
1662
- }],
1663
- "containsAllTermsTemplate": [{
1664
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAllTerms("foo bar"));'
1665
- }],
1666
- "equalityTemplate": [{
1667
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.eq({{{propertyValueV1}}}));',
1668
- "computedVariables": ["propertyValueV1"]
1669
- }],
1670
- "inFilterTemplate": [{
1671
- "template": "// Not supported"
1672
- }],
1673
- "nullTemplate": [{
1674
- "template": "const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.isNull());"
1675
- }],
1676
- "rangeTemplate": [{
1677
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{operation}}({{{propertyValueV1}}}));',
1678
- "computedVariables": ["propertyValueV1"]
1679
- }],
1680
- "withinDistanceTemplate": [{
1681
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.within{{distanceUnitText}}(\n // New York City\n GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n 100.0,\n ));'
1682
- }],
1683
- "withinBoundingBoxTemplate": [{
1684
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.withinBoundingBox({\n topLeft: GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n bottomRight: GeoPoint.fromCoordinates({ latitude: 25.123, longitude: 80.4231 }),\n });'
1685
- }],
1686
- "withinPolygonTemplate": [{
1687
- "template": 'import { Polygon } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.withinPolygon(Polygon.fromGeoJson({\n type: "Polygon",\n coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]],\n }));'
1688
- }],
1689
- "intersectsPolygonTemplate": [{
1690
- "template": 'import { Polygon } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{intersects}}Polygon(Polygon.fromGeoJson({\n type: "Polygon",\n coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]],\n }));'
1691
- }],
1692
- "intersectsBboxTemplate": [{
1693
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{intersects}}BoundingBox({\n topLeft: GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n bottomRight: GeoPoint.fromCoordinates({ latitude: 25.123, longitude: 80.4231 }),\n });'
1694
- }],
1695
- "notTemplate": [{
1696
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.not(query.{{primaryKeyPropertyV1.apiName}}.isNull()));',
1697
- "computedVariables": ["primaryKeyPropertyV1"]
1698
- }],
1699
- "andTemplate": [{
1700
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.and(\n Op.not(query.{{primaryKeyPropertyV1.apiName}}.isNull()),\n query.{{primaryKeyPropertyV1.apiName}}.eq("primaryKey"),\n ));',
1701
- "computedVariables": ["primaryKeyPropertyV1"]
1702
- }],
1703
- "orTemplate": [{
1704
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.or(\n query.{{primaryKeyPropertyV1.apiName}}.isNull(),\n query.{{primaryKeyPropertyV1.apiName}}.eq("primaryKey"),\n ));',
1705
- "computedVariables": ["primaryKeyPropertyV1"]
1706
- }],
1707
- "loadTimeSeriesPointsSnippet": [{
1708
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.points.all();\n}'
1709
- }],
1710
- "loadRelativeTimeSeriesPointsSnippet": [{
1711
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.from{{timeUnitValue}}Ago(1).all();\n}'
1712
- }],
1713
- "loadAbsoluteTimeSeriesPointsSnippet": [{
1714
- "template": 'import { Timestamp } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.range({\n startTime: Timestamp.fromISOString("2022-08-13T12:34:56Z"),\n endTime: Timestamp.fromISOString("2022-08-14T12:34:56Z"),\n });\n}'
1715
- }],
1716
- "loadTimeSeriesFirstPointSnippet": [{
1717
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getFirstPoint();\n}'
1718
- }],
1719
- "loadTimeSeriesLastPointSnippet": [{
1720
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getLastPoint();\n}'
1721
- }],
1722
- "loadObjectMetadataSnippet": [{
1723
- "template": "// Not supported."
1724
- }],
1725
- "subscribeToObjectSetInstructions": [{
1726
- "template": "// Subscribing to object sets is only supported in 2.x versions of the SDK."
1727
- }]
1728
- }
1729
- },
1730
- "1.1.0": {
1731
- "snippets": {
1732
- "loadSingleObjectGuide": [{
1733
- "template": 'import { type GetObjectError, isOk, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst result: Result<{{objectType}}, GetObjectError> = await client.ontology.objects.{{objectType}}.fetchOneWithErrors("primaryKey");\nif (isOk(result)) {\n const object: {{objectType}} = result.value;\n} else {\n console.error(result.error.errorType);\n}\n// You can also fetch a single object without the Result wrapper\ntry {\n const object: {{objectType}} = await client.ontology.objects.{{objectType}}.fetchOne("primaryKey");\n}\ncatch(e) {\n console.error(e);\n}'
1734
- }],
1735
- "loadObjectPageGuide": [{
1736
- "template": 'import { isOk, type LoadObjectSetError, Page, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst firstPage: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}.fetchPageWithErrors({ pageSize: 30 });\n\nif (isOk(firstPage)) {\n const secondPage: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .fetchPageWithErrors({ pageSize: 30, pageToken: firstPage.value.nextPageToken });\n\n const objects = isOk(secondPage) ? [...firstPage.value.data, ...secondPage.value.data] : firstPage.value.data;\n const object = objects[0];\n}\n\n// To fetch a page without a result wrapper, use fetchPage with a try/catch instead\ntry {\n const firstPage: Page<{{objectType}}> = await client.ontology.objects.{{objectType}}.fetchPage({ pageSize: 30 });\n const secondPage: Page<{{objectType}}> = await client.ontology.objects.{{objectType}}\n .fetchPage({ pageSize: 30, pageToken: firstPage.value.nextPageToken });\n const objects = [...firstPage.data, ...secondPage.data];\n const object = objects[0];\n}\ncatch (e) {\n console.error(e);\n}'
1737
- }],
1738
- "orderObjectsGuide": [{
1739
- "template": 'import { isOk, Page, type Result, type SearchObjectsError } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst page: Result<Page<{{objectType}}>, SearchObjectsError> = await client.ontology.objects.{{objectType}}\n .orderBy(sortBy => sortBy.{{titleProperty}}.asc())\n .fetchPageWithErrors({ pageSize: 30 });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1740
- }],
1741
- "searchObjectsGuide": [{
1742
- "template": 'import { isOk, type LoadObjectSetError, Page, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst page: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .where(query => query.{{titleProperty}}.isNull())\n .fetchPageWithErrors({ pageSize: 30 });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1743
- }],
1744
- "loadSingleObjectReference": [{
1745
- "template": 'import { type GetObjectError, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst response: Result<{{objectType}}, GetObjectError> = await client.ontology.objects.{{objectType}}.fetchOneWithErrors("primaryKey");\n\n// You can also fetch a single object without the result wrapper\nconst responseNoWrapper: {{objectType}} = await client.ontology.objects.{{objectType}}.fetchOne("primaryKey");\n'
1746
- }],
1747
- "loadObjectsReference": [{
1748
- "template": 'import type { LoadObjectSetError, Page, Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst response: Result<Page<{{objectType}}>, LoadObjectSetError> = await client.ontology.objects.{{objectType}}\n .fetchPageWithErrors({ pageSize: 30 });\n\n// To fetch a page without a result wrapper, use fetchPage instead\nconst responseNoErrorWrapper: Page<{{objectType}}> = await client.ontology.objects.{{objectType}}\n .fetchPage({ pageSize: 30 });'
1749
- }],
1750
- "loadAllObjectsReference": [{
1751
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objects: {{objectType}}[]= [];\n\nfor await(const obj of client.ontology.objects.{{objectType}}.asyncIter()) {\n objects.push(obj);\n}\nconst object = objects.value[0];'
1752
- }],
1753
- "loadLinkedObjectReference": [{
1754
- "template": 'import type { GetLinkedObjectError, Result } from "{{{packageName}}}";\nimport { {{sourceObjectType}}, {{linkedObjectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getLinked{{linkedObjectType}}(source: {{sourceObjectType}}, linkedObjectPrimaryKey: {{linkedPrimaryKeyPropertyV1.type}}): Result<{{linkedObjectType}}, GetLinkedObjectError>\n{\n return source.{{linkApiName}}.fetchOneWithErrors(linkedObjectPrimaryKey);\n}\n\n// You can also get a linked object without the result wrapper\nfunction getLinkedNoWrapper{{linkedObjectType}}(source: {{sourceObjectType}}, linkedObjectPrimaryKey: {{linkedPrimaryKeyPropertyV1.type}}): {{linkedObjectType}} {\n return source.{{linkApiName}}.fetchOne(linkedObjectPrimaryKey);\n}',
1755
- "computedVariables": ["linkedPrimaryKeyPropertyV1"]
1756
- }],
1757
- "loadLinkedObjectsReference": [{
1758
- "template": 'import type { GetLinkedObjectError, Result } from "{{{packageName}}}";\nimport { {{sourceObjectType}}, {{linkedObjectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getLinked{{linkedObjectType}}(source: {{sourceObjectType}}) {\n {{#isLinkManySided}}\n return source.{{linkApiName}}.fetchPageWithErrors({ pageSize: 30 });\n {{/isLinkManySided}}\n {{^isLinkManySided}}\n return source.{{linkApiName}}.fetchOneWithErrors();\n {{/isLinkManySided}}\n}'
1759
- }],
1760
- "aggregationTemplate": [{
1761
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst num{{objectType}} = await client.ontology.objects.{{objectType}}\n .where(query => Op.not(query.{{property}}.isNull()))\n .groupBy(property => property.{{property}}.exact())\n .count()\n .compute()'
1762
- }],
1763
- "countAggregationTemplate": [{
1764
- "template": "const num{{objectType}} = await client.ontology.objects.{{objectType}}\n .count()\n .compute()"
1765
- }],
1766
- "approximateDistinctAggregationTemplate": [{
1767
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nconst distinct{{objectType}} = await client.ontology.objects.{{objectType}}\n .approximateDistinct(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses metricName as the metric name instead of the default "distinctCount"\nconst distinct{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.approximateDistinct(),\n }))\n .compute()'
1768
- }],
1769
- "exactDistinctAggregationTemplate": [{
1770
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nconst distinct{{objectType}} = await client.ontology.objects.{{objectType}}\n .exactDistinct(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses metricName as the metric name instead of the default "exactDistinctCount"\nconst distinct{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.exactDistinct(),\n }))\n .compute()'
1771
- }],
1772
- "numericAggregationTemplate": [{
1773
- "template": 'const {{operation}}{{objectType}} = await client.ontology.objects.{{objectType}}\n .{{operation}}(obj => obj.{{property}})\n .compute()\n\n// This is equivalent to the above, but uses "metricName" as the metric name instead of the default "{{operation}}"\nconst {{operation}}{{objectType}}CustomName = await client.ontology.objects.{{objectType}}\n .aggregate(obj => ({\n metricName: obj.{{property}}.{{operation}}(),\n }))\n .compute()'
1774
- }],
1775
- "fixedWidthGroupByTemplate": [{
1776
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.fixedWidth(10))\n .count()\n .compute()"
1777
- }],
1778
- "durationGroupByTemplate": [{
1779
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.by{{duration}}({{#durationText}}{{arg}}{{/durationText}}))\n .count()\n .compute()"
1780
- }],
1781
- "exactGroupByTemplate": [{
1782
- "template": "const grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.exact())\n .count()\n .compute()"
1783
- }],
1784
- "rangeGroupByTemplate": [{
1785
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst grouped{{objectType}} = await client.ontology.objects.{{objectType}}\n .groupBy(obj => obj.{{property}}.ranges([{\n startValue: {{propertyValueV1}},\n endValue: {{propertyValueIncrementedV1}}\n }]))\n .count()\n .compute()',
1786
- "computedVariables": ["propertyValueV1", "propertyValueIncrementedV1"]
1787
- }],
1788
- "applyAction": [{
1789
- "template": 'import { ActionValidationResult, ActionExecutionMode, ReturnEditsMode{{#hasAttachmentImports}}, Attachment{{/hasAttachmentImports}}{{#hasDateInputs}}, LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}, Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.actions.{{actionApiName}}({{^hasParameters}}{},{{/hasParameters}}{{#hasParameters}}{\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n},{{/hasParameters}} {\n mode: ActionExecutionMode.VALIDATE_AND_EXECUTE,\n returnEdits: ReturnEditsMode.ALL,\n }\n);\n// Check if http request was successful\nif (!isOk(result)) {\n throw result.error;\n}\n// Check if the validation was successful\nconsole.log(result.value.validation);\nif (result.value.validation.result === ActionValidationResult.VALID) {\n // If ReturnEditsMode.ALL is used, new and updated objects edits will contain the primary key of the object\n if (result.value.edits.type === "edits") {\n console.log(result.value.edits);\n }\n}',
1790
- "computedVariables": ["actionParameterSampleValuesV1"]
1791
- }],
1792
- "batchApplyAction": [{
1793
- "template": 'import { ActionExecutionMode, ReturnEditsMode{{#hasAttachmentImports}}, Attachment{{/hasAttachmentImports}}{{#hasDateInputs}}, LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}, Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.batchActions.{{actionApiName}}(\n [\n {{^hasParameters}}{},{}{{/hasParameters}}{{#hasParameters}}{\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n },\n {\n {{#actionParameterSampleValuesV1}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV1}}\n },{{/hasParameters}}\n ],\n {\n returnEdits: ReturnEditsMode.NONE,\n }\n);',
1794
- "computedVariables": ["actionParameterSampleValuesV1"]
1795
- }],
1796
- "uploadAttachment": [{
1797
- "template": 'import { type Result, isOk, type Attachment, type AttachmentsError } from "{{{packageName}}}";\n\nasync function uploadMyFile() {\n const file = await fetch("file.json");\n const blob = await file.blob();\n return client.ontology.attachments.upload("myFile", blob);\n}\n\nconst result: Result<Attachment, AttachmentsError> = await uploadMyFile();\n\nif (isOk(result)) {\n const attachment = result.value;\n console.log(attachment);\n} else {\n console.error(result.error.errorType);\n}'
1798
- }],
1799
- "executeFunction": [{
1800
- "template": '{{#needsImports}}\nimport { {{#hasAttachmentImports}}Attachment{{#hasDateInputs}},{{/hasDateInputs}}{{^hasDateInputs}}{{#hasTimestampInputs}},{{/hasTimestampInputs}}{{/hasDateInputs}}{{/hasAttachmentImports}}{{#hasDateInputs}}LocalDate{{#hasTimestampInputs}}, {{/hasTimestampInputs}}{{/hasDateInputs}}{{#hasTimestampInputs}}Timestamp{{/hasTimestampInputs}} } from "{{{packageName}}}";\n\n{{/needsImports}}\n{{#hasAttachmentUpload}}\nconst attachment: Attachment = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client.ontology.queries.{{funcApiName}}({{{functionInputValuesV1}}});',
1801
- "computedVariables": ["functionInputValuesV1"]
1802
- }],
1803
- "stringStartsWithTemplate": [{
1804
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.startsWith("foo"));'
1805
- }],
1806
- "containsAllTermsInOrderTemplate": [{
1807
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAllTermsInOrder("foo bar"));'
1808
- }],
1809
- "containsAnyTermTemplate": [{
1810
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAnyTerm("foo bar"));'
1811
- }],
1812
- "containsAllTermsTemplate": [{
1813
- "template": 'const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.containsAllTerms("foo bar"));'
1814
- }],
1815
- "equalityTemplate": [{
1816
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.eq({{{propertyValueV1}}}));',
1817
- "computedVariables": ["propertyValueV1"]
1818
- }],
1819
- "inFilterTemplate": [{
1820
- "template": "// Not supported"
1821
- }],
1822
- "nullTemplate": [{
1823
- "template": "const {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.isNull());"
1824
- }],
1825
- "rangeTemplate": [{
1826
- "template": '{{#isDateProperty}}\nimport { LocalDate } from "{{{packageName}}}";\n\n{{/isDateProperty}}\n{{#isTimestampProperty}}\nimport { Timestamp } from "{{{packageName}}}";\n\n{{/isTimestampProperty}}\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{operation}}({{{propertyValueV1}}}));',
1827
- "computedVariables": ["propertyValueV1"]
1828
- }],
1829
- "withinDistanceTemplate": [{
1830
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.within{{distanceUnitText}}(\n // New York City\n GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n 100.0,\n ));'
1831
- }],
1832
- "withinBoundingBoxTemplate": [{
1833
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.withinBoundingBox({\n topLeft: GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n bottomRight: GeoPoint.fromCoordinates({ latitude: 25.123, longitude: 80.4231 }),\n });'
1834
- }],
1835
- "withinPolygonTemplate": [{
1836
- "template": 'import { Polygon } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.withinPolygon(Polygon.fromGeoJson({\n type: "Polygon",\n coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]],\n }));'
1837
- }],
1838
- "intersectsPolygonTemplate": [{
1839
- "template": 'import { Polygon } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{intersects}}Polygon(Polygon.fromGeoJson({\n type: "Polygon",\n coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]],\n }));'
1840
- }],
1841
- "intersectsBboxTemplate": [{
1842
- "template": 'import { GeoPoint } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => query.{{property}}.{{intersects}}BoundingBox({\n topLeft: GeoPoint.fromCoordinates({ latitude: 40.7128, longitude: -74.0060 }),\n bottomRight: GeoPoint.fromCoordinates({ latitude: 25.123, longitude: 80.4231 }),\n });'
1843
- }],
1844
- "notTemplate": [{
1845
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.not(query.{{primaryKeyPropertyV1.apiName}}.isNull()));',
1846
- "computedVariables": ["primaryKeyPropertyV1"]
1847
- }],
1848
- "andTemplate": [{
1849
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.and(\n Op.not(query.{{primaryKeyPropertyV1.apiName}}.isNull()),\n query.{{primaryKeyPropertyV1.apiName}}.eq("primaryKey"),\n ));',
1850
- "computedVariables": ["primaryKeyPropertyV1"]
1851
- }],
1852
- "orTemplate": [{
1853
- "template": 'import { Op } from "{{{packageName}}}";\n\nconst {{objectType}}ObjectSet = client.ontology.objects.{{objectType}}\n .where(query => Op.or(\n query.{{primaryKeyPropertyV1.apiName}}.isNull(),\n query.{{primaryKeyPropertyV1.apiName}}.eq("primaryKey"),\n ));',
1854
- "computedVariables": ["primaryKeyPropertyV1"]
1855
- }],
1856
- "loadTimeSeriesPointsSnippet": [{
1857
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.points.all();\n}'
1858
- }],
1859
- "loadRelativeTimeSeriesPointsSnippet": [{
1860
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.from{{timeUnitValue}}Ago(1).all();\n}'
1861
- }],
1862
- "loadAbsoluteTimeSeriesPointsSnippet": [{
1863
- "template": 'import { Timestamp } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.range({\n startTime: Timestamp.fromISOString("2022-08-13T12:34:56Z"),\n endTime: Timestamp.fromISOString("2022-08-14T12:34:56Z"),\n });\n}'
1864
- }],
1865
- "loadTimeSeriesFirstPointSnippet": [{
1866
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getFirstPoint();\n}'
1867
- }],
1868
- "loadTimeSeriesLastPointSnippet": [{
1869
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getLastPoint();\n}'
1870
- }],
1871
- "loadObjectMetadataSnippet": [{
1872
- "template": "// Not supported."
1873
- }],
1874
- "subscribeToObjectSetInstructions": [{
1875
- "template": "// Subscribing to object sets is only supported in 2.x versions of the SDK."
1876
- }]
1877
- }
1878
- },
1879
- "2.0.0": {
1880
- "snippets": {
1881
- "loadSingleObjectGuide": [{
1882
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type Result } from "@osdk/client";\n\nconst result: Result<Osdk.Instance<{{objectType}}>> = await client({{objectType}}).fetchOneWithErrors("<primaryKey>");\nif (isOk(result)) {\n const object: Osdk.Instance<{{objectType}}> = result.value;\n} else {\n console.error(result.error.message);\n}\n// You can also fetch a single object without the Result wrapper\ntry {\n const object: Osdk.Instance<{{objectType}}> = await client({{objectType}}).fetchOne("<primaryKey>");\n}\ncatch(e) {\n console.error(e);\n}'
1883
- }],
1884
- "loadObjectPageGuide": [{
1885
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst firstPage: Result<PageResult<Osdk.Instance<{{objectType}}>>>\n = await client({{objectType}}).fetchPageWithErrors({ $pageSize: 30 });\n\nif (isOk(firstPage)) {\n const secondPage: Result<PageResult<Osdk.Instance<{{objectType}}, never, "{{titleProperty}}">>>\n // You can also down select properties to only get the properties you need from the object\n = await client({{objectType}}).fetchPageWithErrors({ $select: ["{{titleProperty}}"], $pageSize: 30, $nextPageToken: firstPage.value.nextPageToken });\n\n const objects = isOk(secondPage) ? [...firstPage.value.data, ...secondPage.value.data] : firstPage.value.data;\n const object = objects[0];\n}\n\n // If you want to get rids, you need to add a flag to specifically request for it. Note how the return type now includes $rid rather than never\nconst secondPageWithRids: Result<PageResult<Osdk.Instance<{{objectType}}, "$rid", "{{titleProperty}}">>>\n = await client({{objectType}}).fetchPageWithErrors({ $select: ["{{titleProperty}}"], $includeRid:true, $pageSize: 30, $nextPageToken: firstPage.value.nextPageToken });\n\n// To fetch a page without a result wrapper, use fetchPage with a try/catch instead\ntry {\n const firstPage: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30 });\n const secondPage: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30, $nextPageToken: firstPage.nextPageToken });\n const objects = [...firstPage.data, ...secondPage.data];\n const object = objects[0];\n}\ncatch (e) {\n console.error(e);\n}'
1886
- }],
1887
- "orderObjectsGuide": [{
1888
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst page: Result<PageResult<Osdk.Instance<{{objectType}}>>> = await client({{objectType}})\n .fetchPageWithErrors({\n $orderBy: {"{{titleProperty}}": "asc"},\n $pageSize: 30\n });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1889
- }],
1890
- "searchObjectsGuide": [{
1891
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst page: Result<PageResult<Osdk.Instance<{{objectType}}>>> = await client({{objectType}})\n .where({\n {{titleProperty}}: {$isNull: true}\n })\n .fetchPageWithErrors({\n $pageSize: 30\n });\n\nif (isOk(page)) {\n const objects = page.value.data;\n const object = objects[0];\n}'
1892
- }],
1893
- "loadSingleObjectReference": [{
1894
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { Osdk, Result } from "@osdk/client";\n\nconst response: Result<Osdk.Instance<{{objectType}}>> = await client({{objectType}}).fetchOneWithErrors("<primaryKey>");\n\n// You can also fetch a single object without the Result wrapper\n\nconst responseNoErrorWrapper: Osdk.Instance<{{objectType}}> = await client({{objectType}}).fetchOne("<primaryKey>");\n\n'
1895
- }],
1896
- "loadObjectsReference": [{
1897
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { Osdk, PageResult, Result } from "@osdk/client";\n\nconst response: Result<PageResult<Osdk.Instance<{{objectType}}>>>\n = await client({{objectType}}).fetchPageWithErrors({ $pageSize: 30 });\n\n// To fetch a page without a result wrapper, use fetchPage instead\nconst responseNoErrorWrapper: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30 });\n'
1898
- }],
1899
- "loadAllObjectsReference": [{
1900
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { Osdk } from "@osdk/client";\n\nconst objects: Osdk.Instance<{{objectType}}>[]= [];\n\nfor await(const obj of client({{objectType}}).asyncIter()) {\n objects.push(obj);\n}\nconst object = objects[0];'
1901
- }],
1902
- "loadLinkedObjectReference": [{
1903
- "template": 'import { {{sourceObjectType}}, {{linkedObjectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type Result } from "@osdk/client";\n\nfunction getLinked{{linkedObjectType}}(source: Osdk.Instance<{{sourceObjectType}}>, linkedObjectPrimaryKey: {{linkedPrimaryKeyPropertyV2.type}}): Result<Osdk.Instance<{{linkedObjectType}}>>\n{\n return source.$link.{{linkApiName}}.fetchOneWithErrors(linkedObjectPrimaryKey);\n}\n\n// You can also get a linked object without the result wrapper\nfunction getLinkedNoWrapper{{linkedObjectType}}(source: Osdk.Instance<{{sourceObjectType}}>, linkedObjectPrimaryKey: {{linkedPrimaryKeyPropertyV2.type}}): Osdk.Instance<{{linkedObjectType}}> {\n return source.$link.{{linkApiName}}.fetchOne(linkedObjectPrimaryKey);\n}',
1904
- "computedVariables": ["linkedPrimaryKeyPropertyV2"]
1905
- }],
1906
- "loadLinkedObjectsReference": [{
1907
- "template": 'import { {{linkedObjectType}} } from "{{{packageName}}}";\n\nfunction getLinked{{linkedObjectType}}(source: Osdk.Instance<{{sourceObjectType}}>) {\n {{#isLinkManySided}}\n return source.$link.{{linkApiName}}.fetchPageWithErrors({ $pageSize: 30 });\n {{/isLinkManySided}}\n {{^isLinkManySided}}\n return source.$link.{{linkApiName}}.fetchOneWithErrors();\n {{/isLinkManySided}}\n}'
1908
- }],
1909
- "aggregationTemplate": [{
1910
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst num{{objectType}} = await client({{objectType}})\n .where({{property}}: { $isNull : false })\n .aggregate({\n $select: { $count: "unordered" },\n $groupBy: { name: "exact" },\n });'
1911
- }],
1912
- "countAggregationTemplate": [{
1913
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst num{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: {$count: "unordered"},\n });'
1914
- }],
1915
- "approximateDistinctAggregationTemplate": [{
1916
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst distinct{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { "{{property}}:approximateDistinct" : "unordered" },\n });'
1917
- }],
1918
- "exactDistinctAggregationTemplate": [{
1919
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst distinct{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { "{{property}}:exactDistinct" : "unordered" },\n });'
1920
- }],
1921
- "numericAggregationTemplate": [{
1922
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{operation}}{{objectType}} = await client({{objectType}})\n .aggregation({\n $select: { "{{property}}:{{operation}}" : "unordered" }\n });'
1923
- }],
1924
- "fixedWidthGroupByTemplate": [{
1925
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst grouped{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { $count: "unordered" },\n $groupBy: { {{property}} : { $fixedWidth: 10 } }\n });'
1926
- }],
1927
- "durationGroupByTemplate": [{
1928
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst grouped{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { $count: "unordered" },\n $groupBy: { {{property}} : $duration: [ {{#durationText}}{{arg}}{{/durationText}}, "{{#durationText}}{{unit}}{{/durationText}}"] }\n })'
1929
- }],
1930
- "exactGroupByTemplate": [{
1931
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst grouped{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { $count: "unordered" },\n $groupBy: { {{property}} : "exact" }\n })'
1932
- }],
1933
- "rangeGroupByTemplate": [{
1934
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst grouped{{objectType}} = await client({{objectType}})\n .aggregate({\n $select: { $count: "unordered" },\n $groupBy: { {{property}} : { $ranges: [[{{{propertyValueV2}}}, {{{propertyValueIncrementedV2}}} ]]} }\n });',
1935
- "computedVariables": ["propertyValueV2", "propertyValueIncrementedV2"]
1936
- }],
1937
- "applyAction": [{
1938
- "template": 'import { {{actionApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentImports}}import type { AttachmentUpload } from "@osdk/api";{{/hasAttachmentImports}}{{#hasMediaParameter}}import type { MediaReference } from "@osdk/api";{{/hasMediaParameter}}\n\n\n{{#hasAttachmentUpload}}\nconst attachment: AttachmentUpload = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\n{{#hasMediaParameter}}\nconst mediaReference: MediaReference = uploadMedia();\n{{/hasMediaParameter}}\nconst result = await client({{actionApiName}}).applyAction(\n{{^hasParameters}}{},\n{{/hasParameters}}{{#hasParameters}}\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV2}}\n },{{/hasParameters}}\n {\n $returnEdits: true,\n }\n);\n\nif (result.type === "edits") {\n // for new objects and updated objects edits will contain the primary key of the object\n const updatedObject = result.editedObjectTypes[0];\n console.log("Updated object", updatedObject);\n}',
1939
- "computedVariables": ["actionParameterSampleValuesV2"]
1940
- }],
1941
- "batchApplyAction": [{
1942
- "template": 'import { {{actionApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentImports}}\nimport type { AttachmentUpload } from "@osdk/api";\n{{/hasAttachmentImports}}{{#hasMediaParameter}}import type { MediaReference } from "@osdk/api";{{/hasMediaParameter}}\n\n\n{{#hasAttachmentUpload}}\nconst attachment: AttachmentUpload = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\n{{#hasMediaParameter}}\nconst mediaReference: MediaReference = uploadMedia();\n{{/hasMediaParameter}}\nconst result = await client({{actionApiName}}).batchApplyAction(\n [\n {{^hasParameters}}{},{}{{/hasParameters}}{{#hasParameters}}\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV2}}\n },\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}}{{^last}}, {{/last}}\n {{/actionParameterSampleValuesV2}}\n },{{/hasParameters}}\n ],\n {\n $returnEdits: false,\n }\n);',
1943
- "computedVariables": ["actionParameterSampleValuesV2"]
1944
- }],
1945
- "uploadAttachment": [{
1946
- "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Result, isOk } from "@osdk/client";\nimport type { AttachmentUpload } from "@osdk/api";\n\n// To upload an attachment with 2.0, it has to be linked to an action call\n\nasync function uploadMyFile() {\n const file = await fetch("file.json");\n const blob = await file.blob();\n return createAttachmentUpload(blob, "myFile");\n}\n\nconst myAttachmentUpload: AttachmentUpload = await uploadMyFile();\n\nconst actionResult = client(attachmentUploadingAction).applyAction({ attachment: myAttachmentUpload });\n'
1947
- }],
1948
- "castInterfaceToObjectReference": [{
1949
- "template": 'import { {{objectTypeApiName}}, {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk } from "@osdk/client";\n\nconst page = await client({{interfaceApiName}}).fetchPageWithErrors();\n\nif (isOk(page)) {\n const interfaces = page.value.data;\n const {{interfaceApiNameCamelCase}}: Osdk<{{interfaceApiName}}> = interfaces[0];\n\n // Cast from interface to object type\n const {{objectTypeApiNameCamelCase}}: Osdk<{{objectTypeApiName}}> = {{interfaceApiNameCamelCase}}.$as({{objectTypeApiName}});\n // Or from object type back to interface\n const {{interfaceApiNameCamelCase}}2: Osdk<{{interfaceApiName}}> = {{objectTypeApiNameCamelCase}}.$as({{interfaceApiName}});\n}'
1950
- }],
1951
- "executeFunction": [{
1952
- "template": '{{#needsImports}}\nimport { {{funcApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentImports}}import type { AttachmentUpload } from "@osdk/api";{{/hasAttachmentImports}}\n\n{{/needsImports}}\n{{#hasAttachmentUpload}}\nconst attachment: AttachmentUpload = uploadMyFile();\n{{/hasAttachmentUpload}}\n{{#attachmentProperty}}\nconst attachment: Attachment = {{{attachmentProperty}}};\n{{/attachmentProperty}}\nconst result = await client({{funcApiName}}).executeFunction({{{functionInputValuesV2}}});',
1953
- "computedVariables": ["functionInputValuesV2"]
1954
- }],
1955
- "stringStartsWithTemplate": [{
1956
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $startsWith: "foo" }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}} : { $startsWith: "foo" }\n {{/structSubPropertyApiName}}\n })'
1957
- }],
1958
- "containsAllTermsInOrderTemplate": [{
1959
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $containsAllTermsInOrder: "foo bar" }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}} : { $containsAllTermsInOrder: "foo bar" }\n {{/structSubPropertyApiName}}\n })'
1960
- }],
1961
- "containsAnyTermTemplate": [{
1962
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $containsAnyTerm: "foo bar" }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}} : { $containsAnyTerm: "foo bar" }\n {{/structSubPropertyApiName}}\n })'
1963
- }],
1964
- "containsAllTermsTemplate": [{
1965
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $containsAllTerms: "foo bar" }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}} : { $containsAllTerms: "foo bar" }\n {{/structSubPropertyApiName}}\n })'
1966
- }],
1967
- "equalityTemplate": [{
1968
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $eq: {{{propertyValueV2}}} }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $eq: {{{propertyValueV2}}} }\n {{/structSubPropertyApiName}}\n });',
1969
- "computedVariables": ["propertyValueV2"]
1970
- }],
1971
- "inFilterTemplate": [{
1972
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $in: [{{{propertyValueV2}}}] }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $in: [{{{propertyValueV2}}}] }\n {{/structSubPropertyApiName}}\n });',
1973
- "computedVariables": ["propertyValueV2"]
1974
- }],
1975
- "nullTemplate": [{
1976
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $isNull: true }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $isNull: true }\n {{/structSubPropertyApiName}}\n });'
1977
- }],
1978
- "rangeTemplate": [{
1979
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { ${{operation}}: {{{propertyValueV2}}} }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { ${{operation}}: {{{propertyValueV2}}} }\n {{/structSubPropertyApiName}}\n });',
1980
- "computedVariables": ["propertyValueV2"]
1981
- }],
1982
- "withinDistanceTemplate": [{
1983
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $within: { $distance: [100, "{{distanceUnit}}"], $of: [-74.0060, 40.7128]} }}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $within: { $distance: [100, "{{distanceUnit}}"], $of: [-74.0060, 40.7128]}}\n {{/structSubPropertyApiName}}\n })'
1984
- }],
1985
- "withinBoundingBoxTemplate": [{
1986
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $within: { $bbox: [-74.0060, 25.123, 80.4231, 40.7128]}}}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $within: { $bbox: [-74.0060, 25.123, 80.4231, 40.7128]}}\n {{/structSubPropertyApiName}}\n\n });'
1987
- }],
1988
- "withinPolygonTemplate": [{
1989
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $within: { type: "Polygon", coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]]}}}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $within: { type: "Polygon", coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]]}}\n {{/structSubPropertyApiName}}\n });'
1990
- }],
1991
- "intersectsPolygonTemplate": [{
1992
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}}: { $intersects: { type: "Polygon", coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]}}}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}}: { $intersects: { type: "Polygon", coordinates: [[[10.0, 40.0], [20.0, 50.0], [20.0, 30.0], [10.0, 40.0]]}}\n {{/structSubPropertyApiName}}\n });'
1993
- }],
1994
- "intersectsBboxTemplate": [{
1995
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({\n {{#structSubPropertyApiName}}\n {{property}}: { {{structSubPropertyApiName}} : { $intersects: { $bbox: [-74.0060, 25.123, 80.4231, 40.7128]}}}\n {{/structSubPropertyApiName}}\n {{^structSubPropertyApiName}}\n {{property}} : { $intersects: { $bbox: [-74.0060, 25.123, 80.4231, 40.7128]}}\n {{/structSubPropertyApiName}}\n });'
1996
- }],
1997
- "notTemplate": [{
1998
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({ $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}});',
1999
- "computedVariables": ["primaryKeyPropertyV2"]
2000
- }],
2001
- "andTemplate": [{
2002
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({ $and:[\n { $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}},\n { {{primaryKeyPropertyV2.apiName}}: { $eq: "<primaryKey>" }}\n ]});',
2003
- "computedVariables": ["primaryKeyPropertyV2"]
2004
- }],
2005
- "orTemplate": [{
2006
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}ObjectSet = client({{objectType}})\n .where({ $or:[\n { $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}},\n { {{primaryKeyPropertyV2.apiName}}: { $eq: "<primaryKey>" }}\n ]});',
2007
- "computedVariables": ["primaryKeyPropertyV2"]
2008
- }],
2009
- "containsTemplate": [{
2010
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst filteredObjects = client({{objectType}})\n .where({\n {{property}} : { $contains: {{{arrayElementValue}}} }\n })',
2011
- "computedVariables": ["arrayElementValue"]
2012
- }],
2013
- "loadInterfacesReference": [{
2014
- "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst response: Result<PageResult<Osdk<{{interfaceApiName}}>>>\n = await client({{interfaceApiName}}).fetchPageWithErrors({ $pageSize: 30 });\n\n// To fetch a page without a result wrapper, use fetchPage instead\nconst responseNoErrorWrapper: PageResult<Osdk<{{interfaceApiName}}>>\n = await client({{interfaceApiName}}).fetchPage({ $pageSize: 30 });'
2015
- }],
2016
- "loadAllInterfacesReference": [{
2017
- "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { Osdk } from "@osdk/client";\n\nconst interfaces: Osdk<{{interfaceApiName}}>[] = [];\n\nfor await(const int of client({{interfaceApiName}}).asyncIter()) {\n interfaces.push(int);\n}\nconst interface1 = interfaces[0];'
2018
- }],
2019
- "loadOrderedInterfacesReference": [{
2020
- "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst page: Result<PageResult<Osdk<{{interfaceApiName}}>>> = await client({{interfaceApiName}})\n .fetchPageWithErrors({\n $orderBy: {"someProperty": "asc"},\n $pageSize: 30\n });\n\nif (isOk(page)) {\n const interfaces = page.value.data;\n const interface1 = interfaces[0];\n}'
2021
- }],
2022
- "searchInterfacesReference": [{
2023
- "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { isOk, type Osdk, type PageResult, type Result } from "@osdk/client";\n\nconst page: Result<PageResult<Osdk<{{interfaceApiName}}>>> = await client({{interfaceApiName}})\n .where({\n $and:[\n { $not: { someProperty: { $isNull: true }}},\n { someProperty: { $eq: "foo" }}\n ]\n })\n .fetchPageWithErrors({\n $pageSize: 30\n });\n\nif (isOk(page)) {\n const interfaces = page.value.data;\n const interface1 = interfaces[0];\n}'
2024
- }],
2025
- "loadTimeSeriesPointsSnippet": [{
2026
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllPoints();\n}'
2027
- }],
2028
- "loadRelativeTimeSeriesPointsSnippet": [{
2029
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllPoints({\n $before: 1,\n $unit: "{{timeUnit}}",\n })\n}'
2030
- }],
2031
- "loadAbsoluteTimeSeriesPointsSnippet": [{
2032
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAbsoluteTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllPoints({\n $startTime: "2022-08-13T12:34:56Z",\n $endTime: "2022-08-14T12:34:56Z",\n });\n}'
2033
- }],
2034
- "loadTimeSeriesFirstPointSnippet": [{
2035
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getFirstTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getFirstPoint();\n}'
2036
- }],
2037
- "loadTimeSeriesLastPointSnippet": [{
2038
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLastPoint();\n}'
2039
- }],
2040
- "loadGeotimeSeriesPointsSnippet": [{
2041
- "template": "// Upgrade to 2.1 for official support"
2042
- }],
2043
- "loadRelativeGeotimeSeriesPointsSnippet": [{
2044
- "template": "// Upgrade to 2.1 for official support"
2045
- }],
2046
- "loadAbsoluteGeotimeSeriesPointsSnippet": [{
2047
- "template": "// Upgrade to 2.1 for official support"
2048
- }],
2049
- "loadGeotimeSeriesLastPointSnippet": [{
2050
- "template": "// Upgrade to 2.1 for official support"
2051
- }],
2052
- "loadObjectMetadataSnippet": [{
2053
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst objectTypeMetadata = await client.fetchMetadata({{objectType}});\n\nif (objectTypeMetadata.icon.type === "blueprint") {\n const blueprintIconName = objectTypeMetadata.icon.name;\n}\nconst currentVisibility = objectTypeMetadata.visibility;\nconst currentDescription = objectTypeMetadata.description;'
2054
- }],
2055
- "loadInterfaceMetadataSnippet": [{
2056
- "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst interfaceTypeMetadata = await client.fetchMetadata({{interfaceApiName}});\n\nconst implementingObjectTypes = interfaceTypeMetadata.implementedBy;\nconst interfaceRid = interfaceTypeMetadata.rid;'
2057
- }],
2058
- "subscribeToObjectSetInstructions": [{
2059
- "template": "// Upgrade to 2.1 for official support"
2060
- }],
2061
- "uploadMedia": [{
2062
- "template": "// Upgrade to 2.1 for official support"
2063
- }],
2064
- "readMedia": [{
2065
- "template": "// Upgrade to 2.1 for official support"
2066
- }],
2067
- "derivedPropertyBaseExample": [{
2068
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("fooLink").pivotTo("barLink").selectProperty("foo")\n })\n .where({\n "newPropertyName": { $gt: 10 }\n })\n .aggregate({\n $select: { "newPropertyName:max": "unordered" }\n });'
2069
- }],
2070
- "derivedPropertyApproximateDistinctAggregation": [{
2071
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:approximateDistinct")\n })'
2072
- }],
2073
- "derivedPropertyExactDistinctAggregation": [{
2074
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:exactDistinct")\n })'
2075
- }],
2076
- "derivedPropertyCollectToListAggregation": [{
2077
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:collectToList", 75)\n })'
2078
- }],
2079
- "derivedPropertyCollectToSetAggregation": [{
2080
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:collectToSet", 75)\n })'
2081
- }],
2082
- "derivedPropertyCountAggregation": [{
2083
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("$count")\n })'
2084
- }],
2085
- "derivedPropertySelectPropertyAggregation": [{
2086
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").selectProperty("{{property}}")\n })'
2087
- }],
2088
- "derivedPropertyApproximatePercentileAggregation": [{
2089
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:approximatePercentile", 0.5)\n })'
2090
- }],
2091
- "derivedPropertyNumericAggregation": [{
2092
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:{{operation}}")\n })'
2093
- }],
2094
- "objectSetOperationsGuide": [{
2095
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objectSetA = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "a"}})\nconst objectSetB = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "b"}})\nconst objectSetC = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "c"}})\n\n// Object set operations can be chained. e.g. To find all objects in objectSetA \n// that are present in objectSetB but do not exist in objectSetC:\nconst result = objectSetA\n .intersect(objectSetB)\n .subtract(objectSetC);'
2096
- }],
2097
- "objectSetOperationsUnion": [{
2098
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objectSetA = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "a"}})\nconst objectSetB = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "b"}})\nconst objectSetC = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "c"}})\n\n// Combine objectSetA, objectSetB and objectSetC\nconst result = objectSetA\n .union(objectSetB)\n .union(objectSetC); // alternatively: objectSetA.union(objectSetB, objectSetC)'
2099
- }],
2100
- "objectSetOperationsSubtract": [{
2101
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objectSetA = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "a"}})\nconst objectSetB = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "b"}})\nconst objectSetC = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "c"}})\n\n\n// Return objects in objectSetA that are not present in either objectSetB or objectSetC\nconst result = objectSetA\n .subtract(objectSetB)\n .subtract(objectSetC); // alternatively: objectSetA.subtract(objectSetB, objectSetC)'
2102
- }],
2103
- "objectSetOperationsIntersect": [{
2104
- "template": 'import { {{objectType}} } from "{{{packageName}}}/ontology/objects";\n\nconst objectSetA = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "a"}})\nconst objectSetB = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "b"}})\nconst objectSetC = client({{objectType}}).where({ {{titleProperty}}: { $containsAnyTerm: "c"}})\n\n\n// Return all objects common to objectSetA, objectSetB and objectSetC\nconst result = objectSetA\n .intersect(objectSetB)\n .intersect(objectSetC); // alternatively: objectSetA.intersect(objectSetB, objectSetC)'
2105
- }],
2106
- "searchAround": [{
2107
- "template": 'import { {{sourceObjectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\n// Object set containing objects a, b and c\nconst objects = client({{sourceObjectType}})\n .where({ {{rawLinkedPrimaryKeyProperty.apiName}}: { $in: ["a", "b", "c"]}});\n\n// Traverse the selected link type to find all objects of type\n// {{linkedObjectType}} linked to objects a, b and c\nconst linkedObjects = await objects.pivotTo("{{linkApiName}}");'
2108
- }]
2109
- }
2110
- },
2111
- "2.1.0": {
2112
- "snippets": {
2113
- "loadGeotimeSeriesPointsSnippet": [{
2114
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllValues();\n}'
2115
- }],
2116
- "loadRelativeGeotimeSeriesPointsSnippet": [{
2117
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllValues({\n $before: 1,\n $unit: "{{timeUnit}}",\n })\n}'
2118
- }],
2119
- "loadAbsoluteGeotimeSeriesPointsSnippet": [{
2120
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAbsoluteTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllValues({\n $startTime: "2022-08-13T12:34:56Z",\n $endTime: "2022-08-14T12:34:56Z",\n });\n}'
2121
- }],
2122
- "loadGeotimeSeriesLastPointSnippet": [{
2123
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLatestValue();\n}'
2124
- }],
2125
- "subscribeToObjectSetInstructions": [{
2126
- "template": 'import { {{objectOrInterfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\n// A map of primary keys to objects loaded through the SDK\nconst objects: { [key: string]: {{objectOrInterfaceApiName}}.OsdkInstance } = ...\n\nconst subscription = client({{objectOrInterfaceApiName}}).subscribe( {\n onChange(update) {\n if (update.state === "ADDED_OR_UPDATED") {\n // An object has received an update or an object was added to the object set\n const currentObject = objects[update.object.$primaryKey];\n if (currentObject !== undefined) {\n currentObject["<propertyName>"] = update.object["<propertyName>"] ?? currentObject["<propertyName>"];\n }\n }\n else if (update.state === "REMOVED") {\n // The object was removed from the object set, which could mean it was deleted or no longer meets the filter criteria\n delete objects[update.object.$primaryKey];\n }\n },\n onSuccessfulSubscription() {\n // The subscription was successful and you can expect to receive updates\n },\n onError(err) {\n // There was an error with the subscription and you will not receive any more updates\n console.error(err);\n },\n onOutOfDate() {\n // We could not keep track of all changes. Please reload the objects in your set.\n },\n },\n { properties: [ {{#propertyNames}}"{{.}}", {{/propertyNames}}\b\b]}\n );\n\nsubscription.unsubscribe();'
2127
- }],
2128
- "uploadMedia": [{
2129
- "template": 'import { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference } from "@osdk/api/unstable";\nimport { {{objectType}} } from "{{{packageName}}}"\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { Result, isOk } from "@osdk/client";\nimport type { MediaReference } from "@osdk/api";\n\n// To upload media with 2.x, it has to be linked to an Action call\nasync function uploadMedia() {\n const file = await fetch("file.json");\n const data = await file.blob();\n\n // Upload media to an object type with a media property. This returns a media reference that can passed to\n // a media parameter in an Action.\n return await client(\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n ).createMediaReference({\n data,\n fileName: "myFile",\n objectType: {{objectType}},\n propertyType: "MediaPropertyApi",\n });\n}\n\nconst mediaReference: MediaReference = await uploadMedia();\nconst actionResult = client(mediaUploadingAction).applyAction({ media_parameter: mediaReference });'
2130
- }],
2131
- "readMedia": [{
2132
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { MediaMetadata, MediaReference } from "@osdk/api";\nimport { Osdk, Result } from "@osdk/client";\n\nconst result = await client({{objectType}}).fetchOne("<primaryKey>");\n\n// Fetch metadata of a media property\nconst mediaMetadata = await result.{{property}}?.fetchMetadata();\n\n// Fetch contents of a media property\nconst response = await result.{{property}}?.fetchContents();\n\nif (response.ok) {\n const data = await response.blob();\n ...\n}'
2133
- }]
2134
- }
2135
- }
2136
- }
2137
- };
2138
- var TYPESCRIPT_OSDK_SNIPPETS = {
2139
- ...snippets};
2140
-
2141
- // ../../node_modules/.pnpm/mustache@4.2.0/node_modules/mustache/mustache.mjs
2142
- var objectToString = Object.prototype.toString;
2143
- var isArray = Array.isArray || function isArrayPolyfill(object) {
2144
- return objectToString.call(object) === "[object Array]";
2145
- };
2146
- function isFunction(object) {
2147
- return typeof object === "function";
2148
- }
2149
- function typeStr(obj) {
2150
- return isArray(obj) ? "array" : typeof obj;
2151
- }
2152
- function escapeRegExp(string) {
2153
- return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
2154
- }
2155
- function hasProperty(obj, propName) {
2156
- return obj != null && typeof obj === "object" && propName in obj;
2157
- }
2158
- function primitiveHasOwnProperty(primitive, propName) {
2159
- return primitive != null && typeof primitive !== "object" && primitive.hasOwnProperty && primitive.hasOwnProperty(propName);
2160
- }
2161
- var regExpTest = RegExp.prototype.test;
2162
- function testRegExp(re, string) {
2163
- return regExpTest.call(re, string);
2164
- }
2165
- var nonSpaceRe = /\S/;
2166
- function isWhitespace(string) {
2167
- return !testRegExp(nonSpaceRe, string);
2168
- }
2169
- var entityMap = {
2170
- "&": "&amp;",
2171
- "<": "&lt;",
2172
- ">": "&gt;",
2173
- '"': "&quot;",
2174
- "'": "&#39;",
2175
- "/": "&#x2F;",
2176
- "`": "&#x60;",
2177
- "=": "&#x3D;"
2178
- };
2179
- function escapeHtml(string) {
2180
- return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
2181
- return entityMap[s];
2182
- });
2183
- }
2184
- var whiteRe = /\s*/;
2185
- var spaceRe = /\s+/;
2186
- var equalsRe = /\s*=/;
2187
- var curlyRe = /\s*\}/;
2188
- var tagRe = /#|\^|\/|>|\{|&|=|!/;
2189
- function parseTemplate(template, tags) {
2190
- if (!template) return [];
2191
- var lineHasNonSpace = false;
2192
- var sections = [];
2193
- var tokens = [];
2194
- var spaces = [];
2195
- var hasTag = false;
2196
- var nonSpace = false;
2197
- var indentation = "";
2198
- var tagIndex = 0;
2199
- function stripSpace() {
2200
- if (hasTag && !nonSpace) {
2201
- while (spaces.length) delete tokens[spaces.pop()];
2202
- } else {
2203
- spaces = [];
2204
- }
2205
- hasTag = false;
2206
- nonSpace = false;
2207
- }
2208
- var openingTagRe, closingTagRe, closingCurlyRe;
2209
- function compileTags(tagsToCompile) {
2210
- if (typeof tagsToCompile === "string") tagsToCompile = tagsToCompile.split(spaceRe, 2);
2211
- if (!isArray(tagsToCompile) || tagsToCompile.length !== 2) throw new Error("Invalid tags: " + tagsToCompile);
2212
- openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + "\\s*");
2213
- closingTagRe = new RegExp("\\s*" + escapeRegExp(tagsToCompile[1]));
2214
- closingCurlyRe = new RegExp("\\s*" + escapeRegExp("}" + tagsToCompile[1]));
2215
- }
2216
- compileTags(tags || mustache.tags);
2217
- var scanner = new Scanner(template);
2218
- var start, type, value, chr, token, openSection;
2219
- while (!scanner.eos()) {
2220
- start = scanner.pos;
2221
- value = scanner.scanUntil(openingTagRe);
2222
- if (value) {
2223
- for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
2224
- chr = value.charAt(i);
2225
- if (isWhitespace(chr)) {
2226
- spaces.push(tokens.length);
2227
- indentation += chr;
2228
- } else {
2229
- nonSpace = true;
2230
- lineHasNonSpace = true;
2231
- indentation += " ";
2232
- }
2233
- tokens.push(["text", chr, start, start + 1]);
2234
- start += 1;
2235
- if (chr === "\n") {
2236
- stripSpace();
2237
- indentation = "";
2238
- tagIndex = 0;
2239
- lineHasNonSpace = false;
2240
- }
2241
- }
2242
- }
2243
- if (!scanner.scan(openingTagRe)) break;
2244
- hasTag = true;
2245
- type = scanner.scan(tagRe) || "name";
2246
- scanner.scan(whiteRe);
2247
- if (type === "=") {
2248
- value = scanner.scanUntil(equalsRe);
2249
- scanner.scan(equalsRe);
2250
- scanner.scanUntil(closingTagRe);
2251
- } else if (type === "{") {
2252
- value = scanner.scanUntil(closingCurlyRe);
2253
- scanner.scan(curlyRe);
2254
- scanner.scanUntil(closingTagRe);
2255
- type = "&";
2256
- } else {
2257
- value = scanner.scanUntil(closingTagRe);
2258
- }
2259
- if (!scanner.scan(closingTagRe)) throw new Error("Unclosed tag at " + scanner.pos);
2260
- if (type == ">") {
2261
- token = [type, value, start, scanner.pos, indentation, tagIndex, lineHasNonSpace];
2262
- } else {
2263
- token = [type, value, start, scanner.pos];
2264
- }
2265
- tagIndex++;
2266
- tokens.push(token);
2267
- if (type === "#" || type === "^") {
2268
- sections.push(token);
2269
- } else if (type === "/") {
2270
- openSection = sections.pop();
2271
- if (!openSection) throw new Error('Unopened section "' + value + '" at ' + start);
2272
- if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
2273
- } else if (type === "name" || type === "{" || type === "&") {
2274
- nonSpace = true;
2275
- } else if (type === "=") {
2276
- compileTags(value);
2277
- }
2278
- }
2279
- stripSpace();
2280
- openSection = sections.pop();
2281
- if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
2282
- return nestTokens(squashTokens(tokens));
2283
- }
2284
- function squashTokens(tokens) {
2285
- var squashedTokens = [];
2286
- var token, lastToken;
2287
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
2288
- token = tokens[i];
2289
- if (token) {
2290
- if (token[0] === "text" && lastToken && lastToken[0] === "text") {
2291
- lastToken[1] += token[1];
2292
- lastToken[3] = token[3];
2293
- } else {
2294
- squashedTokens.push(token);
2295
- lastToken = token;
2296
- }
2297
- }
2298
- }
2299
- return squashedTokens;
2300
- }
2301
- function nestTokens(tokens) {
2302
- var nestedTokens = [];
2303
- var collector = nestedTokens;
2304
- var sections = [];
2305
- var token, section;
2306
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
2307
- token = tokens[i];
2308
- switch (token[0]) {
2309
- case "#":
2310
- case "^":
2311
- collector.push(token);
2312
- sections.push(token);
2313
- collector = token[4] = [];
2314
- break;
2315
- case "/":
2316
- section = sections.pop();
2317
- section[5] = token[2];
2318
- collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
2319
- break;
2320
- default:
2321
- collector.push(token);
2322
- }
2323
- }
2324
- return nestedTokens;
2325
- }
2326
- function Scanner(string) {
2327
- this.string = string;
2328
- this.tail = string;
2329
- this.pos = 0;
2330
- }
2331
- Scanner.prototype.eos = function eos() {
2332
- return this.tail === "";
2333
- };
2334
- Scanner.prototype.scan = function scan(re) {
2335
- var match = this.tail.match(re);
2336
- if (!match || match.index !== 0) return "";
2337
- var string = match[0];
2338
- this.tail = this.tail.substring(string.length);
2339
- this.pos += string.length;
2340
- return string;
2341
- };
2342
- Scanner.prototype.scanUntil = function scanUntil(re) {
2343
- var index = this.tail.search(re), match;
2344
- switch (index) {
2345
- case -1:
2346
- match = this.tail;
2347
- this.tail = "";
2348
- break;
2349
- case 0:
2350
- match = "";
2351
- break;
2352
- default:
2353
- match = this.tail.substring(0, index);
2354
- this.tail = this.tail.substring(index);
2355
- }
2356
- this.pos += match.length;
2357
- return match;
2358
- };
2359
- function Context(view, parentContext) {
2360
- this.view = view;
2361
- this.cache = {
2362
- ".": this.view
2363
- };
2364
- this.parent = parentContext;
2365
- }
2366
- Context.prototype.push = function push(view) {
2367
- return new Context(view, this);
2368
- };
2369
- Context.prototype.lookup = function lookup(name) {
2370
- var cache = this.cache;
2371
- var value;
2372
- if (cache.hasOwnProperty(name)) {
2373
- value = cache[name];
2374
- } else {
2375
- var context = this, intermediateValue, names, index, lookupHit = false;
2376
- while (context) {
2377
- if (name.indexOf(".") > 0) {
2378
- intermediateValue = context.view;
2379
- names = name.split(".");
2380
- index = 0;
2381
- while (intermediateValue != null && index < names.length) {
2382
- if (index === names.length - 1) lookupHit = hasProperty(intermediateValue, names[index]) || primitiveHasOwnProperty(intermediateValue, names[index]);
2383
- intermediateValue = intermediateValue[names[index++]];
2384
- }
2385
- } else {
2386
- intermediateValue = context.view[name];
2387
- lookupHit = hasProperty(context.view, name);
2388
- }
2389
- if (lookupHit) {
2390
- value = intermediateValue;
2391
- break;
2392
- }
2393
- context = context.parent;
2394
- }
2395
- cache[name] = value;
2396
- }
2397
- if (isFunction(value)) value = value.call(this.view);
2398
- return value;
2399
- };
2400
- function Writer() {
2401
- this.templateCache = {
2402
- _cache: {},
2403
- set: function set(key, value) {
2404
- this._cache[key] = value;
2405
- },
2406
- get: function get(key) {
2407
- return this._cache[key];
2408
- },
2409
- clear: function clear() {
2410
- this._cache = {};
2411
- }
2412
- };
2413
- }
2414
- Writer.prototype.clearCache = function clearCache() {
2415
- if (typeof this.templateCache !== "undefined") {
2416
- this.templateCache.clear();
2417
- }
2418
- };
2419
- Writer.prototype.parse = function parse(template, tags) {
2420
- var cache = this.templateCache;
2421
- var cacheKey = template + ":" + (tags || mustache.tags).join(":");
2422
- var isCacheEnabled = typeof cache !== "undefined";
2423
- var tokens = isCacheEnabled ? cache.get(cacheKey) : void 0;
2424
- if (tokens == void 0) {
2425
- tokens = parseTemplate(template, tags);
2426
- isCacheEnabled && cache.set(cacheKey, tokens);
2427
- }
2428
- return tokens;
2429
- };
2430
- Writer.prototype.render = function render(template, view, partials, config) {
2431
- var tags = this.getConfigTags(config);
2432
- var tokens = this.parse(template, tags);
2433
- var context = view instanceof Context ? view : new Context(view, void 0);
2434
- return this.renderTokens(tokens, context, partials, template, config);
2435
- };
2436
- Writer.prototype.renderTokens = function renderTokens(tokens, context, partials, originalTemplate, config) {
2437
- var buffer = "";
2438
- var token, symbol, value;
2439
- for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
2440
- value = void 0;
2441
- token = tokens[i];
2442
- symbol = token[0];
2443
- if (symbol === "#") value = this.renderSection(token, context, partials, originalTemplate, config);
2444
- else if (symbol === "^") value = this.renderInverted(token, context, partials, originalTemplate, config);
2445
- else if (symbol === ">") value = this.renderPartial(token, context, partials, config);
2446
- else if (symbol === "&") value = this.unescapedValue(token, context);
2447
- else if (symbol === "name") value = this.escapedValue(token, context, config);
2448
- else if (symbol === "text") value = this.rawValue(token);
2449
- if (value !== void 0) buffer += value;
2450
- }
2451
- return buffer;
2452
- };
2453
- Writer.prototype.renderSection = function renderSection(token, context, partials, originalTemplate, config) {
2454
- var self = this;
2455
- var buffer = "";
2456
- var value = context.lookup(token[1]);
2457
- function subRender(template) {
2458
- return self.render(template, context, partials, config);
2459
- }
2460
- if (!value) return;
2461
- if (isArray(value)) {
2462
- for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
2463
- buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate, config);
2464
- }
2465
- } else if (typeof value === "object" || typeof value === "string" || typeof value === "number") {
2466
- buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate, config);
2467
- } else if (isFunction(value)) {
2468
- if (typeof originalTemplate !== "string") throw new Error("Cannot use higher-order sections without the original template");
2469
- value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
2470
- if (value != null) buffer += value;
2471
- } else {
2472
- buffer += this.renderTokens(token[4], context, partials, originalTemplate, config);
2473
- }
2474
- return buffer;
2475
- };
2476
- Writer.prototype.renderInverted = function renderInverted(token, context, partials, originalTemplate, config) {
2477
- var value = context.lookup(token[1]);
2478
- if (!value || isArray(value) && value.length === 0) return this.renderTokens(token[4], context, partials, originalTemplate, config);
2479
- };
2480
- Writer.prototype.indentPartial = function indentPartial(partial, indentation, lineHasNonSpace) {
2481
- var filteredIndentation = indentation.replace(/[^ \t]/g, "");
2482
- var partialByNl = partial.split("\n");
2483
- for (var i = 0; i < partialByNl.length; i++) {
2484
- if (partialByNl[i].length && (i > 0 || !lineHasNonSpace)) {
2485
- partialByNl[i] = filteredIndentation + partialByNl[i];
2486
- }
2487
- }
2488
- return partialByNl.join("\n");
2489
- };
2490
- Writer.prototype.renderPartial = function renderPartial(token, context, partials, config) {
2491
- if (!partials) return;
2492
- var tags = this.getConfigTags(config);
2493
- var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
2494
- if (value != null) {
2495
- var lineHasNonSpace = token[6];
2496
- var tagIndex = token[5];
2497
- var indentation = token[4];
2498
- var indentedValue = value;
2499
- if (tagIndex == 0 && indentation) {
2500
- indentedValue = this.indentPartial(value, indentation, lineHasNonSpace);
2501
- }
2502
- var tokens = this.parse(indentedValue, tags);
2503
- return this.renderTokens(tokens, context, partials, indentedValue, config);
2504
- }
2505
- };
2506
- Writer.prototype.unescapedValue = function unescapedValue(token, context) {
2507
- var value = context.lookup(token[1]);
2508
- if (value != null) return value;
2509
- };
2510
- Writer.prototype.escapedValue = function escapedValue(token, context, config) {
2511
- var escape = this.getConfigEscape(config) || mustache.escape;
2512
- var value = context.lookup(token[1]);
2513
- if (value != null) return typeof value === "number" && escape === mustache.escape ? String(value) : escape(value);
2514
- };
2515
- Writer.prototype.rawValue = function rawValue(token) {
2516
- return token[1];
2517
- };
2518
- Writer.prototype.getConfigTags = function getConfigTags(config) {
2519
- if (isArray(config)) {
2520
- return config;
2521
- } else if (config && typeof config === "object") {
2522
- return config.tags;
2523
- } else {
2524
- return void 0;
2525
- }
2526
- };
2527
- Writer.prototype.getConfigEscape = function getConfigEscape(config) {
2528
- if (config && typeof config === "object" && !isArray(config)) {
2529
- return config.escape;
2530
- } else {
2531
- return void 0;
2532
- }
2533
- };
2534
- var mustache = {
2535
- name: "mustache.js",
2536
- version: "4.2.0",
2537
- tags: ["{{", "}}"],
2538
- clearCache: void 0,
2539
- escape: void 0,
2540
- parse: void 0,
2541
- render: void 0,
2542
- Scanner: void 0,
2543
- Context: void 0,
2544
- Writer: void 0,
2545
- /**
2546
- * Allows a user to override the default caching strategy, by providing an
2547
- * object with set, get and clear methods. This can also be used to disable
2548
- * the cache by setting it to the literal `undefined`.
2549
- */
2550
- set templateCache(cache) {
2551
- defaultWriter.templateCache = cache;
2552
- },
2553
- /**
2554
- * Gets the default or overridden caching object from the default writer.
2555
- */
2556
- get templateCache() {
2557
- return defaultWriter.templateCache;
2558
- }
2559
- };
2560
- var defaultWriter = new Writer();
2561
- mustache.clearCache = function clearCache2() {
2562
- return defaultWriter.clearCache();
2563
- };
2564
- mustache.parse = function parse2(template, tags) {
2565
- return defaultWriter.parse(template, tags);
2566
- };
2567
- mustache.render = function render2(template, view, partials, config) {
2568
- if (typeof template !== "string") {
2569
- throw new TypeError('Invalid template! Template should be a "string" but "' + typeStr(template) + '" was given as the first argument for mustache#render(template, view, partials)');
2570
- }
2571
- return defaultWriter.render(template, view, partials, config);
2572
- };
2573
- mustache.escape = escapeHtml;
2574
- mustache.Scanner = Scanner;
2575
- mustache.Context = Context;
2576
- mustache.Writer = Writer;
2577
- var mustache_default = mustache;
2578
-
2579
1460
  // src/api/code-snippets/snippetTypes.ts
2580
1461
  var interfaceSnippets = /* @__PURE__ */ (function(interfaceSnippets2) {
2581
1462
  interfaceSnippets2[interfaceSnippets2["loadInterfacesReference"] = 0] = "loadInterfacesReference";
@@ -2603,6 +1484,7 @@ var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
2603
1484
  objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
2604
1485
  return objectSnippets2;
2605
1486
  })({});
1487
+ var snippetNameMapping = /* @__PURE__ */ new Map([["loadInterfaceMetadataSnippet", "Load {{interfaceName}} metadata"], ["loadInterfacesReference", "Load pages of {{interfaceName}}"], ["loadAllInterfacesReference", "Load all {{interfaceName}}"], ["loadOrderedInterfacesReference", "Load ordered {{interfaceName}}"], ["searchInterfacesReference", "Filtering"], ["subscribeToObjectSetInstructions", "Subscribe to object sets"]]);
2606
1488
 
2607
1489
  // src/api/code-snippets/createCodeSnippets.ts
2608
1490
  function createCodeSnippets(ontology, packageName, outputDir) {
@@ -2644,7 +1526,8 @@ function generateInterfaceSnippet(interfaceType, packageName) {
2644
1526
  "interfaceApiName": interfaceType.apiName,
2645
1527
  "packageName": packageName,
2646
1528
  "objectOrInterfaceApiName": interfaceType.apiName,
2647
- "propertyNames": Object.keys(interfaceType.propertiesV2)
1529
+ "propertyNames": Object.keys(interfaceType.propertiesV2),
1530
+ "interfaceName": interfaceType.displayMetadata.displayName
2648
1531
  };
2649
1532
  return getSnippets(interfaceSnippets, interfaceContext);
2650
1533
  }
@@ -2666,9 +1549,11 @@ function generateActionSnippet(actionType, packageName) {
2666
1549
  function getSnippets(snippetType, context) {
2667
1550
  const allSnippets = {};
2668
1551
  for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
2669
- const latestTemplate = Object.values(TYPESCRIPT_OSDK_SNIPPETS.versions).find((v) => v.snippets[templateName])?.snippets[templateName][0].template ?? "";
2670
- const renderedTemplate = mustache_default.render(latestTemplate, context);
2671
- allSnippets[templateName] = renderedTemplate;
1552
+ const versions = Object.values(typescriptSdkDocs.TYPESCRIPT_OSDK_SNIPPETS.versions);
1553
+ const latestTemplate = versions.slice().reverse().find((v) => v.snippets[templateName])?.snippets[templateName].at(-1)?.template ?? "";
1554
+ const renderedTemplate = Mustache__default.default.render(latestTemplate, context);
1555
+ const snippetName = snippetNameMapping.get(templateName);
1556
+ allSnippets[snippetName !== void 0 ? Mustache__default.default.render(snippetName, context) : templateName] = renderedTemplate;
2672
1557
  }
2673
1558
  return allSnippets;
2674
1559
  }
@@ -3155,7 +2040,7 @@ function addNamespaceIfNone(apiName) {
3155
2040
  var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
3156
2041
  var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
3157
2042
  async function main(args = process.argv) {
3158
- const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.9").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
2043
+ const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.15.0-beta.1").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
3159
2044
  input: {
3160
2045
  alias: "i",
3161
2046
  describe: "Input file",
@@ -3853,8 +2738,14 @@ function addNamespaceToActionDefinition(def) {
3853
2738
  }));
3854
2739
  }
3855
2740
  function getInterfaceParameterName(def, parameter) {
2741
+ if (def.useNonNamespacedParameters) {
2742
+ return getNonNamespacedParameterName(def, parameter);
2743
+ }
3856
2744
  return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
3857
2745
  }
2746
+ function getNonNamespacedParameterName(def, parameter) {
2747
+ return def.conflictingParameterOverrides?.[parameter] ?? (parameter.split(".").pop() || parameter);
2748
+ }
3858
2749
  function convertMappingValue(value) {
3859
2750
  switch (value.type) {
3860
2751
  case "uuid":
@@ -3884,8 +2775,9 @@ function defineCreateInterfaceObjectAction(def) {
3884
2775
  addNamespaceToActionDefinition(def);
3885
2776
  const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
3886
2777
  validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
3887
- const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
3888
- const parameterNames = new Set(propertyParameters);
2778
+ const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
2779
+ const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
2780
+ const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
3889
2781
  Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
3890
2782
  parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
3891
2783
  const actionApiName = def.apiName ?? `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
@@ -3895,7 +2787,7 @@ function defineCreateInterfaceObjectAction(def) {
3895
2787
  }
3896
2788
  validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
3897
2789
  }
3898
- const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
2790
+ const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
3899
2791
  const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
3900
2792
  return defineAction({
3901
2793
  apiName: actionApiName,
@@ -3914,15 +2806,15 @@ function defineCreateInterfaceObjectAction(def) {
3914
2806
  interfaceApiName: def.interfaceType.apiName,
3915
2807
  objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
3916
2808
  sharedPropertyValues: {
3917
- ...Object.fromEntries(propertyParameters.map((id) => [id, {
2809
+ ...Object.fromEntries(sptNames.map((id) => [id, {
3918
2810
  type: "parameterId",
3919
- parameterId: id
2811
+ parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
3920
2812
  }])),
3921
2813
  ...mappings
3922
2814
  }
3923
2815
  }
3924
2816
  }],
3925
- parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
2817
+ parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
3926
2818
  ...def.actionLevelValidation ? {
3927
2819
  validation: convertValidationRule(def.actionLevelValidation, parameters)
3928
2820
  } : {},
@@ -4373,8 +3265,9 @@ function defineModifyInterfaceObjectAction(def) {
4373
3265
  addNamespaceToActionDefinition(def);
4374
3266
  const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
4375
3267
  validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
4376
- const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
4377
- const parameterNames = new Set(propertyParameters);
3268
+ const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
3269
+ const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
3270
+ const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
4378
3271
  Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
4379
3272
  parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
4380
3273
  const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
@@ -4384,7 +3277,7 @@ function defineModifyInterfaceObjectAction(def) {
4384
3277
  }
4385
3278
  validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
4386
3279
  }
4387
- const parameters = createParameters(def, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.sharedPropertyType])), parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
3280
+ const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
4388
3281
  const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
4389
3282
  return defineAction({
4390
3283
  apiName: actionApiName,
@@ -4402,15 +3295,15 @@ function defineModifyInterfaceObjectAction(def) {
4402
3295
  modifyInterfaceRule: {
4403
3296
  interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
4404
3297
  sharedPropertyValues: {
4405
- ...Object.fromEntries(propertyParameters.map((id) => [id, {
3298
+ ...Object.fromEntries(sptNames.map((id) => [id, {
4406
3299
  type: "parameterId",
4407
- parameterId: id
3300
+ parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
4408
3301
  }])),
4409
3302
  ...mappings
4410
3303
  }
4411
3304
  }
4412
3305
  }],
4413
- parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
3306
+ parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
4414
3307
  ...def.actionLevelValidation ? {
4415
3308
  validation: convertValidationRule(def.actionLevelValidation, parameters)
4416
3309
  } : {},
@@ -4640,14 +3533,6 @@ function wrapWithProxy(entity) {
4640
3533
  }
4641
3534
  });
4642
3535
  }
4643
- /*! Bundled license information:
4644
-
4645
- mustache/mustache.mjs:
4646
- (*!
4647
- * mustache.js - Logic-less {{mustache}} templates with JavaScript
4648
- * http://github.com/janl/mustache.js
4649
- *)
4650
- */
4651
3536
 
4652
3537
  exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
4653
3538
  exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;