create-wirejs-app 2.0.176 → 2.0.178

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wirejs-app",
3
- "version": "2.0.176",
3
+ "version": "2.0.178",
4
4
  "description": "Initializes a wirejs package.",
5
5
  "author": "Jon Wire",
6
6
  "license": "MIT",
@@ -0,0 +1,7 @@
1
+ {
2
+ "from": "wirejs-test@thepointless.com",
3
+ "to": "iambipedal@gmail.com",
4
+ "subject": "[wirejs test] first test",
5
+ "body": "This is a test message from your wirejs app:\n\nsome message body",
6
+ "sentAt": "2026-02-25T23:28:44.056Z"
7
+ }
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  AuthenticationApi,
3
3
  BackgroundJob,
4
- CronJob,
5
4
  RealtimeService,
6
5
  withContext,
7
6
  } from "wirejs-resources";
@@ -32,22 +31,6 @@ const counter = new BackgroundJob('app', 'countdowns', {
32
31
  },
33
32
  });
34
33
 
35
- new CronJob('app', 'chat-ping', {
36
- schedule: '*/5 * * * *',
37
- async handler() {
38
- const now = new Date();
39
- const nowString = now.toLocaleString();
40
- const tzOffset = now.getTimezoneOffset() / 60;
41
- const tzOffsetString = tzOffset ? `+${tzOffset}` : `-${tzOffset}`;
42
- const tz = `UTC${tzOffsetString}`;
43
-
44
- realtimeService.publish('test', [{
45
- username: 'cron',
46
- body: `Hi. Just here to let you know what time it is. It's ${nowString} ${tz} ...`
47
- }])
48
- }
49
- });
50
-
51
34
  export const Chat = (auth: AuthenticationApi) => withContext(context => ({
52
35
  async publish(room: string, message: string) {
53
36
  const user = await auth.requireCurrentUser(context);
@@ -0,0 +1,21 @@
1
+ import { AuthenticationApi, EmailSender, withContext } from 'wirejs-resources';
2
+
3
+ const testMailer = new EmailSender('app', 'testMailer', {
4
+ from: 'wirejs-test@thepointless.com'
5
+ });
6
+
7
+ export const Mailer = (auth: AuthenticationApi) => withContext(context => ({
8
+ /**
9
+ * Send a test message to yourself.
10
+ *
11
+ * @param body
12
+ */
13
+ async sendTestMessage(subject: string, body: string) {
14
+ const user = await auth.requireCurrentUser(context);
15
+ await testMailer.send({
16
+ to: user.username,
17
+ body: `This is a test message from your wirejs app:\n\n${body}`,
18
+ subject: `[wirejs test] ${subject}`
19
+ });
20
+ }
21
+ }));
@@ -5,6 +5,7 @@ import { Wiki } from './apps/wiki.js';
5
5
  import { Store } from './apps/store.js';
6
6
  import { Admin } from './apps/admin.js';
7
7
  import { LLM } from './apps/llm/index.js';
8
+ import { Mailer } from './apps/email.js';
8
9
 
9
10
  export type * from './apps/llm/index.js';
10
11
  export type * from './apps/todos.js';
@@ -22,6 +23,7 @@ export const wiki = Wiki(auth);
22
23
  export const store = Store(auth);
23
24
  export const admin = Admin(auth);
24
25
  export const llm = LLM(auth);
26
+ export const mailer = Mailer(auth);
25
27
 
26
28
  new Endpoint('app', 'sample-endpoint', {
27
29
  description: "Sample endpoint to show programmatic endpoint creation.",
@@ -8,3 +8,4 @@ api/index.js
8
8
  api/dist
9
9
  workers/dist
10
10
  *.swp
11
+ .outbox
@@ -11,15 +11,15 @@
11
11
  "dependencies": {
12
12
  "dompurify": "^3.2.3",
13
13
  "marked": "^15.0.6",
14
- "wirejs-components": "^0.1.114",
14
+ "wirejs-components": "^0.1.116",
15
15
  "wirejs-dom": "^1.0.44",
16
- "wirejs-module-payments-stripe": "^0.1.65",
17
- "wirejs-resources": "^0.1.171",
18
- "wirejs-web-worker": "^1.0.68"
16
+ "wirejs-module-payments-stripe": "^0.1.67",
17
+ "wirejs-resources": "^0.1.173",
18
+ "wirejs-web-worker": "^1.0.70"
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "^5.7.3",
22
- "wirejs-scripts": "^3.0.169"
22
+ "wirejs-scripts": "^3.0.171"
23
23
  },
24
24
  "scripts": {
25
25
  "prebuild": "npm run prebuild --workspaces --if-present",
@@ -1,5 +1,4 @@
1
1
  import { html, list, node, text, hydrate } from 'wirejs-dom/v2';
2
- import { AuthenticatedContent } from 'wirejs-components';
3
2
  import { Main } from '../layouts/main.js';
4
3
  import { admin, Endpoint, Setting, SystemAttribute } from 'internal-api';
5
4
 
@@ -155,15 +154,14 @@ function Admin() {
155
154
 
156
155
  async function App() {
157
156
  const self = html`<div id='app'>
158
- ${await AuthenticatedContent({
159
- authenticated: async () => {
160
- return (await admin.isAdmin(null)) ?
161
- html`<div><p>Your <b>are</b> an admin.</p>${Admin()}</div>`
162
- : html`<p>You are <b>NOT</b> an admin.</p>`
163
- },
164
- unauthenticated: () => html`<p>You are not signed in.</p>`,
165
- })}
166
- </div>`;
157
+ ${node('isAdmin', false, (isAdmin: boolean | undefined) =>
158
+ isAdmin ?
159
+ html`<div><p>Your <b>are</b> an admin.</p>${Admin()}</div>`
160
+ : html`<p>You are <b>NOT</b> an admin.</p>`
161
+ )}
162
+ </div>`.onadd(async self => {
163
+ self.data.isAdmin = await admin.isAdmin(null);
164
+ });
167
165
  return self;
168
166
  }
169
167
 
@@ -0,0 +1,57 @@
1
+ import { html, list, attribute, hydrate } from 'wirejs-dom/v2';
2
+ import { AuthenticatedContent } from 'wirejs-components';
3
+ import { mailer } from 'internal-api';
4
+ import { Main } from '../layouts/main.js';
5
+
6
+ function Email() {
7
+ const send = async (subject: string, body: string) => {
8
+ try {
9
+ await mailer.sendTestMessage(undefined, subject, body);
10
+ alert("Message sent!");
11
+ } catch {
12
+ alert("Send failed.");
13
+ }
14
+ }
15
+
16
+ const self = html`<div>
17
+ <h4>Email test</h4>
18
+ <div>
19
+ <form onsubmit=${(event: Event) => {
20
+ event.preventDefault();
21
+ const subject = self.data.subject;
22
+ const body = self.data.body;
23
+ self.data.subject = '';
24
+ self.data.body = '';
25
+ send(subject, body);
26
+ }}>
27
+ <p>Subject: <input type='text' value=${attribute('subject', '' as string)} /></p>
28
+ <p>Body: <input type='text' value=${attribute('body', '' as string)} /></p>
29
+ <input type='submit' value='Send' />
30
+ </form>
31
+ </div>
32
+ <div>`;
33
+
34
+ return self;
35
+ }
36
+
37
+ async function App() {
38
+ const self = html`<div id='app'>
39
+ ${await AuthenticatedContent({
40
+ authenticated: () => Email(),
41
+ unauthenticated: () => html`<div>
42
+ You need to sign in to send a message.
43
+ </div>`
44
+ })}
45
+ </div>`;
46
+
47
+ return self;
48
+ }
49
+
50
+ export async function generate() {
51
+ return Main({
52
+ pageTitle: 'Emailer Test',
53
+ content: await App(),
54
+ });
55
+ }
56
+
57
+ hydrate('app', App as any);
@@ -14,6 +14,7 @@ export async function generate() {
14
14
  <li><a href='/web-worker-test.html'>Web Worker Test</a></li>
15
15
  <li><a href='/storefront.html'>Storefront</a></li>
16
16
  <li><a href='/llm-test.html'>LLM Test</a></li>
17
+ <li><a href='/email.html'>Email Test</a></li>
17
18
  <li><a href='/admin.html'>Admin</a></li>
18
19
  </ul>
19
20
  </div>`