Skip to content

Commit 84788ad

Browse files
committed
Standardize prettier config and format
1 parent f7d98cc commit 84788ad

File tree

11 files changed

+132
-61
lines changed

11 files changed

+132
-61
lines changed

.expo/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
> Why do I have a folder named ".expo" in my project?
2-
The ".expo" folder is created when an Expo project is started using "expo start" command.
3-
> What do the files contain?
4-
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
5-
- "settings.json": contains the server configuration that is used to serve the application manifest.
6-
> Should I commit the ".expo" folder?
7-
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
8-
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
1+
> Why do I have a folder named ".expo" in my project? The ".expo" folder is
2+
> created when an Expo project is started using "expo start" command. What do
3+
> the files contain?
4+
5+
- "devices.json": contains information about devices that have recently opened
6+
this project. This is used to populate the "Development sessions" list in your
7+
development builds.
8+
- "settings.json": contains the server configuration that is used to serve the
9+
application manifest.
10+
> Should I commit the ".expo" folder? No, you should not share the ".expo"
11+
> folder. It does not contain any information that is relevant for other
12+
> developers working on the project, it is specific to your machine. Upon
13+
> project creation, the ".expo" folder is already added to your ".gitignore"
14+
> file.

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"trailingComma": "all",
3+
"proseWrap": "always"
4+
}

CLAUDE.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Claude Development Notes
22

33
## Codegen Command
4+
45
After making changes to component functions, run codegen with:
6+
57
```bash
68
cd example/ && npm run dev -- --once
79
```
@@ -10,18 +12,23 @@ cd example/ && npm run dev -- --once
1012

1113
When adding new functions to this Convex component:
1214

13-
1. **Client function** (`src/client/index.ts`):
14-
- Add method to `PushNotifications` class that calls `ctx.runMutation(this.component.public.functionName, { ...args, logLevel: this.config.logLevel })`
15+
1. **Client function** (`src/client/index.ts`):
16+
17+
- Add method to `PushNotifications` class that calls
18+
`ctx.runMutation(this.component.public.functionName, { ...args, logLevel: this.config.logLevel })`
1519
- Follow existing patterns for argument types and return types
1620

1721
2. **Component function** (`src/component/public.ts`):
22+
1823
- Define args schema using `v.object()`
1924
- Export mutation/query with proper return type
2025
- Call `ensureCoordinator(ctx)` after processing for coordination
2126

2227
3. **Batch functions**:
23-
- Use existing handler functions (like `sendPushNotificationHandler`) in loops
28+
29+
- Use existing handler functions (like `sendPushNotificationHandler`) in
30+
loops
2431
- Call `ensureCoordinator` once after all processing
2532
- Return array of results matching individual function return types
2633

27-
4. **Always run codegen** after changes to regenerate types
34+
4. **Always run codegen** after changes to regenerate types

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
<!-- START: Include on https://convex.dev/components -->
66

7-
This is a Convex component that integrates with [Expo's push notification API](https://docs.expo.dev/push-notifications/overview/)
8-
to allow sending mobile push notifications to users of your app. It will batch calls to Expo's API and handle retrying delivery.
7+
This is a Convex component that integrates with
8+
[Expo's push notification API](https://docs.expo.dev/push-notifications/overview/)
9+
to allow sending mobile push notifications to users of your app. It will batch
10+
calls to Expo's API and handle retrying delivery.
911

1012
<details>
1113
<summary>Demo GIF</summary>
@@ -51,11 +53,12 @@ export const sendPushNotification = mutation({
5153

5254
## Pre-requisite: Convex
5355

54-
You'll need an existing Convex project to use the component.
55-
Convex is a hosted backend platform, including a database, serverless functions,
56-
and a ton more you can learn about [here](https://docs.convex.dev/get-started).
56+
You'll need an existing Convex project to use the component. Convex is a hosted
57+
backend platform, including a database, serverless functions, and a ton more you
58+
can learn about [here](https://docs.convex.dev/get-started).
5759

58-
Run `npm create convex` or follow any of the [quickstarts](https://docs.convex.dev/home) to set one up.
60+
Run `npm create convex` or follow any of the
61+
[quickstarts](https://docs.convex.dev/home) to set one up.
5962

6063
## Installation
6164

@@ -65,7 +68,8 @@ Install the component package:
6568
npm i @convex-dev/expo-push-notifications
6669
```
6770

68-
Create a `convex.config.ts` file in your app's `convex/` folder and install the component by calling `use`:
71+
Create a `convex.config.ts` file in your app's `convex/` folder and install the
72+
component by calling `use`:
6973

7074
```ts
7175
// convex/convex.config.ts
@@ -88,21 +92,24 @@ import { PushNotifications } from "@convex-dev/expo-push-notifications";
8892
const pushNotifications = new PushNotifications(components.pushNotifications);
8993
```
9094

91-
It takes in an optional type parameter (defaulting to `Id<"users">`) for the type to use as a unique identifier for push notification recipients:
95+
It takes in an optional type parameter (defaulting to `Id<"users">`) for the
96+
type to use as a unique identifier for push notification recipients:
9297

9398
```ts
9499
import { PushNotifications } from "@convex-dev/expo-push-notifications";
95100

96101
export type Email = string & { __isEmail: true };
97102

98103
const pushNotifications = new PushNotifications<Email>(
99-
components.pushNotifications
104+
components.pushNotifications,
100105
);
101106
```
102107

103108
## Registering a user for push notifications
104109

105-
Get a user's push notification token following the Expo documentation [here](https://docs.expo.dev/push-notifications/push-notifications-setup/#registering-for-push-notifications), and record it using a Convex mutation:
110+
Get a user's push notification token following the Expo documentation
111+
[here](https://docs.expo.dev/push-notifications/push-notifications-setup/#registering-for-push-notifications),
112+
and record it using a Convex mutation:
106113

107114
```ts
108115
// convex/example.ts
@@ -118,9 +125,11 @@ export const recordPushNotificationToken = mutation({
118125
});
119126
```
120127

121-
You can pause and resume push notification sending for a user using the `pausePushNotifications` and `resumePushNotifications` methods.
128+
You can pause and resume push notification sending for a user using the
129+
`pausePushNotifications` and `resumePushNotifications` methods.
122130

123-
To determine if a user has a token and their pause status, you can use `getStatusForUser`.
131+
To determine if a user has a token and their pause status, you can use
132+
`getStatusForUser`.
124133

125134
## Send notifications
126135

@@ -139,21 +148,24 @@ export const sendPushNotification = mutation({
139148
});
140149
```
141150

142-
You can use the ID returned from `sendPushNotifications` to query the status of the notification using `getNotification`.
143-
Using this in a query allows you to subscribe to the status of a notification.
151+
You can use the ID returned from `sendPushNotifications` to query the status of
152+
the notification using `getNotification`. Using this in a query allows you to
153+
subscribe to the status of a notification.
144154

145155
You can also view all notifications for a user with `getNotificationsForUser`.
146156

147157
## Troubleshooting
148158

149-
To add more logging, provide `PushNotifications` with a `logLevel` in the constructor:
159+
To add more logging, provide `PushNotifications` with a `logLevel` in the
160+
constructor:
150161

151162
```ts
152163
const pushNotifications = new PushNotifications(components.pushNotifications, {
153164
logLevel: "DEBUG",
154165
});
155166
```
156167

157-
The push notification sender can be shutdown gracefully, and then restarted using the `shutdown` and `restart` methods.
168+
The push notification sender can be shutdown gracefully, and then restarted
169+
using the `shutdown` and `restart` methods.
158170

159171
<!-- END: Include on https://convex.dev/components -->

example/.expo/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
> Why do I have a folder named ".expo" in my project?
2-
The ".expo" folder is created when an Expo project is started using "expo start" command.
3-
> What do the files contain?
4-
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
5-
- "settings.json": contains the server configuration that is used to serve the application manifest.
6-
> Should I commit the ".expo" folder?
7-
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
8-
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.
1+
> Why do I have a folder named ".expo" in my project? The ".expo" folder is
2+
> created when an Expo project is started using "expo start" command. What do
3+
> the files contain?
4+
5+
- "devices.json": contains information about devices that have recently opened
6+
this project. This is used to populate the "Development sessions" list in your
7+
development builds.
8+
- "settings.json": contains the server configuration that is used to serve the
9+
application manifest.
10+
> Should I commit the ".expo" folder? No, you should not share the ".expo"
11+
> folder. It does not contain any information that is relevant for other
12+
> developers working on the project, it is specific to your machine. Upon
13+
> project creation, the ".expo" folder is already added to your ".gitignore"
14+
> file.

example/.expo/types/router.d.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,52 @@
11
/* eslint-disable */
2-
import * as Router from 'expo-router';
2+
import * as Router from "expo-router";
33

4-
export * from 'expo-router';
4+
export * from "expo-router";
55

6-
declare module 'expo-router' {
6+
declare module "expo-router" {
77
export namespace ExpoRouter {
88
export interface __routes<T extends string | object = string> {
9-
hrefInputParams: { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/App`; params?: Router.UnknownInputParams; } | { pathname: `/Demo`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; };
10-
hrefOutputParams: { pathname: Router.RelativePathString, params?: Router.UnknownOutputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams } | { pathname: `/App`; params?: Router.UnknownOutputParams; } | { pathname: `/Demo`; params?: Router.UnknownOutputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownOutputParams; };
11-
href: Router.RelativePathString | Router.ExternalPathString | `/App${`?${string}` | `#${string}` | ''}` | `/Demo${`?${string}` | `#${string}` | ''}` | `/_sitemap${`?${string}` | `#${string}` | ''}` | { pathname: Router.RelativePathString, params?: Router.UnknownInputParams } | { pathname: Router.ExternalPathString, params?: Router.UnknownInputParams } | { pathname: `/App`; params?: Router.UnknownInputParams; } | { pathname: `/Demo`; params?: Router.UnknownInputParams; } | { pathname: `/_sitemap`; params?: Router.UnknownInputParams; };
9+
hrefInputParams:
10+
| {
11+
pathname: Router.RelativePathString;
12+
params?: Router.UnknownInputParams;
13+
}
14+
| {
15+
pathname: Router.ExternalPathString;
16+
params?: Router.UnknownInputParams;
17+
}
18+
| { pathname: `/App`; params?: Router.UnknownInputParams }
19+
| { pathname: `/Demo`; params?: Router.UnknownInputParams }
20+
| { pathname: `/_sitemap`; params?: Router.UnknownInputParams };
21+
hrefOutputParams:
22+
| {
23+
pathname: Router.RelativePathString;
24+
params?: Router.UnknownOutputParams;
25+
}
26+
| {
27+
pathname: Router.ExternalPathString;
28+
params?: Router.UnknownOutputParams;
29+
}
30+
| { pathname: `/App`; params?: Router.UnknownOutputParams }
31+
| { pathname: `/Demo`; params?: Router.UnknownOutputParams }
32+
| { pathname: `/_sitemap`; params?: Router.UnknownOutputParams };
33+
href:
34+
| Router.RelativePathString
35+
| Router.ExternalPathString
36+
| `/App${`?${string}` | `#${string}` | ""}`
37+
| `/Demo${`?${string}` | `#${string}` | ""}`
38+
| `/_sitemap${`?${string}` | `#${string}` | ""}`
39+
| {
40+
pathname: Router.RelativePathString;
41+
params?: Router.UnknownInputParams;
42+
}
43+
| {
44+
pathname: Router.ExternalPathString;
45+
params?: Router.UnknownInputParams;
46+
}
47+
| { pathname: `/App`; params?: Router.UnknownInputParams }
48+
| { pathname: `/Demo`; params?: Router.UnknownInputParams }
49+
| { pathname: `/_sitemap`; params?: Router.UnknownInputParams };
1250
}
1351
}
1452
}

example/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Example app
22

3-
Components need an app that uses them in order to run codegen. An example app is also useful
4-
for testing and documentation.
5-
3+
Components need an app that uses them in order to run codegen. An example app is
4+
also useful for testing and documentation.

example/app/+html.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ScrollViewStyleReset } from 'expo-router/html';
2-
import { type PropsWithChildren } from 'react';
1+
import { ScrollViewStyleReset } from "expo-router/html";
2+
import { type PropsWithChildren } from "react";
33

44
/**
55
* This file is web-only and used to configure the root HTML for every web page during static rendering.
@@ -11,7 +11,10 @@ export default function Root({ children }: PropsWithChildren) {
1111
<head>
1212
<meta charSet="utf-8" />
1313
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
14-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
14+
<meta
15+
name="viewport"
16+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
17+
/>
1518

1619
{/*
1720
Disable body scrolling on web. This makes ScrollView components work closer to how they do on native.

example/app/Demo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function registerForPushNotificationsAsync() {
4343
}
4444
if (finalStatus !== "granted") {
4545
handleRegistrationError(
46-
"Permission not granted to get push token for push notification!"
46+
"Permission not granted to get push token for push notification!",
4747
);
4848
return;
4949
}
@@ -79,7 +79,7 @@ export function Demo() {
7979
const [notifId, setNotifId] = useState<string | null>(null);
8080
const notificationState = useQuery(
8181
api.example.getNotificationStatus,
82-
notifId ? { id: notifId } : "skip"
82+
notifId ? { id: notifId } : "skip",
8383
);
8484
const allUsers = useQuery(api.example.getUsers) ?? [];
8585

@@ -116,7 +116,7 @@ export function Demo() {
116116
(error: unknown) => {
117117
alert(`Error registering for push notifications: ${error}`);
118118
return undefined;
119-
}
119+
},
120120
);
121121
if (token !== undefined) {
122122
await convex

src/client/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PushNotifications<UserType extends string = GenericId<"users">> {
2626
public component: ComponentApi,
2727
config?: {
2828
logLevel?: LogLevel;
29-
}
29+
},
3030
) {
3131
this.component = component;
3232
this.config = {
@@ -42,7 +42,7 @@ export class PushNotifications<UserType extends string = GenericId<"users">> {
4242
*/
4343
recordToken(
4444
ctx: RunMutationCtx,
45-
args: { userId: UserType; pushToken: string }
45+
args: { userId: UserType; pushToken: string },
4646
): Promise<null> {
4747
return ctx.runMutation(this.component.public.recordPushNotificationToken, {
4848
...args,
@@ -92,7 +92,7 @@ export class PushNotifications<UserType extends string = GenericId<"users">> {
9292
userId: UserType;
9393
notification: NotificationFields;
9494
allowUnregisteredTokens?: boolean;
95-
}
95+
},
9696
) {
9797
return ctx.runMutation(this.component.public.sendPushNotification, {
9898
...args,
@@ -115,7 +115,7 @@ export class PushNotifications<UserType extends string = GenericId<"users">> {
115115
notification: NotificationFields;
116116
}>;
117117
allowUnregisteredTokens?: boolean;
118-
}
118+
},
119119
) {
120120
return ctx.runMutation(this.component.public.sendPushNotificationBatch, {
121121
...args,
@@ -139,7 +139,7 @@ export class PushNotifications<UserType extends string = GenericId<"users">> {
139139
*/
140140
getNotificationsForUser(
141141
ctx: RunQueryCtx,
142-
args: { userId: UserType; limit?: number }
142+
args: { userId: UserType; limit?: number },
143143
) {
144144
return ctx.runQuery(this.component.public.getNotificationsForUser, {
145145
...args,

0 commit comments

Comments
 (0)