You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

import {
Rename modules from 4-letter aliases to full English words Drops the 4-letter alias convention in favour of a single homogeneous naming axis: full English words across filesystem, alias, wire format and constants. Module renames: - arts/aapp → arts/active-app (libs/aapp also) - arts/buss → arts/bus (libs/buss also) - arts/cach → arts/cache (libs/cach + svrs/cach also) - arts/conn → arts/connection - arts/fend → arts/frontend - arts/fmts → arts/formats (curr→currency, nums→numbers, unts→units) - arts/logr → arts/logger (libs/logr also) - arts/perm → arts/permissions (libs/perm + svrs/perm also) - arts/sess → arts/session - arts/stor → arts/storage - arts/timr → arts/timer (libs/timers → libs/timer) Modules left as-is: auth, dom, errs, http, lang, sium (already match their canonical name or are proper names). Special case: `aapp` could not become `app` because `$app` is reserved by SvelteKit (`$app/stores`, `$app/navigation`, ...). Compromise: - Filesystem and alias use `active-app` / `$active-app`. - Constants and class names use `App` / `APP_*` (no `active-` prefix). The `active-` prefix only disambiguates the alias from SvelteKit's namespace; the module is App. Special case: `permissions` keeps the plural for filesystem/alias/wire but constants and classes use the singular `PERMISSION_*` / `Permission*` because they describe the concept ("a permission effect"), not the module collection. Constants follow the new module name in caps: `STORAGE_*`, `BUS_*`, `CACHE_*`, `CONNECTION_*`, `FORMATS_*`, `LOGGER_*`, `SESSION_*`, `TIMER_*`, etc. Module values: `STORAGE_MODULE = 'storage'`, `BUS_MODULE = 'bus'`, `APP_MODULE = 'app'`, `PERMISSION_MODULE = 'permissions'`, etc. Wire/code format moved accordingly: `'storage::*'`, `'bus::*'`, `'session::*'`, `'permissions::*'`, etc. Diagnostic event values updated: `'storage.error'`, `'bus.event.published'`, `'connection.auth_failed'`, etc. App events use `'app.*'`: `AAPP_EVENT_* → APP_EVENT_*` with values `'app.user.identity.changed'`. Class renames (where they used the abbreviation): - AappAlreadyCreatedError → AppAlreadyCreatedError - BussError* → BusError* (where applicable) - Cach* → Cache* - Conn* → Connection* (e.g. ConnDisposedError → ConnectionDisposedError; ConnConnection* collapsed to Connection*) - Logr*Error → Logger*Error - Sess* → Session* (SessInvalidSessionError → SessionInvalidError) - Stor* → Storage* - Timr* → Timer* (TimrInactiveTimerError → TimerInactiveError) - AuthCachPort → AuthCachePort - AuthClientCach* → AuthClientCache* - AuthPermPort → AuthPermissionsPort Property renames in option types: - `cach?:` → `cache?:` in AuthClient options - `logr:` → `logger:` in svrs/auth ports - `timr:` → `timer:` in svrs/auth ports `docs/conventions.md` rewritten: - Rule 1 dropped the 4-letter alias mandate; lists the full English module names and special-cases active-app, lang, sium, permissions. - Rule 2 documents the new constant prefix convention and its two exceptions (APP_* for active-app, PERMISSION_* singular for permissions). - Rule 6 codifies that all error infrastructure (codes, messages, classes, guards) lives in a single `errors.ts` per module — removing the `consts.ts` / `errors.ts` split for error-related symbols. `libs/errs` adds `ErrorMessages` type so every module can declare its catalog as `<MOD>_ERROR_MESSAGES: ErrorMessages` instead of repeating the `Readonly<Record<ErrCode, string | (...args) => string>>` shape. Storage migrated as the first proof of the canonical pattern. All 1334 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
CONNECTION_CONNECT_REASON_DISPOSED,
CONNECTION_STATE_OPEN
} from './consts.ts';
import type { ConnectionConnectResult, ConnectionState } from './types.ts';
export interface ConnectionConnectController {
connect(reconnect: boolean): Promise<ConnectionConnectResult>;
}
export interface ConnectionConnectControllerOptions {
getState(): ConnectionState;
isDisposed(): boolean;
isConnected(): boolean;
beforeAttempt(): void;
runConnect(reconnect: boolean): Promise<ConnectionConnectResult>;
}
export function createConnectionConnectController(
options: ConnectionConnectControllerOptions
): ConnectionConnectController {
let connectPromise: Promise<ConnectionConnectResult> | null = null;
function connect(reconnect: boolean): Promise<ConnectionConnectResult> {
const state = options.getState();
if (options.isDisposed()) {
return Promise.resolve({
ok: false,
state,
Rename modules from 4-letter aliases to full English words Drops the 4-letter alias convention in favour of a single homogeneous naming axis: full English words across filesystem, alias, wire format and constants. Module renames: - arts/aapp → arts/active-app (libs/aapp also) - arts/buss → arts/bus (libs/buss also) - arts/cach → arts/cache (libs/cach + svrs/cach also) - arts/conn → arts/connection - arts/fend → arts/frontend - arts/fmts → arts/formats (curr→currency, nums→numbers, unts→units) - arts/logr → arts/logger (libs/logr also) - arts/perm → arts/permissions (libs/perm + svrs/perm also) - arts/sess → arts/session - arts/stor → arts/storage - arts/timr → arts/timer (libs/timers → libs/timer) Modules left as-is: auth, dom, errs, http, lang, sium (already match their canonical name or are proper names). Special case: `aapp` could not become `app` because `$app` is reserved by SvelteKit (`$app/stores`, `$app/navigation`, ...). Compromise: - Filesystem and alias use `active-app` / `$active-app`. - Constants and class names use `App` / `APP_*` (no `active-` prefix). The `active-` prefix only disambiguates the alias from SvelteKit's namespace; the module is App. Special case: `permissions` keeps the plural for filesystem/alias/wire but constants and classes use the singular `PERMISSION_*` / `Permission*` because they describe the concept ("a permission effect"), not the module collection. Constants follow the new module name in caps: `STORAGE_*`, `BUS_*`, `CACHE_*`, `CONNECTION_*`, `FORMATS_*`, `LOGGER_*`, `SESSION_*`, `TIMER_*`, etc. Module values: `STORAGE_MODULE = 'storage'`, `BUS_MODULE = 'bus'`, `APP_MODULE = 'app'`, `PERMISSION_MODULE = 'permissions'`, etc. Wire/code format moved accordingly: `'storage::*'`, `'bus::*'`, `'session::*'`, `'permissions::*'`, etc. Diagnostic event values updated: `'storage.error'`, `'bus.event.published'`, `'connection.auth_failed'`, etc. App events use `'app.*'`: `AAPP_EVENT_* → APP_EVENT_*` with values `'app.user.identity.changed'`. Class renames (where they used the abbreviation): - AappAlreadyCreatedError → AppAlreadyCreatedError - BussError* → BusError* (where applicable) - Cach* → Cache* - Conn* → Connection* (e.g. ConnDisposedError → ConnectionDisposedError; ConnConnection* collapsed to Connection*) - Logr*Error → Logger*Error - Sess* → Session* (SessInvalidSessionError → SessionInvalidError) - Stor* → Storage* - Timr* → Timer* (TimrInactiveTimerError → TimerInactiveError) - AuthCachPort → AuthCachePort - AuthClientCach* → AuthClientCache* - AuthPermPort → AuthPermissionsPort Property renames in option types: - `cach?:` → `cache?:` in AuthClient options - `logr:` → `logger:` in svrs/auth ports - `timr:` → `timer:` in svrs/auth ports `docs/conventions.md` rewritten: - Rule 1 dropped the 4-letter alias mandate; lists the full English module names and special-cases active-app, lang, sium, permissions. - Rule 2 documents the new constant prefix convention and its two exceptions (APP_* for active-app, PERMISSION_* singular for permissions). - Rule 6 codifies that all error infrastructure (codes, messages, classes, guards) lives in a single `errors.ts` per module — removing the `consts.ts` / `errors.ts` split for error-related symbols. `libs/errs` adds `ErrorMessages` type so every module can declare its catalog as `<MOD>_ERROR_MESSAGES: ErrorMessages` instead of repeating the `Readonly<Record<ErrCode, string | (...args) => string>>` shape. Storage migrated as the first proof of the canonical pattern. All 1334 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
reason: CONNECTION_CONNECT_REASON_DISPOSED
});
}
Rename modules from 4-letter aliases to full English words Drops the 4-letter alias convention in favour of a single homogeneous naming axis: full English words across filesystem, alias, wire format and constants. Module renames: - arts/aapp → arts/active-app (libs/aapp also) - arts/buss → arts/bus (libs/buss also) - arts/cach → arts/cache (libs/cach + svrs/cach also) - arts/conn → arts/connection - arts/fend → arts/frontend - arts/fmts → arts/formats (curr→currency, nums→numbers, unts→units) - arts/logr → arts/logger (libs/logr also) - arts/perm → arts/permissions (libs/perm + svrs/perm also) - arts/sess → arts/session - arts/stor → arts/storage - arts/timr → arts/timer (libs/timers → libs/timer) Modules left as-is: auth, dom, errs, http, lang, sium (already match their canonical name or are proper names). Special case: `aapp` could not become `app` because `$app` is reserved by SvelteKit (`$app/stores`, `$app/navigation`, ...). Compromise: - Filesystem and alias use `active-app` / `$active-app`. - Constants and class names use `App` / `APP_*` (no `active-` prefix). The `active-` prefix only disambiguates the alias from SvelteKit's namespace; the module is App. Special case: `permissions` keeps the plural for filesystem/alias/wire but constants and classes use the singular `PERMISSION_*` / `Permission*` because they describe the concept ("a permission effect"), not the module collection. Constants follow the new module name in caps: `STORAGE_*`, `BUS_*`, `CACHE_*`, `CONNECTION_*`, `FORMATS_*`, `LOGGER_*`, `SESSION_*`, `TIMER_*`, etc. Module values: `STORAGE_MODULE = 'storage'`, `BUS_MODULE = 'bus'`, `APP_MODULE = 'app'`, `PERMISSION_MODULE = 'permissions'`, etc. Wire/code format moved accordingly: `'storage::*'`, `'bus::*'`, `'session::*'`, `'permissions::*'`, etc. Diagnostic event values updated: `'storage.error'`, `'bus.event.published'`, `'connection.auth_failed'`, etc. App events use `'app.*'`: `AAPP_EVENT_* → APP_EVENT_*` with values `'app.user.identity.changed'`. Class renames (where they used the abbreviation): - AappAlreadyCreatedError → AppAlreadyCreatedError - BussError* → BusError* (where applicable) - Cach* → Cache* - Conn* → Connection* (e.g. ConnDisposedError → ConnectionDisposedError; ConnConnection* collapsed to Connection*) - Logr*Error → Logger*Error - Sess* → Session* (SessInvalidSessionError → SessionInvalidError) - Stor* → Storage* - Timr* → Timer* (TimrInactiveTimerError → TimerInactiveError) - AuthCachPort → AuthCachePort - AuthClientCach* → AuthClientCache* - AuthPermPort → AuthPermissionsPort Property renames in option types: - `cach?:` → `cache?:` in AuthClient options - `logr:` → `logger:` in svrs/auth ports - `timr:` → `timer:` in svrs/auth ports `docs/conventions.md` rewritten: - Rule 1 dropped the 4-letter alias mandate; lists the full English module names and special-cases active-app, lang, sium, permissions. - Rule 2 documents the new constant prefix convention and its two exceptions (APP_* for active-app, PERMISSION_* singular for permissions). - Rule 6 codifies that all error infrastructure (codes, messages, classes, guards) lives in a single `errors.ts` per module — removing the `consts.ts` / `errors.ts` split for error-related symbols. `libs/errs` adds `ErrorMessages` type so every module can declare its catalog as `<MOD>_ERROR_MESSAGES: ErrorMessages` instead of repeating the `Readonly<Record<ErrCode, string | (...args) => string>>` shape. Storage migrated as the first proof of the canonical pattern. All 1334 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 months ago
if (state === CONNECTION_STATE_OPEN && options.isConnected()) {
return Promise.resolve({ ok: true, state, reused: true });
}
if (connectPromise !== null) return connectPromise;
connectPromise = (async () => {
options.beforeAttempt();
try {
return await options.runConnect(reconnect);
} finally {
connectPromise = null;
}
})();
return connectPromise;
}
return { connect };
}

Powered by TurnKey Linux.