@osdk/maker 0.14.0-beta.7 → 0.14.0-beta.9

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 (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/browser/api/code-snippets/createCodeSnippets.js +91 -0
  3. package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
  4. package/build/browser/api/code-snippets/snippetTypes.js +60 -0
  5. package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
  6. package/build/browser/api/defineDeleteInterfaceObjectAction.js +2 -2
  7. package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  8. package/build/browser/api/defineOntology.js +5 -1
  9. package/build/browser/api/defineOntology.js.map +1 -1
  10. package/build/browser/api/test/actions.test.js +9 -9
  11. package/build/browser/api/test/actions.test.js.map +1 -1
  12. package/build/browser/cli/main.js +23 -4
  13. package/build/browser/cli/main.js.map +1 -1
  14. package/build/cjs/index.cjs +1300 -40
  15. package/build/cjs/index.cjs.map +1 -1
  16. package/build/cjs/index.d.cts +1 -1
  17. package/build/esm/api/code-snippets/createCodeSnippets.js +91 -0
  18. package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
  19. package/build/esm/api/code-snippets/snippetTypes.js +60 -0
  20. package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
  21. package/build/esm/api/defineDeleteInterfaceObjectAction.js +2 -2
  22. package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
  23. package/build/esm/api/defineOntology.js +5 -1
  24. package/build/esm/api/defineOntology.js.map +1 -1
  25. package/build/esm/api/test/actions.test.js +9 -9
  26. package/build/esm/api/test/actions.test.js.map +1 -1
  27. package/build/esm/cli/main.js +23 -4
  28. package/build/esm/cli/main.js.map +1 -1
  29. package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
  30. package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
  31. package/build/types/api/code-snippets/snippetTypes.d.ts +23 -0
  32. package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
  33. package/build/types/api/defineOntology.d.ts +1 -1
  34. package/build/types/api/defineOntology.d.ts.map +1 -1
  35. package/package.json +4 -3
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var consola = require('consola');
6
- var fs2 = require('fs/promises');
7
- var path2 = require('path');
6
+ var fs3 = require('fs/promises');
7
+ var path3 = require('path');
8
8
  var invariant7 = require('tiny-invariant');
9
9
  var yargs = require('yargs');
10
10
  var helpers = require('yargs/helpers');
11
- var fs = require('fs');
11
+ var fs2 = require('fs');
12
12
  var crypto = require('crypto');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -31,11 +31,11 @@ function _interopNamespace(e) {
31
31
  return Object.freeze(n);
32
32
  }
33
33
 
34
- var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
35
- var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
34
+ var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
35
+ var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
36
36
  var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
37
37
  var yargs__default = /*#__PURE__*/_interopDefault(yargs);
38
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
38
+ var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
39
39
 
40
40
  // src/cli/main.ts
41
41
 
@@ -1443,6 +1443,1236 @@ function getFormContentOrdering(action, parameterOrdering) {
1443
1443
  return formContentOrdering;
1444
1444
  }
1445
1445
 
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
+ // src/api/code-snippets/snippetTypes.ts
2580
+ var interfaceSnippets = /* @__PURE__ */ (function(interfaceSnippets2) {
2581
+ interfaceSnippets2[interfaceSnippets2["loadInterfacesReference"] = 0] = "loadInterfacesReference";
2582
+ interfaceSnippets2[interfaceSnippets2["loadAllInterfacesReference"] = 1] = "loadAllInterfacesReference";
2583
+ interfaceSnippets2[interfaceSnippets2["loadOrderedInterfacesReference"] = 2] = "loadOrderedInterfacesReference";
2584
+ interfaceSnippets2[interfaceSnippets2["searchInterfacesReference"] = 3] = "searchInterfacesReference";
2585
+ interfaceSnippets2[interfaceSnippets2["loadInterfaceMetadataSnippet"] = 4] = "loadInterfaceMetadataSnippet";
2586
+ interfaceSnippets2[interfaceSnippets2["subscribeToObjectSetInstructions"] = 5] = "subscribeToObjectSetInstructions";
2587
+ return interfaceSnippets2;
2588
+ })({});
2589
+ var actionSnippets = /* @__PURE__ */ (function(actionSnippets2) {
2590
+ actionSnippets2[actionSnippets2["applyAction"] = 0] = "applyAction";
2591
+ actionSnippets2[actionSnippets2["batchApplyAction"] = 1] = "batchApplyAction";
2592
+ return actionSnippets2;
2593
+ })({});
2594
+ var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
2595
+ objectSnippets2[objectSnippets2["loadSingleObjectGuide"] = 0] = "loadSingleObjectGuide";
2596
+ objectSnippets2[objectSnippets2["loadObjectsReference"] = 1] = "loadObjectsReference";
2597
+ objectSnippets2[objectSnippets2["loadAllObjectsReference"] = 2] = "loadAllObjectsReference";
2598
+ objectSnippets2[objectSnippets2["loadOrderedInterfacesReference"] = 3] = "loadOrderedInterfacesReference";
2599
+ objectSnippets2[objectSnippets2["searchObjectsGuide"] = 4] = "searchObjectsGuide";
2600
+ objectSnippets2[objectSnippets2["aggregationTemplate"] = 5] = "aggregationTemplate";
2601
+ objectSnippets2[objectSnippets2["objectSetOperationsGuide"] = 6] = "objectSetOperationsGuide";
2602
+ objectSnippets2[objectSnippets2["loadObjectMetadataSnippet"] = 7] = "loadObjectMetadataSnippet";
2603
+ objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
2604
+ return objectSnippets2;
2605
+ })({});
2606
+
2607
+ // src/api/code-snippets/createCodeSnippets.ts
2608
+ function createCodeSnippets(ontology, packageName, outputDir) {
2609
+ if (outputDir === void 0) {
2610
+ outputDir = "./code-snippets";
2611
+ }
2612
+ if (!fs2__namespace.existsSync(outputDir)) {
2613
+ fs2__namespace.mkdirSync(outputDir, {
2614
+ recursive: true
2615
+ });
2616
+ }
2617
+ if (packageName === void 0) {
2618
+ packageName = "";
2619
+ }
2620
+ consola.consola.info("Generating code snippets to ", outputDir);
2621
+ for (const type of Object.values(OntologyEntityTypeEnum)) {
2622
+ for (const object of Object.values(ontology[type])) {
2623
+ let snippet = {};
2624
+ switch (type) {
2625
+ case OntologyEntityTypeEnum.OBJECT_TYPE:
2626
+ snippet = generateObjectSnippet(object, packageName);
2627
+ break;
2628
+ case OntologyEntityTypeEnum.ACTION_TYPE:
2629
+ snippet = generateActionSnippet(object, packageName);
2630
+ break;
2631
+ case OntologyEntityTypeEnum.INTERFACE_TYPE:
2632
+ snippet = generateInterfaceSnippet(object, packageName);
2633
+ break;
2634
+ default:
2635
+ continue;
2636
+ }
2637
+ fs2__namespace.writeFileSync(path3__namespace.join(outputDir, object.apiName), JSON.stringify(snippet));
2638
+ }
2639
+ }
2640
+ consola.consola.info("Finished Code Snippet Generation");
2641
+ }
2642
+ function generateInterfaceSnippet(interfaceType, packageName) {
2643
+ const interfaceContext = {
2644
+ "interfaceApiName": interfaceType.apiName,
2645
+ "packageName": packageName,
2646
+ "objectOrInterfaceApiName": interfaceType.apiName,
2647
+ "propertyNames": Object.keys(interfaceType.propertiesV2)
2648
+ };
2649
+ return getSnippets(interfaceSnippets, interfaceContext);
2650
+ }
2651
+ function generateObjectSnippet(objectType, packageName) {
2652
+ const objectContext = {
2653
+ "objectType": objectType.apiName,
2654
+ "packageName": packageName,
2655
+ "objectOrInterfaceApiName": objectType.apiName
2656
+ };
2657
+ return getSnippets(objectSnippets, objectContext);
2658
+ }
2659
+ function generateActionSnippet(actionType, packageName) {
2660
+ const actionContext = {
2661
+ "actionApiName": actionType.apiName,
2662
+ "packageName": packageName
2663
+ };
2664
+ return getSnippets(actionSnippets, actionContext);
2665
+ }
2666
+ function getSnippets(snippetType, context) {
2667
+ const allSnippets = {};
2668
+ 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;
2672
+ }
2673
+ return allSnippets;
2674
+ }
2675
+
1446
2676
  // src/api/defineOntology.ts
1447
2677
  var ontologyDefinition;
1448
2678
  var importedTypes;
@@ -1458,7 +2688,7 @@ function updateOntology(entity) {
1458
2688
  }
1459
2689
  ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
1460
2690
  }
1461
- async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
2691
+ async function defineOntology(ns, body, outputDir, dependencyFile, codeSnippetFiles, snippetPackageName, snippetFileOutputDir, randomnessKey) {
1462
2692
  namespace = ns;
1463
2693
  dependencies = {};
1464
2694
  ontologyDefinition = {
@@ -1489,10 +2719,13 @@ async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey
1489
2719
  if (dependencyFile) {
1490
2720
  writeDependencyFile(dependencyFile);
1491
2721
  }
2722
+ if (codeSnippetFiles) {
2723
+ createCodeSnippets(ontologyDefinition, snippetPackageName, snippetFileOutputDir);
2724
+ }
1492
2725
  return convertOntologyDefinition(ontologyDefinition, randomnessKey);
1493
2726
  }
1494
2727
  function writeStaticObjects(outputDir) {
1495
- const codegenDir = path2__namespace.resolve(outputDir, "codegen");
2728
+ const codegenDir = path3__namespace.resolve(outputDir, "codegen");
1496
2729
  const typeDirs = {
1497
2730
  [OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
1498
2731
  [OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
@@ -1501,31 +2734,31 @@ function writeStaticObjects(outputDir) {
1501
2734
  [OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
1502
2735
  [OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
1503
2736
  };
1504
- if (!fs__namespace.existsSync(codegenDir)) {
1505
- fs__namespace.mkdirSync(codegenDir, {
2737
+ if (!fs2__namespace.existsSync(codegenDir)) {
2738
+ fs2__namespace.mkdirSync(codegenDir, {
1506
2739
  recursive: true
1507
2740
  });
1508
2741
  }
1509
2742
  Object.values(typeDirs).forEach((typeDirNameFromMap) => {
1510
- const currentTypeDirPath = path2__namespace.join(codegenDir, typeDirNameFromMap);
1511
- if (fs__namespace.existsSync(currentTypeDirPath)) {
1512
- fs__namespace.rmSync(currentTypeDirPath, {
2743
+ const currentTypeDirPath = path3__namespace.join(codegenDir, typeDirNameFromMap);
2744
+ if (fs2__namespace.existsSync(currentTypeDirPath)) {
2745
+ fs2__namespace.rmSync(currentTypeDirPath, {
1513
2746
  recursive: true,
1514
2747
  force: true
1515
2748
  });
1516
2749
  }
1517
- fs__namespace.mkdirSync(currentTypeDirPath, {
2750
+ fs2__namespace.mkdirSync(currentTypeDirPath, {
1518
2751
  recursive: true
1519
2752
  });
1520
2753
  });
1521
2754
  const topLevelExportStatements = [];
1522
2755
  Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
1523
2756
  const typeDirName = typeDirs[ontologyTypeEnumKey];
1524
- const typeDirPath = path2__namespace.join(codegenDir, typeDirName);
2757
+ const typeDirPath = path3__namespace.join(codegenDir, typeDirName);
1525
2758
  const entityModuleNames = [];
1526
2759
  Object.entries(entities).forEach(([apiName, entity]) => {
1527
2760
  const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
1528
- const filePath = path2__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
2761
+ const filePath = path3__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
1529
2762
  const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
1530
2763
  const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
1531
2764
  const content = `
@@ -1537,7 +2770,7 @@ const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey ===
1537
2770
 
1538
2771
  export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
1539
2772
  `;
1540
- fs__namespace.writeFileSync(filePath, content, {
2773
+ fs2__namespace.writeFileSync(filePath, content, {
1541
2774
  flag: "w"
1542
2775
  });
1543
2776
  entityModuleNames.push(entityFileNameBase);
@@ -1548,8 +2781,8 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
1548
2781
  });
1549
2782
  if (topLevelExportStatements.length > 0) {
1550
2783
  const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
1551
- const mainIndexFilePath = path2__namespace.join(outputDir, "index.ts");
1552
- fs__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
2784
+ const mainIndexFilePath = path3__namespace.join(outputDir, "index.ts");
2785
+ fs2__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
1553
2786
  flag: "w"
1554
2787
  });
1555
2788
  }
@@ -1905,7 +3138,7 @@ function getEntityTypeName(type) {
1905
3138
  }[type];
1906
3139
  }
1907
3140
  function writeDependencyFile(dependencyFile) {
1908
- fs__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
3141
+ fs2__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
1909
3142
  }
1910
3143
  function dependencyInjectionString() {
1911
3144
  const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
@@ -1922,20 +3155,20 @@ function addNamespaceIfNone(apiName) {
1922
3155
  var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
1923
3156
  var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1924
3157
  async function main(args = process.argv) {
1925
- const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.7").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
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({
1926
3159
  input: {
1927
3160
  alias: "i",
1928
3161
  describe: "Input file",
1929
3162
  type: "string",
1930
3163
  default: ".ontology/ontology.ts",
1931
- coerce: path2__namespace.resolve
3164
+ coerce: path3__namespace.resolve
1932
3165
  },
1933
3166
  output: {
1934
3167
  alias: "o",
1935
3168
  describe: "Output file",
1936
3169
  type: "string",
1937
3170
  default: "ontology.json",
1938
- coerce: path2__namespace.resolve
3171
+ coerce: path3__namespace.resolve
1939
3172
  },
1940
3173
  apiNamespace: {
1941
3174
  describe: "Api name prefix for namespaced ontology types",
@@ -1947,29 +3180,45 @@ async function main(args = process.argv) {
1947
3180
  describe: "Snapshot directory",
1948
3181
  type: "string",
1949
3182
  default: "snapshots",
1950
- coerce: path2__namespace.resolve
3183
+ coerce: path3__namespace.resolve
1951
3184
  },
1952
3185
  outputDir: {
1953
3186
  alias: "d",
1954
3187
  describe: "Directory for generated ontology entities",
1955
3188
  type: "string",
1956
- coerce: path2__namespace.resolve
3189
+ coerce: path3__namespace.resolve
1957
3190
  },
1958
3191
  valueTypesOutput: {
1959
3192
  describe: "Value Type Output File",
1960
3193
  type: "string",
1961
3194
  default: "value-types.json",
1962
- coerce: path2__namespace.resolve
3195
+ coerce: path3__namespace.resolve
1963
3196
  },
1964
3197
  dependencies: {
1965
3198
  describe: "File to write dependencies to",
1966
3199
  type: "string",
1967
- coerce: path2__namespace.resolve
3200
+ coerce: path3__namespace.resolve
3201
+ },
3202
+ generateCodeSnippets: {
3203
+ describe: "Enable code snippet files creation",
3204
+ type: "boolean",
3205
+ default: false
3206
+ },
3207
+ codeSnippetPackageName: {
3208
+ describe: "The package name that will be displayed in the code snippets",
3209
+ default: "",
3210
+ type: "string"
3211
+ },
3212
+ codeSnippetDir: {
3213
+ describe: "Directory for generated code snippet files",
3214
+ type: "string",
3215
+ default: "./",
3216
+ coerce: path3__namespace.resolve
1968
3217
  },
1969
3218
  randomnessKey: {
1970
3219
  describe: "Value used to assure uniqueness of entities",
1971
3220
  type: "string",
1972
- coerce: path2__namespace.resolve
3221
+ coerce: path3__namespace.resolve
1973
3222
  }
1974
3223
  }).parseAsync();
1975
3224
  let apiNamespace = "";
@@ -1979,38 +3228,41 @@ async function main(args = process.argv) {
1979
3228
  !apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant7__default.default(false) : void 0;
1980
3229
  }
1981
3230
  consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
3231
+ if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
3232
+ consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
3233
+ }
1982
3234
  if (commandLineOpts.randomnessKey !== void 0) {
1983
3235
  !uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant7__default.default(false) : void 0;
1984
3236
  }
1985
- const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
3237
+ const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
1986
3238
  consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
1987
- await fs2__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
3239
+ await fs3__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
1988
3240
  if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
1989
- await fs2__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
3241
+ await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
1990
3242
  }
1991
3243
  }
1992
- async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
1993
- const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
3244
+ async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
3245
+ const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
1994
3246
  return q;
1995
3247
  }
1996
3248
  var MAX_SEARCH_DEPTH = 5;
1997
3249
  function addDependency(namespaceNoDot, fileInPackage) {
1998
- let dir = path2__namespace.dirname(fileInPackage);
3250
+ let dir = path3__namespace.dirname(fileInPackage);
1999
3251
  let packageJsonPath = null;
2000
3252
  for (let i = 0; i < MAX_SEARCH_DEPTH; i++) {
2001
- const candidate = path2__namespace.join(dir, "package.json");
2002
- if (fs__namespace.existsSync(candidate)) {
3253
+ const candidate = path3__namespace.join(dir, "package.json");
3254
+ if (fs2__namespace.existsSync(candidate)) {
2003
3255
  packageJsonPath = candidate;
2004
3256
  break;
2005
3257
  }
2006
- const parentDir = path2__namespace.dirname(dir);
3258
+ const parentDir = path3__namespace.dirname(dir);
2007
3259
  if (parentDir === dir) break;
2008
3260
  dir = parentDir;
2009
3261
  }
2010
3262
  if (!packageJsonPath) {
2011
3263
  throw new Error(`Could not find a package.json within ${MAX_SEARCH_DEPTH} parent directories of ${fileInPackage}`);
2012
3264
  }
2013
- const packageJson = JSON.parse(fs__namespace.readFileSync(packageJsonPath, "utf-8"));
3265
+ const packageJson = JSON.parse(fs2__namespace.readFileSync(packageJsonPath, "utf-8"));
2014
3266
  dependencies[namespaceNoDot] = packageJson.version ?? "";
2015
3267
  }
2016
3268
 
@@ -2862,8 +4114,8 @@ function defineDeleteInterfaceObjectAction(def) {
2862
4114
  }
2863
4115
  }],
2864
4116
  entities: {
2865
- affectedInterfaceTypes: [],
2866
- affectedObjectTypes: [def.interfaceType.apiName],
4117
+ affectedInterfaceTypes: [def.interfaceType.apiName],
4118
+ affectedObjectTypes: [],
2867
4119
  affectedLinkTypes: [],
2868
4120
  typeGroups: []
2869
4121
  }
@@ -3388,6 +4640,14 @@ function wrapWithProxy(entity) {
3388
4640
  }
3389
4641
  });
3390
4642
  }
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
+ */
3391
4651
 
3392
4652
  exports.CREATE_INTERFACE_OBJECT_PARAMETER = CREATE_INTERFACE_OBJECT_PARAMETER;
3393
4653
  exports.CREATE_OR_MODIFY_OBJECT_PARAMETER = CREATE_OR_MODIFY_OBJECT_PARAMETER;