@osdk/typescript-sdk-docs 0.5.0-beta.2 → 0.5.0-beta.3

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.
@@ -583,6 +583,21 @@ var snippets = {
583
583
  "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\n// Note that this vector maps to an arbitrary string\n// It must match the dimension of the "{{property}}" property: {{vectorDimensionSize}}\nconst vector_query = Array.from({ length: {{vectorDimensionSize}} }, () => 0.3);\nconst result = await client({{objectType}})\n .nearestNeighbors(vector_query, 5, "{{property}}")\n .fetchPage();'
584
584
  }]
585
585
  }
586
+ },
587
+ "2.6.0": {
588
+ "snippets": {
589
+ "applyAction": [{
590
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentProperty}}\nimport type { AttachmentUpload {{#hasMediaParameter}}, MediaReference, MediaUpload {{/hasMediaParameter}} } from "@osdk/api";\n{{/hasAttachmentProperty}}\n{{^hasAttachmentProperty}}{{#hasMediaParameter}}\nimport type { MediaReference, MediaUpload } from "@osdk/api";\n{{/hasMediaParameter}}{{/hasAttachmentProperty}}\n{{#hasAttachmentProperty}}\nimport { createAttachmentUpload } from "@osdk/client";\n{{/hasAttachmentProperty}}\nimport { {{actionApiName}} {{#hasMediaParameter}}, {{objectType}} {{/hasMediaParameter}} } from "{{{packageName}}}";\n\nasync function callAction() {\n{{#hasAttachmentProperty}}\n // Create attachment upload\n const attachmentFile = await fetch("file.json");\n const attachmentBlob = await attachmentFile.blob();\n const attachment: AttachmentUpload = createAttachmentUpload(attachmentBlob, "myFile");\n // alternatively, you can get the Rid from the attachment property on the object type you are modifying \n // const attachmentRid = objectTypeWithAttachment.{attachmentProperty}?.rid;\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\n // Use existing media reference\n const objectPage = await client({{objectType}}).fetchPage();\n const mediaReference: MediaReference = objectPage.data[0].{{property}}!.getMediaReference();\n\n // Upload media data\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaUpload: MediaUpload = { data: mediaBlob, fileName: "myMedia" };\n\n const mediaReferenceOrUpload = Math.random() < 0.5 ? mediaReference : mediaUpload;\n\n{{/hasMediaParameter}}\n const result = await client({{actionApiName}}).applyAction(\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n },\n {\n $returnEdits: true,\n }\n );\n if (result.type === "edits") {\n // use the result object to report back on action results\n const updatedObject = result.editedObjectTypes[0];\n console.log("Updated object", updatedObject);\n }\n}',
591
+ "computedVariables": ["actionParameterSampleValuesV2"]
592
+ }],
593
+ "batchApplyAction": [{
594
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentProperty}}\nimport type { AttachmentUpload {{#hasMediaParameter}}, MediaReference, MediaUpload {{/hasMediaParameter}} } from "@osdk/api";\n{{/hasAttachmentProperty}}\n{{^hasAttachmentProperty}}{{#hasMediaParameter}}\nimport type { MediaReference, MediaUpload } from "@osdk/api";\n{{/hasMediaParameter}}{{/hasAttachmentProperty}}\n{{#hasAttachmentProperty}}\nimport { createAttachmentUpload } from "@osdk/client";\n{{/hasAttachmentProperty}}\nimport { {{actionApiName}} {{#hasMediaParameter}}, {{objectType}} {{/hasMediaParameter}} } from "{{{packageName}}}";\n\nasync function callBatchAction() {\n{{#hasAttachmentProperty}}\n // Create attachment upload\n const attachmentFile = await fetch("file.json");\n const attachmentBlob = await attachmentFile.blob();\n const attachment: AttachmentUpload = createAttachmentUpload(attachmentBlob, "myFile");\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\n // Use existing media reference\n const objectPage = await client({{objectType}}).fetchPage();\n const mediaReference: MediaReference = objectPage.data[0].{{property}}!.getMediaReference();\n\n // Upload media data\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaUpload: MediaUpload = { data: mediaBlob, fileName: "myMedia" };\n\n const mediaReferenceOrUpload = Math.random() < 0.5 ? mediaReference : mediaUpload;\n \n{{/hasMediaParameter}}\n const result = await client({{actionApiName}}).batchApplyAction([\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n },\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n },\n ],\n {\n $returnEdits: true,\n }\n );\n if (result.type === "edits") {\n // use the result object to report back on action results\n const updatedObject = result.editedObjectTypes[0];\n console.log("Updated object", updatedObject);\n }\n}',
595
+ "computedVariables": ["actionParameterSampleValuesV2"]
596
+ }],
597
+ "uploadMediaOntologyEdits": [{
598
+ "template": 'import type { Client } from "@osdk/client";\nimport { {{objectType}} } from "{{{packageName}}}";\nimport type { Edits } from "@osdk/functions";\nimport { createEditBatch, uploadMedia } from "@osdk/functions";\n\nasync function createObject(client: Client): Promise<Edits.Object<{{objectType}}>[]> {\n const batch = createEditBatch<Edits.Object<{{objectType}}>>(client);\n \n const blob = new Blob(["Hello, world"], { type: "text/plain" });\n const mediaReference = await uploadMedia(client, { data: blob, fileName: "foundryFile.txt" });\n\n // @ts-ignore\n batch.create({{objectType}}, {\n // "<mediaProperty>": mediaReference,\n });\n\n return batch.getEdits();\n}\n\nexport default createObject;'
599
+ }]
600
+ }
586
601
  }
587
602
  }
588
603
  };
@@ -838,7 +853,7 @@ function renderType(type, majorVersion, context) {
838
853
  case "marking":
839
854
  return "{}";
840
855
  case "mediaReference":
841
- return context === "actionParameter" ? "mediaReference" : "mediaReferenceRid";
856
+ return context === "actionParameter" ? "mediaReferenceOrUpload" : "mediaReferenceRid";
842
857
  case "objectType":
843
858
  return `"${type.objectTypeApiName}"`;
844
859
  case "map":