@atproto/lex-server 0.0.1 → 0.0.3

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.
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-namespace */
3
- /* eslint-disable n/no-extraneous-import */
4
- /* eslint-disable import/no-unresolved */
5
- /* eslint-env node */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const lex_1 = require("@atproto/lex");
8
- const index_js_1 = require("./index.js");
9
- const nodejs_js_1 = require("./nodejs.js");
10
- var com;
11
- (function (com) {
12
- let example;
13
- (function (example) {
14
- let echo;
15
- (function (echo) {
16
- echo.nsid = 'com.example.echo';
17
- echo.message = lex_1.l.typedObject(echo.nsid, 'message', lex_1.l.object({
18
- message: lex_1.l.string(),
19
- }));
20
- echo.main = lex_1.l.subscription(echo.nsid, lex_1.l.params({
21
- message: lex_1.l.string({ minLength: 1 }),
22
- interval: lex_1.l.optional(lex_1.l.integer({ minimum: 0, default: 500 })),
23
- }), lex_1.l.typedUnion([lex_1.l.typedRef(() => echo.message)], false));
24
- })(echo = example.echo || (example.echo = {}));
25
- })(example = com.example || (com.example = {}));
26
- })(com || (com = {}));
27
- const router = new index_js_1.LexRouter({ upgradeWebSocket: nodejs_js_1.upgradeWebSocket })
28
- //
29
- .add(com.example.echo, async function* ({ params: { interval, message } }) {
30
- while (true) {
31
- yield com.example.echo.message.$build({ message });
32
- await new Promise((resolve) => setTimeout(resolve, interval));
33
- }
34
- });
35
- (0, nodejs_js_1.serve)(router, { port: 8080, host: '0.0.0.0' });
36
- //# sourceMappingURL=subscripotion.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subscripotion.js","sourceRoot":"","sources":["../src/subscripotion.ts"],"names":[],"mappings":";AAAA,oDAAoD;AACpD,2CAA2C;AAC3C,yCAAyC;AACzC,qBAAqB;;AAErB,sCAAgC;AAChC,yCAAsC;AACtC,2CAAqD;AAErD,IAAU,GAAG,C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AAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;QAClD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC,CAAC,CAAA;AAEJ,IAAA,iBAAK,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable n/no-extraneous-import */\n/* eslint-disable import/no-unresolved */\n/* eslint-env node */\n\nimport { l } from '@atproto/lex'\nimport { LexRouter } from './index.js'\nimport { serve, upgradeWebSocket } from './nodejs.js'\n\nnamespace com {\n export namespace example {\n export namespace echo {\n export const nsid = 'com.example.echo'\n\n export const message = l.typedObject(\n nsid,\n 'message',\n l.object({\n message: l.string(),\n }),\n )\n\n export const main = l.subscription(\n nsid,\n l.params({\n message: l.string({ minLength: 1 }),\n interval: l.optional(l.integer({ minimum: 0, default: 500 })),\n }),\n l.typedUnion([l.typedRef(() => message)], false),\n )\n }\n }\n}\n\nconst router = new LexRouter({ upgradeWebSocket })\n //\n .add(com.example.echo, async function* ({ params: { interval, message } }) {\n while (true) {\n yield com.example.echo.message.$build({ message })\n await new Promise((resolve) => setTimeout(resolve, interval))\n }\n })\n\nserve(router, { port: 8080, host: '0.0.0.0' })\n"]}
package/dist/test.d.mts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=test.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.d.mts","sourceRoot":"","sources":["../src/test.mjs"],"names":[],"mappings":""}
package/dist/test.mjs DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- /* eslint-env node */
3
- import { l } from '@atproto/lex';
4
- import { LexRouter } from './lex-server.js';
5
- import { startServer, upgradeWebSocket } from './nodejs.js';
6
- const echoMessage = l.typedObject('com.example.echo', 'echoMessage', l.object({
7
- message: l.string(),
8
- }));
9
- const sub = l.subscription('com.example.echo', l.params({
10
- message: l.string({ minLength: 1 }),
11
- }), l.typedUnion([
12
- //
13
- l.typedRef(() => echoMessage),
14
- ], false));
15
- const router = new LexRouter({
16
- upgradeWebSocket,
17
- onMethodNotFound: () => {
18
- return new Response('<h1>404 Not Found</h1>', {
19
- status: 404,
20
- headers: { 'Content-Type': 'text/html' },
21
- });
22
- },
23
- })
24
- //
25
- .add(sub, async function* ({ params: { message } }) {
26
- try {
27
- while (true) {
28
- /** @type {l.TypedObject} */
29
- const item = {
30
- $type: 'com.example.echo#ff',
31
- // @ts-expect-error
32
- message,
33
- };
34
- yield item;
35
- yield echoMessage.$build({ message });
36
- await new Promise((resolve) => setTimeout(resolve, 500));
37
- }
38
- }
39
- finally {
40
- console.log('Subscription ended');
41
- }
42
- });
43
- startServer(router, {
44
- port: 8080,
45
- onError: (err) => {
46
- console.error('Server error:', err);
47
- },
48
- }).then((server) => {
49
- const { port } = /** @type {import('net').AddressInfo} */ (server.address());
50
- console.log(`Server is running on http://localhost:${port}`);
51
- });
52
- //# sourceMappingURL=test.mjs.map
package/dist/test.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"test.mjs","sourceRoot":"","sources":["../src/test.mjs"],"names":[],"mappings":";AAAA,qBAAqB;AAErB,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE3D,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAC/B,kBAAkB,EAClB,aAAa,EACb,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CACH,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,CAAC,YAAY,CACxB,kBAAkB,EAClB,CAAC,CAAC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AAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;IACjB,MAAM,EAAE,IAAI,EAAE,GAAG,wCAAwC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5E,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,EAAE,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAA","sourcesContent":["/* eslint-env node */\n\nimport { l } from '@atproto/lex'\nimport { LexRouter } from './lex-server.js'\nimport { startServer, upgradeWebSocket } from './nodejs.js'\n\nconst echoMessage = l.typedObject(\n 'com.example.echo',\n 'echoMessage',\n l.object({\n message: l.string(),\n }),\n)\n\nconst sub = l.subscription(\n 'com.example.echo',\n l.params({\n message: l.string({ minLength: 1 }),\n }),\n l.typedUnion(\n [\n //\n l.typedRef(() => echoMessage),\n ],\n false,\n ),\n)\n\nconst router = new LexRouter({\n upgradeWebSocket,\n onMethodNotFound: () => {\n return new Response('<h1>404 Not Found</h1>', {\n status: 404,\n headers: { 'Content-Type': 'text/html' },\n })\n },\n})\n //\n .add(sub, async function* ({ params: { message } }) {\n try {\n while (true) {\n /** @type {l.TypedObject} */\n const item = {\n $type: 'com.example.echo#ff',\n // @ts-expect-error\n message,\n }\n\n yield item\n yield echoMessage.$build({ message })\n await new Promise((resolve) => setTimeout(resolve, 500))\n }\n } finally {\n console.log('Subscription ended')\n }\n })\n\nstartServer(router, {\n port: 8080,\n onError: (err) => {\n console.error('Server error:', err)\n },\n}).then((server) => {\n const { port } = /** @type {import('net').AddressInfo} */ (server.address())\n console.log(`Server is running on http://localhost:${port}`)\n})\n"]}