@boxxy/notifier-atc 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 the boxxy authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
+ <h1>@boxxy/notifier-atc</h1>
2
3
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/@boxxy/notifier-atc"><img src="https://img.shields.io/npm/v/@boxxy/notifier-atc" alt="npm version"></a>
6
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
7
+ </p>
8
+
9
+ <p>
10
+ <a href="../../docs/design/boxxy/README.md">Documentation</a>
11
+ </p>
12
+ </div>
13
+
14
+ boxxy's `Notifier` port on atc: a hold notice arrives as one atc message in one named session.
15
+
16
+ ## Install
17
+
18
+ Install the package from [npm](https://www.npmjs.com/package/@boxxy/notifier-atc) with Bun:
19
+
20
+ ```bash
21
+ bun add @boxxy/notifier-atc
22
+ ```
23
+
24
+ The package runs on [Bun](https://bun.sh) 1.3 or newer.
25
+
26
+ ## Features
27
+
28
+ - `createAtcNotifier({ client, session })` returns a `Notifier`. The message names the item and the
29
+ reason, and says the owner next runs `boxxy item note` and `boxxy item retry`.
30
+ - The client is one call, `sendMessage`. The app builds it from its atc connection.
31
+ - A send that fails, or that atc refuses, returns the failed outcome and never throws.
32
+
33
+ ## Documentation
34
+
35
+ [Notices in v1](../../docs/design/boxxy/v1.md#notices) describes when a notice is written and sent.
@@ -0,0 +1,3 @@
1
+ import type { Notifier } from '@boxxy/model';
2
+ import type { AtcNotifierOptions } from './types.ts';
3
+ export declare function createAtcNotifier(options: AtcNotifierOptions): Notifier;
@@ -0,0 +1,2 @@
1
+ export { createAtcNotifier } from './create-atc-notifier.ts';
2
+ export type { AtcMessageClient, AtcNotifierOptions, AtcSendRequest } from './types.ts';
@@ -0,0 +1,12 @@
1
+ export interface AtcSendRequest {
2
+ readonly session: string;
3
+ readonly text: string;
4
+ readonly idempotencyKey: string;
5
+ }
6
+ export interface AtcMessageClient {
7
+ sendMessage: (request: AtcSendRequest) => Promise<unknown>;
8
+ }
9
+ export interface AtcNotifierOptions {
10
+ readonly client: AtcMessageClient;
11
+ readonly session: string;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "@boxxy/notifier-atc",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "boxxy's hold notice sent as an atc message to one named session",
5
+ "homepage": "https://github.com/zgeoff/boxxy/tree/main/adapters/notifier-atc#readme",
6
+ "bugs": "https://github.com/zgeoff/boxxy/issues",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/zgeoff/boxxy.git",
11
+ "directory": "adapters/notifier-atc"
12
+ },
13
+ "files": [
14
+ "src",
15
+ "!src/**/*.test.ts",
16
+ "dist"
17
+ ],
18
+ "type": "module",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./src/index.ts"
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "scripts": {
29
+ "build": "rm -rf dist && tsrs -p tsconfig.build.json",
30
+ "typecheck": "tsrs --noEmit"
31
+ },
32
+ "dependencies": {
33
+ "@boxxy/model": "0.1.3"
34
+ },
35
+ "engines": {
36
+ "bun": ">=1.3",
37
+ "node": ">=24"
38
+ }
39
+ }
@@ -0,0 +1,47 @@
1
+ import type { HoldNotice, Notifier } from '@boxxy/model';
2
+ import type { AtcNotifierOptions } from './types.ts';
3
+
4
+ export function createAtcNotifier(options: AtcNotifierOptions): Notifier {
5
+ return {
6
+ async tellHold(notice) {
7
+ try {
8
+ await options.client.sendMessage({
9
+ session: options.session,
10
+ text: formatHoldMessage(notice),
11
+ idempotencyKey: buildIdempotencyKey(notice),
12
+ });
13
+ } catch (error) {
14
+ return { kind: 'failed', reason: toFailureReason(error) };
15
+ }
16
+
17
+ return { kind: 'sent' };
18
+ },
19
+ };
20
+ }
21
+
22
+ function formatHoldMessage(notice: HoldNotice): string {
23
+ return [
24
+ `boxxy put ${notice.item} on hold: ${notice.reason}.`,
25
+ `Add a note with \`boxxy item note ${notice.item}\`, then run \`boxxy item retry ${notice.item}\`.`,
26
+ ].join('\n');
27
+ }
28
+
29
+ // The port's notice has no id or try count; the item, the reason and the time name the notice,
30
+ // so a later try of the same notice repeats the key.
31
+ function buildIdempotencyKey(notice: HoldNotice): string {
32
+ return `boxxy-hold:${notice.item}:${notice.reason}:${notice.at}`;
33
+ }
34
+
35
+ // Only a string `code` is kept: an error message may carry text that must not reach the log.
36
+ function toFailureReason(error: unknown): string {
37
+ if (
38
+ typeof error === 'object' &&
39
+ error !== null &&
40
+ 'code' in error &&
41
+ typeof error.code === 'string'
42
+ ) {
43
+ return error.code;
44
+ }
45
+
46
+ return 'atc send failed';
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { createAtcNotifier } from './create-atc-notifier.ts';
2
+ export type { AtcMessageClient, AtcNotifierOptions, AtcSendRequest } from './types.ts';
package/src/types.ts ADDED
@@ -0,0 +1,17 @@
1
+ export interface AtcSendRequest {
2
+ // the name or the id of the session that gets the message
3
+ readonly session: string;
4
+ readonly text: string;
5
+ readonly idempotencyKey: string;
6
+ }
7
+
8
+ // The one call the adapter needs. It resolves when atc takes the message and rejects when atc
9
+ // refuses it or cannot be reached; a rejection may carry a string `code`, such as `no_such_session`.
10
+ export interface AtcMessageClient {
11
+ sendMessage: (request: AtcSendRequest) => Promise<unknown>;
12
+ }
13
+
14
+ export interface AtcNotifierOptions {
15
+ readonly client: AtcMessageClient;
16
+ readonly session: string;
17
+ }