Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/docs/ai_chat_apps/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class UserServicer(User.Servicer):
request: CreateCounterRequest,
) -> CreateCounterResponse:
"""Create a new Counter and return its ID."""
counter, _ = await Counter.create(
counter, _ = await Counter.factory.create(
context,
description=request.description,
owner_id=context.state_id,
Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/learn_more/applications.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ async def hello_greeter(
context: ExternalContext = InjectExternalContext,
):
body = await request.json()
greeter, _ = await Greeter.create(
greeter, _ = await Greeter.factory.create(
context,
title=body['title'],
name=body['name'],
Expand Down Expand Up @@ -230,7 +230,7 @@ application.http.post("/hello_greeter", async (context, req, res) => {
name: string;
adjective: string;
};
const [greeter] = await Greeter.create(context, {
const [greeter] = await Greeter.factory.create(context, {
title,
name,
adjective,
Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/learn_more/auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ construction](/learn_more/call/overview#explicit-construction):
<!-- The below code snippet is automatically added from ../../../tests/reboot/auth_tests.py -->

```py
bank, _ = await Bank.create(
bank, _ = await Bank.factory.create(
context,
SINGLETON_BANK_ID,
Options(bearer_token=VALID_JWT),
Expand All @@ -68,7 +68,7 @@ bank, _ = await Bank.create(

<TabItem value="typescript" label="TypeScript">
```ts
const [bank] = await Bank.create(
const [bank] = await Bank.factory.create(
context,
SINGLETON_BANK_ID,
{},
Expand Down
5 changes: 4 additions & 1 deletion documentation/docs/learn_more/call/from_within_your_app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def transfer(
</TabItem>
<TabItem value="typescript" label="TypeScript">
<!-- MARKDOWN-AUTO-DOCS:START
(CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&lines=46-54) -->
(CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&lines=50-61) -->
<!-- The below code snippet is automatically added from ../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts -->

```ts
Expand All @@ -62,6 +62,9 @@ async transfer(

await fromAccount.withdraw(context, { amount: request.amount });
await toAccount.deposit(context, { amount: request.amount });

return {};
}
```

<!-- MARKDOWN-AUTO-DOCS:END -->
Expand Down
24 changes: 14 additions & 10 deletions documentation/docs/learn_more/call/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from_account = Account.ref(request.from_account_id)
</TabItem>
<TabItem value="typescript" label="TypeScript">
<!-- MARKDOWN-AUTO-DOCS:START
(CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&lines=50-50) -->
(CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&lines=54-54) -->
<!-- The below code snippet is automatically added from ../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts -->

```ts
Expand Down Expand Up @@ -191,7 +191,7 @@ example:
<Tabs groupId="language">
<TabItem value="python" label="Python" default>
```python
account, response = await Account.open(
account, response = await Account.factory.open(
context,
customer_name=request.customer_name,
)
Expand All @@ -200,7 +200,7 @@ account, response = await Account.open(
</TabItem>
<TabItem value="typescript" label="TypeScript">
```typescript
const [account, response] = await Account.open(context, {
const [account, response] = await Account.factory.open(context, {
customerName: request.customerName,
});
```
Expand Down Expand Up @@ -230,7 +230,7 @@ an example of constructing an `Account` with an explicit ID using the
<!-- The below code snippet is automatically added from ../../../../reboot/examples/monorepo/bank/backend/src/bank_servicer.py -->

```python
account, _ = await Account.open(
account, _ = await Account.factory.open(
context,
new_account_id,
customer_name=request.customer_name,
Expand All @@ -240,13 +240,17 @@ account, _ = await Account.open(
<!-- MARKDOWN-AUTO-DOCS:END -->
</TabItem>
<TabItem value="typescript" label="TypeScript">
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&syntax=typescript&lines=39-41) -->
<!-- MARKDOWN-AUTO-DOCS:START (CODE:src=../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts&syntax=typescript&lines=39-45) -->
<!-- The below code snippet is automatically added from ../../../../reboot/examples/bank-nodejs/backend/src/bank_servicer.ts -->

```typescript
const [account, response] = await Account.open(context, newAccountId, {
customerName: request.customerName,
});
const [account, response] = await Account.factory.open(
context,
newAccountId,
{
customerName: request.customerName,
}
);
```

<!-- MARKDOWN-AUTO-DOCS:END -->
Expand All @@ -263,7 +267,7 @@ application (i.e., using an `ExternalContext`):
<Tabs groupId="language">
<TabItem value="python" label="Python" default>
```python
account, response = await Account.idempotently().open(
account, response = await Account.factory.idempotently().open(
context,
customer_name=request.customer_name,
)
Expand All @@ -272,7 +276,7 @@ account, response = await Account.idempotently().open(
</TabItem>
<TabItem value="typescript" label="TypeScript">
```typescript
const [account, response] = await Account.idempotently().open(context, {
const [account, response] = await Account.factory.idempotently().open(context, {
customerName: request.customerName,
});
```
Expand Down
5 changes: 3 additions & 2 deletions documentation/docs/learn_more/idempotency.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ distinguish each call, for example:
<Tabs groupId="language">
<TabItem value="python" label="Python" default>
<!-- MARKDOWN-AUTO-DOCS:START
(CODE:src=../../../tests/reboot/idempotency_tests.py&lines=370-373) -->
(CODE:src=../../../tests/reboot/idempotency_tests.py&lines=371-375) -->
<!-- The below code snippet is automatically added from ../../../tests/reboot/idempotency_tests.py -->

```py
# First call: sign up the account idempotently.
await bank.idempotently('sign up jonathan').SignUp(
context,
account_id='jonathan',
Expand All @@ -40,7 +41,7 @@ await bank.idempotently('sign up jonathan').SignUp(
<!-- The below code snippet is automatically added from ../../../tests/reboot/nodejs/greeter_test/test.ts -->

```ts
await Greeter.idempotently("generated").create(context, {
await Greeter.factory.idempotently("generated").create(context, {
title: "Mr",
name: "John",
adjective: "Dangerous",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ key is still a secret at rest, so encrypt it with
reference to the encrypted value:

```py
ciphertext, _ = await Ciphertext.encrypt(
ciphertext, _ = await Ciphertext.factory.encrypt(
context,
plaintext=request.api_key.encode(),
associated_data=make_associated_data(
Expand Down
8 changes: 4 additions & 4 deletions documentation/docs/library_services/ciphertext.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ from reboot.std.ciphertext.v1.ciphertext import APP_SHARED_KEY_MANAGER_ID
from uuid import uuid4

ciphertext_id = str(uuid4())
ciphertext, _ = await Ciphertext.encrypt(
ciphertext, _ = await Ciphertext.factory.encrypt(
context,
ciphertext_id,
plaintext=b"123-45-6789",
Expand All @@ -132,7 +132,7 @@ import {
} from "@reboot-dev/reboot-std/ciphertext/v1";

const ciphertextId = crypto.randomUUID();
const [ciphertext] = await Ciphertext.encrypt(context, ciphertextId, {
const [ciphertext] = await Ciphertext.factory.encrypt(context, ciphertextId, {
plaintext: new TextEncoder().encode("123-45-6789"),
associatedData: makeAssociatedData({ user_id: "42", purpose: "ssn" }),
scope: "user_id:42",
Expand Down Expand Up @@ -199,7 +199,7 @@ others ciphertexts (`shred` operates per manager).

```py
# Encrypt under a named manager.
await Ciphertext.encrypt(
await Ciphertext.factory.encrypt(
context,
ciphertext_id,
plaintext=b"123-45-6789",
Expand All @@ -217,7 +217,7 @@ await KeyManager.ref("tenant:acme").shred(context, scope="user_id:42")

```ts
// Encrypt under a named manager.
await Ciphertext.encrypt(context, ciphertextId, {
await Ciphertext.factory.encrypt(context, ciphertextId, {
plaintext: new TextEncoder().encode("123-45-6789"),
associatedData: makeAssociatedData({ user_id: "42", purpose: "ssn" }),
scope: "user_id:42",
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/library_services/mailgun.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Reboot Cloud.
## Message {#rbtthirdpartymailgunv1message}
A single message sent using the integration.

Created and scheduled using its constructor: `await Message.send(...)`.
Created and scheduled using its constructor: `await Message.factory.send(...)`.

### Send

Expand Down
3 changes: 2 additions & 1 deletion rbt/thirdparty/mailgun/v1/mailgun.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import "google/protobuf/timestamp.proto";
/**
* A single message sent using the integration.
*
* Created and scheduled using its constructor: `await Message.Send(...)`.
* Created and scheduled using its constructor:
* `await Message.factory.Send(...)`.
*/
service MessageMethods {
/**
Expand Down
2 changes: 1 addition & 1 deletion reboot/aio/applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ async def _post_authenticate(
user.

`context` is app-internal: materializing the state is a Writer
call (`User.Create(...)`) that the authorizer permits from
call (`User.factory.Create(...)`) that the authorizer permits from
trusted app code (auto-construct `User` types allow
app-internal callers).
"""
Expand Down
2 changes: 1 addition & 1 deletion reboot/cli/commands/cloud/up.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def _maybe_create_application(
bearer_token=api_key,
)
try:
await Application.Create(context, qualified_application_name)
await Application.factory.Create(context, qualified_application_name)
except Aborted as aborted:
match aborted.error:
case StateAlreadyConstructed(): # type: ignore[misc]
Expand Down
4 changes: 2 additions & 2 deletions reboot/demos/fig/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { FigBoardServicer, FigServicer } from "./fig_servicer.js";
import { UserServicer, UsersServicer } from "./user_servicer.js";

const initialize = async (context) => {
await FigBoard.create(context, FIG_BOARD_ID);
await FigBoard.factory.create(context, FIG_BOARD_ID);

await Users.create(context, USERS_ID);
await Users.factory.create(context, USERS_ID);
};

new Application({
Expand Down
2 changes: 1 addition & 1 deletion reboot/demos/fig/backend/src/user_servicer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class UsersServicer extends Users.Servicer {

this.state.userIds.push(request.userId);

await User.create(context, request.userId);
await User.factory.create(context, request.userId);

return {};
}
Expand Down
6 changes: 3 additions & 3 deletions reboot/examples/agent-wiki/backend/src/servicers/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async def create_page(
content. Returns the new page's state ID, which you
should link to from the wiki's markdown as
`Page:<state_id>`."""
page, _ = await Page.create(
page, _ = await Page.factory.create(
context,
title=title,
content=content,
Expand All @@ -288,7 +288,7 @@ async def create_wiki(
context.auth.user_id if context.auth is not None and
context.auth.user_id is not None else ""
)
wiki, _ = await Wiki.create(
wiki, _ = await Wiki.factory.create(
context,
name=request.name,
description=request.description,
Expand Down Expand Up @@ -363,7 +363,7 @@ async def add_transcript(
) -> WikiAddTranscriptResponse:
"""Create a new Transcript belonging to this Wiki and
record it as pending ingestion on the Wiki."""
transcript, _ = await Transcript.create(
transcript, _ = await Transcript.factory.create(
context,
messages=list(request.messages),
owner_id=self.state.owner_id,
Expand Down
4 changes: 2 additions & 2 deletions reboot/examples/agent-wiki/backend/tests/wiki_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def test_wiki_get_and_update(self) -> None:
async def test_page_crud(self) -> None:
"""`Page.create` / `get` / `update` round-trip the
title and markdown body."""
page, _ = await Page.create(
page, _ = await Page.factory.create(
self.context,
title="My Page",
content="Initial body.",
Expand All @@ -188,7 +188,7 @@ async def test_transcript_crud(self) -> None:
TranscriptMessage(role="user", content="Hello"),
TranscriptMessage(role="assistant", content="Hi!"),
]
transcript, _ = await Transcript.create(
transcript, _ = await Transcript.factory.create(
self.context,
messages=messages,
owner_id=self.user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def create_counter(
request: CreateCounterRequest,
) -> CreateCounterResponse:
"""Create a new Counter and return its ID."""
counter, _ = await Counter.create(
counter, _ = await Counter.factory.create(
context, description=request.description
)
self.state.counter_ids.append(counter.state_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def create_counter(
request: CreateCounterRequest,
) -> CreateCounterResponse:
"""Create a new Counter and return its ID."""
counter, _ = await Counter.create(
counter, _ = await Counter.factory.create(
context,
description=request.description,
owner_id=context.state_id,
Expand Down
10 changes: 7 additions & 3 deletions reboot/examples/bank-nodejs/backend/src/bank_servicer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ export class BankServicer extends Bank.Servicer {
this.state.accountIds.push(newAccountId);

// Let's go create the account.
const [account, response] = await Account.open(context, newAccountId, {
customerName: request.customerName,
});
const [account, response] = await Account.factory.open(
context,
newAccountId,
{
customerName: request.customerName,
}
);

return { accountId: newAccountId };
}
Expand Down
2 changes: 1 addition & 1 deletion reboot/examples/bank-nodejs/backend/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function reportErrorToUser(errorMessage: string): void {
async function performErroringWithdrawal(context: any): Promise<void> {
const accountId = "account-nodejs";

const [account] = await Account.open(context, accountId, {
const [account] = await Account.factory.open(context, accountId, {
customerName: "Tony",
});

Expand Down
2 changes: 1 addition & 1 deletion reboot/examples/bank-pydantic/backend/src/bank_servicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def sign_up(
context: TransactionContext,
request: Bank.SignUpRequest,
) -> None:
await Customer.sign_up(context, request.customer_id)
await Customer.factory.sign_up(context, request.customer_id)

await SortedMap.ref(self.state.customer_ids_map_id).insert(
context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def open_account(
account_id = str(uuid.uuid4())
self.state.account_ids.append(account_id)

account, _ = await Account.open(
account, _ = await Account.factory.open(
context,
account_id,
)
Expand Down
2 changes: 1 addition & 1 deletion reboot/examples/bank-pydantic/backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


async def initialize(context: InitializeContext):
await Bank.create(context, SINGLETON_BANK_ID)
await Bank.factory.create(context, SINGLETON_BANK_ID)


async def main():
Expand Down
Loading
Loading