Skip to content

Commit d3b538d

Browse files
committed
DOCS-3709: Add TS code sample ingestion
1 parent f610bea commit d3b538d

30 files changed

Lines changed: 589 additions & 58 deletions

.github/workflows/parse_typescript.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ def parse(self, type, viam_resources, args):
115115
}
116116

117117
returns = md(str(method.find('h4', class_="tsd-returns-title"))).replace("#### Returns ", "").strip().replace('\\', '')
118-
return_description = md(str(method.find('h4', class_="tsd-returns-title").next_sibling)).strip()
118+
return_description = ""
119+
if method.find('h4', class_="tsd-returns-title").next_sibling:
120+
if not method.find('h4', class_="tsd-returns-title").next_sibling.get('class'):
121+
return_description = md(str(method.find('h4', class_="tsd-returns-title").next_sibling)).strip()
122+
else:
123+
return_description = None
124+
else:
125+
return_description = None
119126

120127
return_object = {
121128
'return_description': return_description,
@@ -128,16 +135,25 @@ def parse(self, type, viam_resources, args):
128135
if method.find('li', class_="tsd-description").find('div', class_="tsd-comment"):
129136
method_description = method.find('li', class_="tsd-description").find('div', class_="tsd-comment").text.strip()
130137

138+
code_sample = ""
139+
if method.find('div', class_='tsd-tag-example'):
140+
code_sample_full = method.find('div', class_='tsd-tag-example').find('pre')
141+
code_sample_full.find('button').decompose()
142+
code_sample_draft = md(str(code_sample_full)).replace('```', "").strip()
143+
code_sample = ""
144+
for line in code_sample_draft.split('\n'):
145+
code_sample = code_sample + line.rstrip() + "\n"
146+
131147
self.typescript_methods[type][resource][method_name] = {
132148
'method_description': method_description,
133149
'method_link': method.find('a', class_='tsd-anchor-icon')["href"],
134150
'parameters': param_object,
135151
'proto': '', # method_name ?
136152
'return': return_object
137153
}
138-
# 'code_sample': "", # No code samples yet method.find('pre').text
139-
# print(self.typescript_methods[type][resource][method_name])
140-
# print()
154+
155+
if code_sample:
156+
self.typescript_methods[type][resource][method_name]["code_sample"] = code_sample
141157

142158

143159
return self.typescript_methods

.github/workflows/sdk_protos_map.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ board,GetResourceName,No,get_resource_name,,getResourceName,
5858
board,Close,No,close,Close,,
5959

6060
## Button
61-
button,Push,No,,Push,,push
61+
button,Push,No,push,Push,,push
6262
button,DoCommand,No,,DoCommand,,doCommand
6363
button,Close,No,,Close,,
6464

@@ -393,6 +393,7 @@ app,DeleteKey,,delete_key,,,deleteKey
393393
app,RotateKey,,rotate_key,,,rotateKey
394394
app,ListKeys,,list_keys,,,listKeys
395395
app,CreateKeyFromExistingKeyAuthorizations,,create_key_from_existing_key_authorizations,,,createKeyFromExistingKeyAuthorizations
396+
app,GetAppContent,,,,,getAppContent
396397

397398
## Billing
398399
billing,GetCurrentMonthUsage,,get_current_month_usage,,,getCurrentMonthUsage

static/include/app/apis/generated/app-table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@
7979
| [`RotateKey`](/dev/reference/apis/fleet/#rotatekey) | Rotate an API key. |
8080
| [`ListKeys`](/dev/reference/apis/fleet/#listkeys) | List all keys for the {{< glossary_tooltip term_id="organization" text="organization" >}} that you are currently authenticated to. |
8181
| [`CreateKeyFromExistingKeyAuthorizations`](/dev/reference/apis/fleet/#createkeyfromexistingkeyauthorizations) | Create a new API key with an existing key’s authorizations. |
82+
| [`GetAppContent`](/dev/reference/apis/fleet/#getappcontent) | Retrieve the app content for an organization. |

static/include/app/apis/generated/app.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
24582458
**Parameters:**
24592459

24602460
- `organizationId` (string) (required): The ID of the organization to create the role under.
2461-
- `entityId` (string) (required): The ID of the entity the role belongs to (for example, a user ID).
2461+
- `entityId` (string) (required): The ID of the entity the role belongs to (for example a user ID).
24622462
- `role` (string) (required): The role to add ("owner" or "operator").
24632463
- `resourceType` (string) (required): The type of resource to create the role for ("robot",
24642464
"location", or "organization").
@@ -2516,7 +2516,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
25162516
**Parameters:**
25172517

25182518
- `organizationId` (string) (required): The ID of the organization to remove the role from.
2519-
- `entityId` (string) (required): The ID of the entity the role belongs to (for example, a user ID).
2519+
- `entityId` (string) (required): The ID of the entity the role belongs to (for example a user ID).
25202520
- `role` (string) (required): The role to remove ("owner" or "operator").
25212521
- `resourceType` (string) (required): The type of resource to remove the role from ("robot",
25222522
"location", or "organization").
@@ -3447,3 +3447,24 @@ For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/
34473447

34483448
{{% /tab %}}
34493449
{{< /tabs >}}
3450+
3451+
### GetAppContent
3452+
3453+
Retrieve the app content for an organization.
3454+
3455+
{{< tabs >}}
3456+
{{% tab name="TypeScript" %}}
3457+
3458+
**Parameters:**
3459+
3460+
- `publicNamespace` (string) (required): The public namespace of the organization.
3461+
- `name` (string) (required): The name of the app.
3462+
3463+
**Returns:**
3464+
3465+
- (Promise<[GetAppContentResponse](https://ts.viam.dev/classes/appApi.GetAppContentResponse.html)>): The blob path and entrypoint of the app content.
3466+
3467+
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AppClient.html#getappcontent).
3468+
3469+
{{% /tab %}}
3470+
{{< /tabs >}}

static/include/app/apis/generated/billing.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
2828

2929
**Parameters:**
3030

31-
- `orgId` (string) (required)
31+
- `orgId` (string) (required): The organization ID.
3232

3333
**Returns:**
3434

35-
- (Promise<GetCurrentMonthUsageResponse>): None.
35+
- (Promise<GetCurrentMonthUsageResponse>)
36+
37+
**Example:**
38+
39+
```ts {class="line-numbers linkable-line-numbers"}
40+
const usage = await billing.getCurrentMonthUsage('<organization-id>');
41+
```
3642

3743
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/BillingClient.html#getcurrentmonthusage).
3844

@@ -69,11 +75,19 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
6975

7076
**Parameters:**
7177

72-
- `orgId` (string) (required)
78+
- `orgId` (string) (required): The organization ID.
7379

7480
**Returns:**
7581

76-
- (Promise<[GetOrgBillingInformationResponse](https://ts.viam.dev/classes/billingApi.GetOrgBillingInformationResponse.html)>): None.
82+
- (Promise<[GetOrgBillingInformationResponse](https://ts.viam.dev/classes/billingApi.GetOrgBillingInformationResponse.html)>)
83+
84+
**Example:**
85+
86+
```ts {class="line-numbers linkable-line-numbers"}
87+
const billingInfo = await billing.getOrgBillingInformation(
88+
'<organization-id>'
89+
);
90+
```
7791

7892
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/BillingClient.html#getorgbillinginformation).
7993

@@ -109,11 +123,19 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
109123

110124
**Parameters:**
111125

112-
- `orgId` (string) (required)
126+
- `orgId` (string) (required): The organization ID.
113127

114128
**Returns:**
115129

116-
- (Promise<[GetInvoicesSummaryResponse](https://ts.viam.dev/classes/billingApi.GetInvoicesSummaryResponse.html)>): None.
130+
- (Promise<[GetInvoicesSummaryResponse](https://ts.viam.dev/classes/billingApi.GetInvoicesSummaryResponse.html)>)
131+
132+
**Example:**
133+
134+
```ts {class="line-numbers linkable-line-numbers"}
135+
const invoicesSummary = await billing.getInvoicesSummary(
136+
'<organization-id>'
137+
);
138+
```
117139

118140
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/BillingClient.html#getinvoicessummary).
119141

@@ -152,12 +174,21 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
152174

153175
**Parameters:**
154176

155-
- `id` (string) (required)
156-
- `orgId` (string) (required)
177+
- `id` (string) (required): The invoice ID.
178+
- `orgId` (string) (required): The organization ID.
157179

158180
**Returns:**
159181

160-
- (Promise<Uint8Array>): None.
182+
- (Promise<Uint8Array>)
183+
184+
**Example:**
185+
186+
```ts {class="line-numbers linkable-line-numbers"}
187+
const invoicePdf = await billing.getInvoicePdf(
188+
'<invoice-id>',
189+
'<organization-id>'
190+
);
191+
```
161192

162193
For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/BillingClient.html#getinvoicepdf).
163194

static/include/app/apis/generated/data.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
696696

697697
**Parameters:**
698698

699-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of the requested binary data.
699+
- `ids` (string) (required): The IDs of the requested binary data.
700700

701701
**Returns:**
702702

@@ -964,7 +964,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
964964

965965
**Parameters:**
966966

967-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of the data to be deleted. Must be non-empty.
967+
- `ids` (string) (required): The IDs of the data to be deleted. Must be non-empty.
968968

969969
**Returns:**
970970

@@ -1065,7 +1065,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
10651065

10661066
- `tags` (string) (required): The list of tags to add to specified binary data. Must be
10671067
non-empty.
1068-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of the data to be tagged. Must be non-empty.
1068+
- `ids` (string) (required): The IDs of the data to be tagged. Must be non-empty.
10691069

10701070
**Returns:**
10711071

@@ -1262,7 +1262,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
12621262

12631263
- `tags` (string) (required): List of tags to remove from specified binary data. Must be
12641264
non-empty.
1265-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of the data to be edited. Must be non-empty.
1265+
- `ids` (string) (required): The IDs of the data to be edited. Must be non-empty.
12661266

12671267
**Returns:**
12681268

@@ -1531,7 +1531,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
15311531

15321532
**Parameters:**
15331533

1534-
- `id` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required)
1534+
- `binaryId` (string) (required): The ID of the image to add the bounding box to.
15351535
- `label` (string) (required): A label for the bounding box.
15361536
- `xMinNormalized` (number) (required): The min X value of the bounding box normalized from 0
15371537
to 1.
@@ -1628,7 +1628,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
16281628

16291629
**Parameters:**
16301630

1631-
- `binId` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The ID of the image to remove the bounding box from.
1631+
- `binId` (string) (required): The ID of the image to remove the bounding box from.
16321632
- `bboxId` (string) (required): The ID of the bounding box to remove.
16331633

16341634
**Returns:**
@@ -1962,7 +1962,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
19621962

19631963
**Parameters:**
19641964

1965-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of binary data to add to dataset.
1965+
- `ids` (string) (required): The IDs of binary data to add to dataset.
19661966
- `datasetId` (string) (required): The ID of the dataset to be added to.
19671967

19681968
**Returns:**
@@ -2062,7 +2062,7 @@ For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/
20622062

20632063
**Parameters:**
20642064

2065-
- `ids` ([BinaryID](https://ts.viam.dev/classes/BinaryID.html)) (required): The IDs of the binary data to remove from dataset.
2065+
- `ids` (string) (required): The IDs of the binary data to remove from dataset.
20662066
- `datasetId` (string) (required): The ID of the dataset to be removed from.
20672067

20682068
**Returns:**

static/include/app/apis/generated/data_sync.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ _viam = await Viam.withApiKey(
8383
DateTime(2025, 1, 15, 14, 45) // End time
8484
);
8585
86-
final binaryDataId = await dataClient.binaryDataCaptureUpload(
86+
final fileId = await dataClient.binaryDataCaptureUpload(
8787
imageBytes,
8888
"<YOUR-PART-ID>",
8989
".png",
@@ -499,7 +499,7 @@ void _uploadData() async {
499499
DateTime(2025, 1, 15, 14, 45) // End time
500500
);
501501
502-
final binaryDataId = await dataClient.streamingDataCaptureUpload(
502+
final fileId = await dataClient.streamingDataCaptureUpload(
503503
video,
504504
"<YOUR-PART-ID>",
505505
".mp4", // Replace with your desired file format

0 commit comments

Comments
 (0)