@osdk/typescript-sdk-docs 0.1.0 → 0.2.0-beta.2

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.
@@ -553,7 +553,7 @@ var snippets = {
553
553
  "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLatestValue();\n}'
554
554
  }],
555
555
  "subscribeToObjectSetInstructions": [{
556
- "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 === "DELETED") {\n // The object has been deleted\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();'
556
+ "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();'
557
557
  }],
558
558
  "uploadMedia": [{
559
559
  "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 });'
@@ -587,7 +587,8 @@ var TYPESCRIPT_OSDK_SNIPPETS = {
587
587
  linkedPropertiesV1: handleLinkedPropertiesV1,
588
588
  linkedPropertiesV2: handleLinkedPropertiesV2,
589
589
  linkedPrimaryKeyPropertyV1: handleLinkedPrimaryKeyPropertyV1,
590
- linkedPrimaryKeyPropertyV2: handleLinkedPrimaryKeyPropertyV2
590
+ linkedPrimaryKeyPropertyV2: handleLinkedPrimaryKeyPropertyV2,
591
+ arrayElementValue: handleArrayElementValue
591
592
  }
592
593
  };
593
594
  var SdkMajorVersion = /* @__PURE__ */ function(SdkMajorVersion2) {
@@ -635,6 +636,17 @@ function handlePropertyValueIncrementedV2({
635
636
  }) {
636
637
  return renderPropertyValue(rawPropertyValueIncremented, SdkMajorVersion.V2);
637
638
  }
639
+ function handleArrayElementValue({
640
+ rawPropertyValue
641
+ }) {
642
+ return renderArrayElementPropertyValue(rawPropertyValue, SdkMajorVersion.V2);
643
+ }
644
+ function renderArrayElementPropertyValue(propertyValue, majorVersion) {
645
+ if (propertyValue == null) {
646
+ throw new Error("Cannot render a null property value");
647
+ }
648
+ return renderType(propertyValue, majorVersion, "arraySubType");
649
+ }
638
650
  function handlePropertiesV1({
639
651
  rawProperties
640
652
  }) {
@@ -761,7 +773,8 @@ function renderType(type, majorVersion, context) {
761
773
  case "array":
762
774
  case "set":
763
775
  case "list":
764
- return `[${renderType(type.subtype, majorVersion, context)}]`;
776
+ const arraySubType = renderType(type.subtype, majorVersion, context);
777
+ return context === "arraySubType" ? arraySubType : `[${arraySubType}]`;
765
778
  case "boolean":
766
779
  return type.value ? "true" : "false";
767
780
  case "byte":