@osdk/typescript-sdk-docs 0.4.0-beta.4 → 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.
@@ -7,7 +7,7 @@ export const snippets = {
7
7
  "1.0.0": {
8
8
  "snippets": {
9
9
  "loadSingleObjectGuide": [{
10
- "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}"
10
+ "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}"
11
11
  }],
12
12
  "loadObjectPageGuide": [{
13
13
  "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}"
@@ -156,10 +156,10 @@ export const snippets = {
156
156
  "1.1.0": {
157
157
  "snippets": {
158
158
  "loadSingleObjectGuide": [{
159
- "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}"
159
+ "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}"
160
160
  }],
161
161
  "loadObjectPageGuide": [{
162
- "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}"
162
+ "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}"
163
163
  }],
164
164
  "orderObjectsGuide": [{
165
165
  "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}"
@@ -305,35 +305,36 @@ export const snippets = {
305
305
  "2.0.0": {
306
306
  "snippets": {
307
307
  "loadSingleObjectGuide": [{
308
- "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}"
308
+ "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}",
309
+ "computedVariables": ["primaryKeyPropertyValueV2"]
309
310
  }],
310
311
  "loadObjectPageGuide": [{
311
- "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}"
312
+ "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}"
312
313
  }],
313
314
  "orderObjectsGuide": [{
314
- "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}"
315
+ "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}"
315
316
  }],
316
317
  "searchObjectsGuide": [{
317
- "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}"
318
+ "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}"
318
319
  }],
319
320
  "loadSingleObjectReference": [{
320
- "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"
321
+ "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",
322
+ "computedVariables": ["primaryKeyPropertyValueV2"]
321
323
  }],
322
324
  "loadObjectsReference": [{
323
- "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"
325
+ "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"
324
326
  }],
325
327
  "loadAllObjectsReference": [{
326
- "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 objects: Osdk.Instance<{{objectType}}>[]= [];\n\nfor await(const obj of client({{objectType}}).asyncIter()) {\n objects.push(obj);\n}\nconst object = objects[0];"
328
+ "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}"
327
329
  }],
328
330
  "loadLinkedObjectReference": [{
329
- "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}",
330
- "computedVariables": ["linkedPrimaryKeyPropertyV2"]
331
+ "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}"
331
332
  }],
332
333
  "loadLinkedObjectsReference": [{
333
- "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}"
334
+ "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}"
334
335
  }],
335
336
  "aggregationTemplate": [{
336
- "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 });"
337
+ "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 });"
337
338
  }],
338
339
  "countAggregationTemplate": [{
339
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 .aggregate({\n $select: {$count: \"unordered\"},\n });"
@@ -345,50 +346,49 @@ export const snippets = {
345
346
  "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 });"
346
347
  }],
347
348
  "numericAggregationTemplate": [{
348
- "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 });"
349
+ "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 });"
349
350
  }],
350
351
  "fixedWidthGroupByTemplate": [{
351
- "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 });"
352
+ "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 });"
352
353
  }],
353
354
  "durationGroupByTemplate": [{
354
- "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 })"
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}}: { $duration: [ {{#durationText}}{{arg}}{{/durationText}}, \"{{#durationText}}{{unit}}{{/durationText}}\"] } }\n });"
355
356
  }],
356
357
  "exactGroupByTemplate": [{
357
- "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 })"
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}}: \"exact\" }\n })"
358
359
  }],
359
360
  "rangeGroupByTemplate": [{
360
- "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 });",
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}}: { $ranges: [[{{{propertyValueV2}}}, {{{propertyValueIncrementedV2}}} ]]} }\n });",
361
362
  "computedVariables": ["propertyValueV2", "propertyValueIncrementedV2"]
362
363
  }],
363
364
  "applyAction": [{
364
- "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}",
365
- "computedVariables": ["actionParameterSampleValuesV2"]
365
+ "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}"
366
366
  }],
367
367
  "batchApplyAction": [{
368
- "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);",
369
- "computedVariables": ["actionParameterSampleValuesV2"]
368
+ "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}"
370
369
  }],
371
370
  "uploadAttachment": [{
372
- "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"
371
+ "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 });",
372
+ "computedVariables": ["propertyValueV2"]
373
373
  }],
374
374
  "castInterfaceToObjectReference": [{
375
375
  "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}"
376
376
  }],
377
377
  "executeFunction": [{
378
- "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}}});",
378
+ "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}}",
379
379
  "computedVariables": ["functionInputValuesV2"]
380
380
  }],
381
381
  "stringStartsWithTemplate": [{
382
- "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 })"
382
+ "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 })"
383
383
  }],
384
384
  "containsAllTermsInOrderTemplate": [{
385
- "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 })"
385
+ "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 })"
386
386
  }],
387
387
  "containsAnyTermTemplate": [{
388
- "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 })"
388
+ "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 })"
389
389
  }],
390
390
  "containsAllTermsTemplate": [{
391
- "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 })"
391
+ "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 })"
392
392
  }],
393
393
  "equalityTemplate": [{
394
394
  "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 });",
@@ -409,31 +409,31 @@ export const snippets = {
409
409
  "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 })"
410
410
  }],
411
411
  "withinBoundingBoxTemplate": [{
412
- "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 });"
412
+ "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 });"
413
413
  }],
414
414
  "withinPolygonTemplate": [{
415
415
  "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 });"
416
416
  }],
417
417
  "intersectsPolygonTemplate": [{
418
- "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 });"
418
+ "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 });"
419
419
  }],
420
420
  "intersectsBboxTemplate": [{
421
- "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 });"
421
+ "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 });"
422
422
  }],
423
423
  "notTemplate": [{
424
- "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 }}});",
425
- "computedVariables": ["primaryKeyPropertyV2"]
424
+ "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}}} }}});",
425
+ "computedVariables": ["propertyValueV2"]
426
426
  }],
427
427
  "andTemplate": [{
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({ $and:[\n { $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}},\n { {{primaryKeyPropertyV2.apiName}}: { $eq: \"<primaryKey>\" }}\n ]});",
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({ $and:[\n { $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}},\n { {{property}}: { $eq: {{{propertyValueV2}}} }}\n ]});",
429
+ "computedVariables": ["primaryKeyPropertyV2", "propertyValueV2"]
430
430
  }],
431
431
  "orTemplate": [{
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({ $or:[\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({ $or:[\n { $not: { {{primaryKeyPropertyV2.apiName}}: { $isNull: true }}},\n { {{property}}: { $eq: {{{propertyValueV2}}} }}\n ]});",
433
+ "computedVariables": ["primaryKeyPropertyV2", "propertyValueV2"]
434
434
  }],
435
435
  "containsTemplate": [{
436
- "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 })",
436
+ "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 })",
437
437
  "computedVariables": ["arrayElementValue"]
438
438
  }],
439
439
  "loadInterfacesReference": [{
@@ -443,25 +443,26 @@ export const snippets = {
443
443
  "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];"
444
444
  }],
445
445
  "loadOrderedInterfacesReference": [{
446
- "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}"
446
+ "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}"
447
447
  }],
448
448
  "searchInterfacesReference": [{
449
- "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}"
449
+ "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}",
450
+ "computedVariables": ["propertyValueV2"]
450
451
  }],
451
452
  "loadTimeSeriesPointsSnippet": [{
452
- "template": "import { {{objectType}} } from \"{{{packageName}}}\";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllPoints();\n}"
453
+ "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}"
453
454
  }],
454
455
  "loadRelativeTimeSeriesPointsSnippet": [{
455
- "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}"
456
+ "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}"
456
457
  }],
457
458
  "loadAbsoluteTimeSeriesPointsSnippet": [{
458
- "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}"
459
+ "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}"
459
460
  }],
460
461
  "loadTimeSeriesFirstPointSnippet": [{
461
- "template": "import { {{objectType}} } from \"{{{packageName}}}\";\n\nfunction getFirstTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getFirstPoint();\n}"
462
+ "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}"
462
463
  }],
463
464
  "loadTimeSeriesLastPointSnippet": [{
464
- "template": "import { {{objectType}} } from \"{{{packageName}}}\";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLastPoint();\n}"
465
+ "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}"
465
466
  }],
466
467
  "loadGeotimeSeriesPointsSnippet": [{
467
468
  "template": "// Upgrade to 2.1 for official support"
@@ -476,7 +477,7 @@ export const snippets = {
476
477
  "template": "// Upgrade to 2.1 for official support"
477
478
  }],
478
479
  "loadObjectMetadataSnippet": [{
479
- "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;"
480
+ "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;"
480
481
  }],
481
482
  "loadInterfaceMetadataSnippet": [{
482
483
  "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;"
@@ -491,87 +492,89 @@ export const snippets = {
491
492
  "template": "// Upgrade to 2.1 for official support"
492
493
  }],
493
494
  "derivedPropertyBaseExample": [{
494
- "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 });"
495
+ "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 })"
495
496
  }],
496
497
  "derivedPropertyApproximateDistinctAggregation": [{
497
- "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 })"
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(\"{{linkApiName}}\").aggregate(\"{{property}}:approximateDistinct\")\n }).fetchPage();"
498
499
  }],
499
500
  "derivedPropertyExactDistinctAggregation": [{
500
- "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 })"
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(\"{{linkApiName}}\").aggregate(\"{{property}}:exactDistinct\")\n }).fetchPage();"
501
502
  }],
502
503
  "derivedPropertyCollectToListAggregation": [{
503
- "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 })"
504
+ "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();"
504
505
  }],
505
506
  "derivedPropertyCollectToSetAggregation": [{
506
- "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 })"
507
+ "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();"
507
508
  }],
508
509
  "derivedPropertyCountAggregation": [{
509
- "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 })"
510
+ "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();"
510
511
  }],
511
512
  "derivedPropertySelectPropertyAggregation": [{
512
- "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 })"
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(\"{{linkApiName}}\").selectProperty(\"{{property}}\")\n }).fetchPage();"
513
514
  }],
514
515
  "derivedPropertyApproximatePercentileAggregation": [{
515
- "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 })"
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(\"{{linkApiName}}\").aggregate(\"{{property}}:approximatePercentile\", { percentile: 95 })\n }).fetchPage();"
516
517
  }],
517
518
  "derivedPropertyNumericAggregation": [{
518
- "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 })"
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(\"{{linkApiName}}\").aggregate(\"{{property}}:{{operation}}\")\n }).fetchPage();"
519
520
  }],
520
521
  "objectSetOperationsGuide": [{
521
- "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);"
522
+ "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)"
522
523
  }],
523
524
  "objectSetOperationsUnion": [{
524
- "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)"
525
+ "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)"
525
526
  }],
526
527
  "objectSetOperationsSubtract": [{
527
- "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)"
528
+ "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)"
528
529
  }],
529
530
  "objectSetOperationsIntersect": [{
530
- "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)"
531
+ "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)"
531
532
  }],
532
533
  "searchAround": [{
533
- "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}}\");"
534
+ "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();"
534
535
  }]
535
536
  }
536
537
  },
537
538
  "2.1.0": {
538
539
  "snippets": {
539
540
  "loadGeotimeSeriesPointsSnippet": [{
540
- "template": "import { {{objectType}} } from \"{{{packageName}}}\";\n\nfunction getAllTimeSeriesPoints(obj: {{objectType}}) {\n return obj.{{property}}.getAllValues();\n}"
541
+ "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}"
541
542
  }],
542
543
  "loadRelativeGeotimeSeriesPointsSnippet": [{
543
- "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}"
544
+ "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}"
544
545
  }],
545
546
  "loadAbsoluteGeotimeSeriesPointsSnippet": [{
546
- "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}"
547
+ "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}"
547
548
  }],
548
549
  "loadGeotimeSeriesLastPointSnippet": [{
549
- "template": "import { {{objectType}} } from \"{{{packageName}}}\";\n\nfunction getLastTimeSeriesPoint(obj: {{objectType}}) {\n return obj.{{property}}.getLatestValue();\n}"
550
+ "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}"
550
551
  }],
551
552
  "subscribeToObjectSetInstructions": [{
552
- "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();"
553
+ "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();"
553
554
  }],
554
555
  "uploadMedia": [{
555
- "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 });"
556
+ "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});",
557
+ "computedVariables": ["propertyValueV2"]
556
558
  }],
557
559
  "readMedia": [{
558
- "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}"
560
+ "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}",
561
+ "computedVariables": ["primaryKeyPropertyValueV2"]
559
562
  }]
560
563
  }
561
564
  },
562
565
  "2.4.0": {
563
566
  "snippets": {
564
567
  "derivedPropertyNumericExpression": [{
565
- "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 });"
568
+ "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}}"
566
569
  }],
567
570
  "derivedPropertyDatetimeExpression": [{
568
- "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 });"
571
+ "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();"
569
572
  }],
570
573
  "nearestNeighborsTextQuery": [{
571
574
  "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();"
572
575
  }],
573
576
  "nearestNeighborsVectorQuery": [{
574
- "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();"
577
+ "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();"
575
578
  }]
576
579
  }
577
580
  }