@osdk/typescript-sdk-docs 0.6.0-beta.2 → 0.6.0-beta.4
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.
- package/CHANGELOG.md +12 -0
- package/build/browser/docs.js +2 -0
- package/build/browser/docs.js.map +1 -1
- package/build/browser/generatedNoCheck/docsNoComputedVariables.js +9 -16
- package/build/browser/generatedNoCheck/docsNoComputedVariables.js.map +1 -1
- package/build/cjs/index.cjs +11 -16
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/docs.js +2 -0
- package/build/esm/docs.js.map +1 -1
- package/build/esm/generatedNoCheck/docsNoComputedVariables.js +9 -16
- package/build/esm/generatedNoCheck/docsNoComputedVariables.js.map +1 -1
- package/package.json +2 -2
package/build/cjs/index.cjs
CHANGED
|
@@ -558,8 +558,16 @@ var snippets = {
|
|
|
558
558
|
"subscribeToObjectSetInstructions": [{
|
|
559
559
|
"template": 'import { {{objectOrInterfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst subscription = client({{objectOrInterfaceApiName}}).subscribe(\n {\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 // Get the object using the $primaryKey from your cache\n // const currentObject = objects[update.object.$primaryKey];\n // use the update.object["<propertyName>"] to update your cache \n //currentObject["<propertyName>"] = update.object["<propertyName>"] ?? currentObject["<propertyName>"];\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 // Remove the object from your cache using the $primaryKey\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 throw new Error(err.error instanceof Error ? err.error.message : String(err.error));\n },\n onOutOfDate() {\n // We could not keep track of all changes. Please reload the objects in your set.\n },\n },\n { properties: [ {{{propertyNames}}} ] }\n);\n\n// To stop receiving updates, call unsubscribe\nsubscription.unsubscribe();'
|
|
560
560
|
}],
|
|
561
|
+
"applyAction": [{
|
|
562
|
+
"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}',
|
|
563
|
+
"computedVariables": ["actionParameterSampleValuesV2"]
|
|
564
|
+
}],
|
|
565
|
+
"batchApplyAction": [{
|
|
566
|
+
"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}',
|
|
567
|
+
"computedVariables": ["actionParameterSampleValuesV2"]
|
|
568
|
+
}],
|
|
561
569
|
"uploadMediaOntologyEdits": [{
|
|
562
|
-
"template": "
|
|
570
|
+
"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;'
|
|
563
571
|
}],
|
|
564
572
|
"uploadMedia": [{
|
|
565
573
|
"template": 'import { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference } from "@osdk/api/unstable";\nimport { {{objectType}}, {{actionApiName}} } from "{{{packageName}}}"\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { MediaReference } from "@osdk/api";\n// To upload media with 2.x, it has to be linked to an Action call\nasync function createMediaReference() {\n const file = await fetch("file.json");\n const data = await file.blob();\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: "{{property}}",\n });\n}\nconst mediaReference: MediaReference = await createMediaReference();\nconst actionResult = client({{actionApiName}}).applyAction({ \n {{primaryKeyPropertyV2.apiName}}: {{{propertyValueV2}}},\n {{mediaParameter}}: mediaReference \n});',
|
|
@@ -586,21 +594,6 @@ var snippets = {
|
|
|
586
594
|
"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();'
|
|
587
595
|
}]
|
|
588
596
|
}
|
|
589
|
-
},
|
|
590
|
-
"2.6.0": {
|
|
591
|
-
"snippets": {
|
|
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\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
|
-
"computedVariables": ["actionParameterSampleValuesV2"]
|
|
595
|
-
}],
|
|
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\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
|
-
"computedVariables": ["actionParameterSampleValuesV2"]
|
|
599
|
-
}],
|
|
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}}, { myMediaProperty: mediaReference, /* Other properties... */ });\n\n return batch.getEdits();\n}\n\nexport default createObject;'
|
|
602
|
-
}]
|
|
603
|
-
}
|
|
604
597
|
}
|
|
605
598
|
}
|
|
606
599
|
};
|
|
@@ -847,6 +840,8 @@ function renderType(type, majorVersion, context) {
|
|
|
847
840
|
return majorVersion >= SdkMajorVersion.V2 ? `"primaryKeyValue" // or myObjectInstance` : `{ __primaryKey: ${primaryKeyValue}, /* other properties */ }`;
|
|
848
841
|
}
|
|
849
842
|
return primaryKeyValue;
|
|
843
|
+
case "objectSet":
|
|
844
|
+
return `client(${type.objectTypeApiName}).where({ /* filter conditions */ })`;
|
|
850
845
|
case "anonymousCustomType":
|
|
851
846
|
case "customType":
|
|
852
847
|
return "{}";
|