@osdk/typescript-sdk-docs 0.5.0-beta.4 → 0.5.0-beta.5

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.
@@ -590,15 +590,15 @@ var snippets = {
590
590
  "2.6.0": {
591
591
  "snippets": {
592
592
  "applyAction": [{
593
- "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}',
593
+ "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\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\n // You can upload media data via your Action\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaUpload: MediaUpload = { data: mediaBlob, fileName: "myMedia" };\n \n // You can also pass an existing media reference into your Action\n const objectPage = await client({{objectType}}).fetchPage();\n const mediaReference: MediaReference = objectPage.data[0].{{property}}!.getMediaReference();\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}',
594
594
  "computedVariables": ["actionParameterSampleValuesV2"]
595
595
  }],
596
596
  "batchApplyAction": [{
597
- "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}',
597
+ "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\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\n // You can upload media data via your Action\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaUpload: MediaUpload = { data: mediaBlob, fileName: "myMedia" };\n \n // You can also pass an existing media reference into your Action\n const objectPage = await client({{objectType}}).fetchPage();\n const mediaReference: MediaReference = objectPage.data[0].{{property}}!.getMediaReference();\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}',
598
598
  "computedVariables": ["actionParameterSampleValuesV2"]
599
599
  }],
600
600
  "uploadMediaOntologyEdits": [{
601
- "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 // Set required properties here...\n // Media properties can be set to `mediaReference`\n });\n\n return batch.getEdits();\n}\n\nexport default createObject;'
601
+ "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}}, { myMediaProperty: mediaReference, /* Other properties... */ });\n\n return batch.getEdits();\n}\n\nexport default createObject;'
602
602
  }]
603
603
  }
604
604
  }
@@ -844,7 +844,7 @@ function renderType(type, majorVersion, context) {
844
844
  case "object":
845
845
  const primaryKeyValue = type.primaryKeyType === "string" ? '"primaryKeyValue"' : "primaryKeyValue";
846
846
  if (context === "actionParameter") {
847
- return majorVersion >= SdkMajorVersion.V2 ? `{ $primaryKey: ${primaryKeyValue}, /* other properties */ }` : `{ __primaryKey: ${primaryKeyValue}, /* other properties */ }`;
847
+ return majorVersion >= SdkMajorVersion.V2 ? `"primaryKeyValue" // or myObjectInstance` : `{ __primaryKey: ${primaryKeyValue}, /* other properties */ }`;
848
848
  }
849
849
  return primaryKeyValue;
850
850
  case "anonymousCustomType":
@@ -856,7 +856,7 @@ function renderType(type, majorVersion, context) {
856
856
  case "marking":
857
857
  return "{}";
858
858
  case "mediaReference":
859
- return context === "actionParameter" ? "mediaReferenceOrUpload" : "mediaReferenceRid";
859
+ return context === "actionParameter" ? "mediaUpload" : "mediaReferenceRid";
860
860
  case "objectType":
861
861
  return `"${type.objectTypeApiName}"`;
862
862
  case "map":