@osdk/typescript-sdk-docs 0.4.0-beta.5 → 0.4.0-beta.6

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.
@@ -11,7 +11,7 @@ var snippets = {
11
11
  "1.0.0": {
12
12
  "snippets": {
13
13
  "loadSingleObjectGuide": [{
14
- "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}'
14
+ "template": 'import { type GetObjectError, isOk, type Result } from "{{{packageName}}}";\nimport { {{objectType}} } from "{{{packageName}}}";\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}'
15
15
  }],
16
16
  "loadObjectPageGuide": [{
17
17
  "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}'
@@ -160,10 +160,10 @@ var snippets = {
160
160
  "1.1.0": {
161
161
  "snippets": {
162
162
  "loadSingleObjectGuide": [{
163
- "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}'
163
+ "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 throw e;\n}'
164
164
  }],
165
165
  "loadObjectPageGuide": [{
166
- "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}'
166
+ "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 throw e;\n}'
167
167
  }],
168
168
  "orderObjectsGuide": [{
169
169
  "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}'
@@ -309,35 +309,36 @@ var snippets = {
309
309
  "2.0.0": {
310
310
  "snippets": {
311
311
  "loadSingleObjectGuide": [{
312
- "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}'
312
+ "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\ntry {\n const object: Osdk.Instance<{{objectType}}> = await client({{objectType}}).fetchOne({{{primaryKeyPropertyValueV2}}});\n}\ncatch(e) {\n throw e;\n}',
313
+ "computedVariables": ["primaryKeyPropertyValueV2"]
313
314
  }],
314
315
  "loadObjectPageGuide": [{
315
- "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}'
316
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type PageResult } from "@osdk/client";\n\ntry {\n const firstPage: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30 });\n if (firstPage.nextPageToken === undefined) {\n console.log(firstPage.data);\n }\n const secondPage: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30, $nextPageToken: firstPage.nextPageToken });\n console.log([...firstPage.data, ...secondPage.data]);\n}\ncatch (e) {\n throw e;\n}'
316
317
  }],
317
318
  "orderObjectsGuide": [{
318
- "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}'
319
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type PageResult } from "@osdk/client";\n\ntry {\n const page: PageResult<Osdk.Instance<{{objectType}}>> = await client({{objectType}})\n .fetchPage({\n $orderBy: {"{{titleProperty}}": "asc"},\n $pageSize: 30\n });\n const objects = page.data;\n const object = objects[0];\n} catch (e) {\n throw e;\n}'
319
320
  }],
320
321
  "searchObjectsGuide": [{
321
- "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}'
322
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type PageResult } from "@osdk/client";\n\ntry {\n const page: PageResult<Osdk.Instance<{{objectType}}>> = await client({{objectType}})\n .where({\n {{titleProperty}}: {$isNull: true}\n })\n .fetchPage({\n $pageSize: 30\n });\n const objects = page.data;\n const object = objects[0];\n} catch (e) {\n throw e;\n}'
322
323
  }],
323
324
  "loadSingleObjectReference": [{
324
- "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'
325
+ "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 responseNoErrorWrapper: Osdk.Instance<{{objectType}}> = await client({{objectType}}).fetchOne({{{primaryKeyPropertyValueV2}}});\n\n',
326
+ "computedVariables": ["primaryKeyPropertyValueV2"]
325
327
  }],
326
328
  "loadObjectsReference": [{
327
- "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'
329
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport type { Osdk, PageResult } from "@osdk/client";\ntry {\n const responseNoErrorWrapper: PageResult<Osdk.Instance<{{objectType}}>>\n = await client({{objectType}}).fetchPage({ $pageSize: 30 });\n} catch (e) {\n throw e;\n}\n'
328
330
  }],
329
331
  "loadAllObjectsReference": [{
330
332
  "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\nasync function getAll(): Promise<Array<Osdk.Instance<{{objectType}}>>> {\n const objects: Osdk.Instance<{{objectType}}>[]= [];\n for await(const obj of client({{objectType}}).asyncIter()) {\n objects.push(obj);\n }\n\n return objects;\n}\n\n// If Array.fromAsync() is available in your target environment\nfunction getAllFromAsync(): Promise<Array<Osdk.Instance<{{objectType}}>>> {\n return Array.fromAsync(client({{objectType}}).asyncIter());\n}'
331
333
  }],
332
334
  "loadLinkedObjectReference": [{
333
- "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}',
334
- "computedVariables": ["linkedPrimaryKeyPropertyV2"]
335
+ "template": 'import { type {{objectType}} } from "{{{packageName}}}";\nimport { type Osdk } from "@osdk/client";\n\nasync function getLinked{{linkedObjectType}}(source: Osdk.Instance<{{objectType}}>) {\n try {\n {{#isLinkManySided}}\n return await source.$link.{{linkApiName}}.fetchPage();\n {{/isLinkManySided}}\n {{^isLinkManySided}}\n return await source.$link.{{linkApiName}}.fetchOne();\n {{/isLinkManySided}}\n } catch (error) {\n return { error };\n }\n}'
335
336
  }],
336
337
  "loadLinkedObjectsReference": [{
337
- "template": 'import { {{linkedObjectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\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}\n\n// You can also get a linked object by doing an object set searcharound\nfunction getLinkedWithPivot{{linkedObjectType}}(){\n return client({{sourceObjectType}}).pivotTo({{linkApiName}}).fetchPage();\n}'
338
+ "template": 'import { {{sourceObjectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nasync function getLinkedWithPivot{{linkedObjectType}}(){\n return await client({{sourceObjectType}}).pivotTo("{{linkApiName}}").fetchPage();\n}'
338
339
  }],
339
340
  "aggregationTemplate": [{
340
- "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 });'
341
+ "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: { {{property}}: "exact" },\n });'
341
342
  }],
342
343
  "countAggregationTemplate": [{
343
344
  "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 });'
@@ -349,50 +350,49 @@ var snippets = {
349
350
  "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 });'
350
351
  }],
351
352
  "numericAggregationTemplate": [{
352
- "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 });'
353
+ "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 .aggregate({\n $select: { "{{property}}:{{operation}}" : "unordered" }\n });'
353
354
  }],
354
355
  "fixedWidthGroupByTemplate": [{
355
- "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 });'
356
+ "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 });'
356
357
  }],
357
358
  "durationGroupByTemplate": [{
358
- "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 })'
359
+ "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 });'
359
360
  }],
360
361
  "exactGroupByTemplate": [{
361
- "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 })'
362
+ "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 })'
362
363
  }],
363
364
  "rangeGroupByTemplate": [{
364
- "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 });',
365
+ "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 });',
365
366
  "computedVariables": ["propertyValueV2", "propertyValueIncrementedV2"]
366
367
  }],
367
368
  "applyAction": [{
368
- "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}',
369
- "computedVariables": ["actionParameterSampleValuesV2"]
369
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentProperty}}\nimport type { AttachmentUpload {{#hasMediaParameter}}, MediaReference {{/hasMediaParameter}} } from "@osdk/api";\n{{/hasAttachmentProperty}}\n{{^hasAttachmentProperty}}{{#hasMediaParameter}}\nimport type { MediaReference } from "@osdk/api";\n{{/hasMediaParameter}}{{/hasAttachmentProperty}}\n{{#hasAttachmentProperty}}\nimport { createAttachmentUpload } from "@osdk/client";\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference } from "@osdk/api/unstable";\n{{/hasMediaParameter}}\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 // Create media reference\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaReference: MediaReference = await client(\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n ).createMediaReference({\n data: mediaBlob,\n fileName: "myMedia",\n objectType: {{objectType}},\n propertyType: "{{property}}",\n });\n // alternatively, you can get the Rid from the media property on the object type you are modifying\n // const mediaRid = objectTypeWithMedia.{mediaProperty}?.rid;\n{{/hasMediaParameter}}\n const result = await client({{actionApiName}}).applyAction(\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n {{#hasAttachmentProperty}}\n {{attachmentParameter}}: attachment, // or attachmentRid\n {{/hasAttachmentProperty}}\n {{#hasMediaParameter}}\n {{mediaParameter}}: mediaReference,\n {{/hasMediaParameter}}\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}'
370
370
  }],
371
371
  "batchApplyAction": [{
372
- "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);',
373
- "computedVariables": ["actionParameterSampleValuesV2"]
372
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentProperty}}\nimport type { AttachmentUpload {{#hasMediaParameter}}, MediaReference {{/hasMediaParameter}} } from "@osdk/api";\n{{/hasAttachmentProperty}}\n{{^hasAttachmentProperty}}{{#hasMediaParameter}}\nimport type { MediaReference } from "@osdk/api";\n{{/hasMediaParameter}}{{/hasAttachmentProperty}}\n{{#hasAttachmentProperty}}\nimport { createAttachmentUpload } from "@osdk/client";\n{{/hasAttachmentProperty}}\n{{#hasMediaParameter}}\nimport { __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference } from "@osdk/api/unstable";\n{{/hasMediaParameter}}\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 // Create media reference\n const mediaFile = await fetch("media.mp4");\n const mediaBlob = await mediaFile.blob();\n const mediaReference: MediaReference = await client(\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n ).createMediaReference({\n data: mediaBlob,\n fileName: "myMedia",\n objectType: {{objectType}},\n propertyType: "{{property}}",\n });\n{{/hasMediaParameter}}\n const result = await client({{actionApiName}}).batchApplyAction([\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n {{#hasAttachmentProperty}}\n {{attachmentParameter}}: attachment,\n {{/hasAttachmentProperty}}\n {{#hasMediaParameter}}\n {{mediaParameter}}: mediaReference,\n {{/hasMediaParameter}}\n },\n {\n {{#actionParameterSampleValuesV2}}\n "{{key}}": {{{value}}},\n {{/actionParameterSampleValuesV2}}\n {{#hasAttachmentProperty}}\n {{attachmentParameter}}: attachment,\n {{/hasAttachmentProperty}}\n {{#hasMediaParameter}}\n {{mediaParameter}}: mediaReference,\n {{/hasMediaParameter}}\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}'
374
373
  }],
375
374
  "uploadAttachment": [{
376
- "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'
375
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { createAttachmentUpload } from "@osdk/client";\nimport type { AttachmentUpload } from "@osdk/api";\nimport { {{actionApiName}} } from "{{{packageName}}}";\n\n// To call an action with an attachment property, you first need to upload the file\nasync function createAttachmentReference() {\n const file = await fetch("file.json");\n const blob = await file.blob();\n return createAttachmentUpload(blob, "myFile");\n}\n\nconst myAttachmentUpload: AttachmentUpload = await createAttachmentReference();\n// then pass the attachment to the action in the action parameter.\nconst actionResult = client({{actionApiName}}).applyAction({ \n {{primaryKeyPropertyV2.apiName}}: {{{propertyValueV2}}},\n {{property}}: myAttachmentUpload\n });',
376
+ "computedVariables": ["propertyValueV2"]
377
377
  }],
378
378
  "castInterfaceToObjectReference": [{
379
379
  "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}'
380
380
  }],
381
381
  "executeFunction": [{
382
- "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}}});',
382
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\n{{#hasAttachmentProperty}}\n{{#hasAttachmentUpload}}\nimport type { AttachmentUpload } from "@osdk/api";\nimport { createAttachmentUpload } from "@osdk/client";\nimport { {{funcApiName}} } from "{{{packageName}}}";\n{{/hasAttachmentUpload}}\n{{^hasAttachmentUpload}}\nimport type { Osdk } from "@osdk/client";\nimport { {{funcApiName}}, type {{objectType}} } from "{{{packageName}}}";\n{{/hasAttachmentUpload}}\n\n{{#hasAttachmentUpload}}\nasync function callFunctionWithAttachmentUpload() {\n async function createAttachmentReference() {\n const file = await fetch("file.json");\n const blob = await file.blob();\n return createAttachmentUpload(blob, "myFile");\n }\n const attachment: AttachmentUpload = await createAttachmentReference();\n{{/hasAttachmentUpload}}\n{{^hasAttachmentUpload}}\nasync function callFunctionWithAttachmentLoaded(objectWithAttachment: Osdk.Instance<{{objectType}}>) {\n const attachment = objectWithAttachment.{{attachmentProperty}}?.rid;\n if (attachment == null) {\n throw new Error("Attachment is required");\n }\n{{/hasAttachmentUpload}}\n const result = await client({{funcApiName}}).executeFunction({{{functionInputValuesV2}}});\n return result;\n}\n{{/hasAttachmentProperty}}\n{{^hasAttachmentProperty}}\nimport { {{funcApiName}} } from "{{{packageName}}}";\n\nconst result = await client({{funcApiName}}).executeFunction({{{functionInputValuesV2}}});\n{{/hasAttachmentProperty}}',
383
383
  "computedVariables": ["functionInputValuesV2"]
384
384
  }],
385
385
  "stringStartsWithTemplate": [{
386
- "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 })'
386
+ "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 })'
387
387
  }],
388
388
  "containsAllTermsInOrderTemplate": [{
389
- "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 })'
389
+ "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 })'
390
390
  }],
391
391
  "containsAnyTermTemplate": [{
392
- "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 })'
392
+ "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 })'
393
393
  }],
394
394
  "containsAllTermsTemplate": [{
395
- "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 })'
395
+ "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 })'
396
396
  }],
397
397
  "equalityTemplate": [{
398
398
  "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 });',
@@ -413,31 +413,31 @@ var snippets = {
413
413
  "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 })'
414
414
  }],
415
415
  "withinBoundingBoxTemplate": [{
416
- "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 });'
416
+ "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 });'
417
417
  }],
418
418
  "withinPolygonTemplate": [{
419
419
  "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 });'
420
420
  }],
421
421
  "intersectsPolygonTemplate": [{
422
- "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 });'
422
+ "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 });'
423
423
  }],
424
424
  "intersectsBboxTemplate": [{
425
- "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 });'
425
+ "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 });'
426
426
  }],
427
427
  "notTemplate": [{
428
- "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 }}});',
429
- "computedVariables": ["primaryKeyPropertyV2"]
428
+ "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: { {{property}}: { $eq: {{{propertyValueV2}}} }}});',
429
+ "computedVariables": ["propertyValueV2"]
430
430
  }],
431
431
  "andTemplate": [{
432
- "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 ]});',
433
- "computedVariables": ["primaryKeyPropertyV2"]
432
+ "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 { {{property}}: { $eq: {{{propertyValueV2}}} }}\n ]});',
433
+ "computedVariables": ["primaryKeyPropertyV2", "propertyValueV2"]
434
434
  }],
435
435
  "orTemplate": [{
436
- "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 ]});',
437
- "computedVariables": ["primaryKeyPropertyV2"]
436
+ "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 { {{property}}: { $eq: {{{propertyValueV2}}} }}\n ]});',
437
+ "computedVariables": ["primaryKeyPropertyV2", "propertyValueV2"]
438
438
  }],
439
439
  "containsTemplate": [{
440
- "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 })',
440
+ "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 })',
441
441
  "computedVariables": ["arrayElementValue"]
442
442
  }],
443
443
  "loadInterfacesReference": [{
@@ -447,25 +447,26 @@ var snippets = {
447
447
  "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];'
448
448
  }],
449
449
  "loadOrderedInterfacesReference": [{
450
- "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}'
450
+ "template": 'import { {{interfaceApiName}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nimport { type Osdk, type PageResult } from "@osdk/client";\n\ntry {\n const page: PageResult<Osdk<{{interfaceApiName}}>> = await client({{interfaceApiName}})\n .fetchPage({\n $orderBy: { {{property}}: "asc"},\n $pageSize: 30\n });\n} catch (e) {\n throw e;\n}'
451
451
  }],
452
452
  "searchInterfacesReference": [{
453
- "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}'
453
+ "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: { {{property}}: { $isNull: true }}},\n { {{property}}: { $eq: {{{propertyValueV2}}} }}\n ]\n })\n .fetchPageWithErrors({\n $pageSize: 30\n });\n\nif (isOk(page)) {\n const interfaces = page.value.data;\n const interface1 = interfaces[0];\n}',
454
+ "computedVariables": ["propertyValueV2"]
454
455
  }],
455
456
  "loadTimeSeriesPointsSnippet": [{
456
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllPoints();\n}'
457
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getAllPoints();\n}'
457
458
  }],
458
459
  "loadRelativeTimeSeriesPointsSnippet": [{
459
- "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}'
460
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getAllPoints({\n $before: 1,\n $unit: "{{timeUnit}}",\n })\n}'
460
461
  }],
461
462
  "loadAbsoluteTimeSeriesPointsSnippet": [{
462
- "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}'
463
+ "template": 'import { type {{objectType}} } from "{{{packageName}}}";\nimport { type Osdk } from "@osdk/client";\n\nasync function getAbsoluteTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return await obj.{{property}}?.getAllPoints({\n $startTime: "2022-08-13T12:34:56Z",\n $endTime: "2022-08-14T12:34:56Z",\n });\n}'
463
464
  }],
464
465
  "loadTimeSeriesFirstPointSnippet": [{
465
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getFirstTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getFirstPoint();\n}'
466
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getFirstTimeSeriesPoint(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getFirstPoint();\n}'
466
467
  }],
467
468
  "loadTimeSeriesLastPointSnippet": [{
468
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLastPoint();\n}'
469
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getLastPoint();\n}'
469
470
  }],
470
471
  "loadGeotimeSeriesPointsSnippet": [{
471
472
  "template": "// Upgrade to 2.1 for official support"
@@ -480,7 +481,7 @@ var snippets = {
480
481
  "template": "// Upgrade to 2.1 for official support"
481
482
  }],
482
483
  "loadObjectMetadataSnippet": [{
483
- "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;'
484
+ "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;'
484
485
  }],
485
486
  "loadInterfaceMetadataSnippet": [{
486
487
  "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;'
@@ -495,87 +496,89 @@ var snippets = {
495
496
  "template": "// Upgrade to 2.1 for official support"
496
497
  }],
497
498
  "derivedPropertyBaseExample": [{
498
- "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 });'
499
+ "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("{{linkApiName}}").aggregate("$count")\n })\n .where({\n "newPropertyName": { $gt: 0 }\n }).aggregate({\n $select: { "newPropertyName:max": "unordered" }\n })'
499
500
  }],
500
501
  "derivedPropertyApproximateDistinctAggregation": [{
501
- "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 })'
502
+ "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("{{linkApiName}}").aggregate("{{property}}:approximateDistinct")\n }).fetchPage();'
502
503
  }],
503
504
  "derivedPropertyExactDistinctAggregation": [{
504
- "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 })'
505
+ "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("{{linkApiName}}").aggregate("{{property}}:exactDistinct")\n }).fetchPage();'
505
506
  }],
506
507
  "derivedPropertyCollectToListAggregation": [{
507
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst maxObjectsInList = 75; // Adjust this value as needed between 1 and 100\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:collectList", maxObjectsInList)\n })'
508
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst maxObjectsInList = 75; // Adjust this value as needed between 1 and 100\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}").aggregate("{{property}}:collectList", { limit: maxObjectsInList })\n }).fetchPage();'
508
509
  }],
509
510
  "derivedPropertyCollectToSetAggregation": [{
510
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst maxObjectsInSet = 75; // Adjust this value as needed between 1 and 100\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkName}}").aggregate("{{property}}:collectSet", maxObjectsInSet)\n })'
511
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst maxObjectsInSet = 75; // Adjust this value as needed between 1 and 100\nconst sum{{objectType}} = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}").aggregate("{{property}}:collectSet", { limit: maxObjectsInSet })\n }).fetchPage();'
511
512
  }],
512
513
  "derivedPropertyCountAggregation": [{
513
- "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 })'
514
+ "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("{{linkApiName}}").aggregate("$count")\n }).fetchPage();'
514
515
  }],
515
516
  "derivedPropertySelectPropertyAggregation": [{
516
- "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 })'
517
+ "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("{{linkApiName}}").selectProperty("{{property}}")\n }).fetchPage();'
517
518
  }],
518
519
  "derivedPropertyApproximatePercentileAggregation": [{
519
- "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 })'
520
+ "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("{{linkApiName}}").aggregate("{{property}}:approximatePercentile", { percentile: 95 })\n }).fetchPage();'
520
521
  }],
521
522
  "derivedPropertyNumericAggregation": [{
522
- "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 })'
523
+ "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("{{linkApiName}}").aggregate("{{property}}:{{operation}}")\n }).fetchPage();'
523
524
  }],
524
525
  "objectSetOperationsGuide": [{
525
- "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);'
526
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { {{objectType}} } from "{{{packageName}}}";\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)'
526
527
  }],
527
528
  "objectSetOperationsUnion": [{
528
- "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)'
529
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { {{objectType}} } from "{{{packageName}}}";\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)'
529
530
  }],
530
531
  "objectSetOperationsSubtract": [{
531
- "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)'
532
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { {{objectType}} } from "{{{packageName}}}";\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)'
532
533
  }],
533
534
  "objectSetOperationsIntersect": [{
534
- "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)'
535
+ "template": '// Edit this import if your client location differs\nimport { client } from "./client";\nimport { {{objectType}} } from "{{{packageName}}}";\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)'
535
536
  }],
536
537
  "searchAround": [{
537
- "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}}");'
538
+ "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// Find {{linkedObjectType}} objects linked to the filtered {{sourceObjectType}} objects\nconst linkedObjects = await objects.pivotTo("{{linkApiName}}").fetchPage();'
538
539
  }]
539
540
  }
540
541
  },
541
542
  "2.1.0": {
542
543
  "snippets": {
543
544
  "loadGeotimeSeriesPointsSnippet": [{
544
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllValues();\n}'
545
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getAllTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getAllValues();\n}'
545
546
  }],
546
547
  "loadRelativeGeotimeSeriesPointsSnippet": [{
547
- "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}'
548
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\n// Only supports ranges in the past\nfunction getRelativeTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getAllValues({\n $before: 1,\n $unit: "{{timeUnit}}",\n })\n}'
548
549
  }],
549
550
  "loadAbsoluteGeotimeSeriesPointsSnippet": [{
550
- "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}'
551
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getAbsoluteTimeSeriesPoints(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getAllValues({\n $startTime: "2022-08-13T12:34:56Z",\n $endTime: "2022-08-14T12:34:56Z",\n });\n}'
551
552
  }],
552
553
  "loadGeotimeSeriesLastPointSnippet": [{
553
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLatestValue();\n}'
554
+ "template": 'import type { Osdk } from "@osdk/client";\nimport { type {{objectType}} } from "{{{packageName}}}";\n\nfunction getLastTimeSeriesPoint(obj: Osdk.Instance<{{objectType}}>) {\n return obj.{{property}}?.getLatestValue();\n}'
554
555
  }],
555
556
  "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 {\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}}] }\n);\n\nsubscription.unsubscribe();'
557
+ "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();'
557
558
  }],
558
559
  "uploadMedia": [{
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 });'
560
+ "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});',
561
+ "computedVariables": ["propertyValueV2"]
560
562
  }],
561
563
  "readMedia": [{
562
- "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}'
564
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\nconst result = await client({{objectType}}).fetchOne({{{primaryKeyPropertyValueV2}}});\n// Fetch metadata of a media property\nconst mediaMetadata = await result.{{property}}?.fetchMetadata();\nconsole.log(mediaMetadata?.mediaType, mediaMetadata?.sizeBytes, mediaMetadata?.path);\n// Fetch contents of a media property\nconst mediaContent = await result.{{property}}?.fetchContents();\nif (mediaContent?.ok) {\n const data = await mediaContent.blob();\n}',
565
+ "computedVariables": ["primaryKeyPropertyValueV2"]
563
566
  }]
564
567
  }
565
568
  },
566
569
  "2.4.0": {
567
570
  "snippets": {
568
571
  "derivedPropertyNumericExpression": [{
569
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}WithExpression = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n {{^isUnary}}\n baseObjectSet.pivotTo("{{linkName}}")\n .selectProperty("{{property}}").{{operation}}(\n baseObjectSet.pivotTo("{{linkName}}").aggregate("$count"))\n {{/isUnary}}\n {{#isUnary}}\n baseObjectSet.pivotTo("{{linkName}}").selectProperty("{{property}}").{{operation}}()\n {{/isUnary}}\n });'
572
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}WithExpression = await client({{objectType}})\n .withProperties({\n {{^isUnary}}\n "newPropertyName": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}")\n .aggregate("{{property}}").{{operation}}(\n baseObjectSet.pivotTo("{{linkApiName}}").aggregate("$count"))\n }).fetchPage();\n {{/isUnary}}\n {{#isUnary}}\n "{{operation}}_{{property}}": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}")\n .selectProperty("{{property}}").{{operation}}()\n }).fetchPage();\n {{/isUnary}}'
570
573
  }],
571
574
  "derivedPropertyDatetimeExpression": [{
572
- "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}WithExpression = await client({{objectType}})\n .withProperties({\n "newPropertyName": (baseObjectSet) =>\n {{^isExtractPart}} \n baseObjectSet.pivotTo("{{linkName}}")\n .selectProperty("{{property}}")\n .{{operation}}(baseObjectSet.pivotTo("{{linkName}}").selectProperty("{{property}}"))\n {{/isExtractPart}}\n {{#isExtractPart}}\n baseObjectSet.pivotTo("{{linkName}}")\n .selectProperty("{{property}}").{{operation}}("DAY")\n {{/isExtractPart}}\n });'
575
+ "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst {{objectType}}WithExpression = await client({{objectType}})\n .withProperties({\n {{^isExtractPart}} \n "derivedPropertyDatetime_{{operation}}": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}")\n .selectProperty("{{property}}")\n .{{operation}}(baseObjectSet.pivotTo("{{linkApiName}}").selectProperty("{{property}}"))\n {{/isExtractPart}}\n {{#isExtractPart}}\n "YEARS_part_of_{{property}}_of_{{linkApiName}}": (baseObjectSet) =>\n baseObjectSet.pivotTo("{{linkApiName}}")\n .selectProperty("{{property}}").extractPart("YEARS")\n {{/isExtractPart}}\n }).fetchPage();'
573
576
  }],
574
577
  "nearestNeighborsTextQuery": [{
575
578
  "template": 'import { {{objectType}} } from "{{{packageName}}}";\n// Edit this import if your client location differs\nimport { client } from "./client";\n\nconst result = await client({{objectType}})\n .nearestNeighbors("coffee", 5, "{{property}}")\n .fetchPage();'
576
579
  }],
577
580
  "nearestNeighborsVectorQuery": [{
578
- "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();'
581
+ "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();'
579
582
  }]
580
583
  }
581
584
  }
@@ -600,6 +603,7 @@ var TYPESCRIPT_OSDK_SNIPPETS = {
600
603
  propertiesV2: handlePropertiesV2,
601
604
  primaryKeyPropertyV1: handlePrimaryKeyPropertyV1,
602
605
  primaryKeyPropertyV2: handlePrimaryKeyPropertyV2,
606
+ primaryKeyPropertyValueV2: handlePrimaryKeyPropertyValueV2,
603
607
  linkedPropertiesV1: handleLinkedPropertiesV1,
604
608
  linkedPropertiesV2: handleLinkedPropertiesV2,
605
609
  linkedPrimaryKeyPropertyV1: handleLinkedPrimaryKeyPropertyV1,
@@ -707,6 +711,14 @@ function handlePrimaryKeyPropertyV2({
707
711
  value: renderPropertyValue(rawPrimaryKeyProperty.value, SdkMajorVersion.V2)
708
712
  };
709
713
  }
714
+ function handlePrimaryKeyPropertyValueV2({
715
+ rawPrimaryKeyProperty
716
+ }) {
717
+ if (rawPrimaryKeyProperty == null) {
718
+ throw new Error("Cannot render with null rawPrimaryKeyProperty");
719
+ }
720
+ return renderPropertyValue(rawPrimaryKeyProperty.value, SdkMajorVersion.V2);
721
+ }
710
722
  function handleLinkedPropertiesV1({
711
723
  rawLinkedProperties
712
724
  }) {