feat(storage): generalize S3 client and watcher interfaces to storage-oriented naming with backward compatibility
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import * as smartbucket from '../ts/index.js';
|
||||
import type { IS3ChangeEvent } from '../ts/interfaces.js';
|
||||
import type { IStorageChangeEvent } from '../ts/interfaces.js';
|
||||
|
||||
// Get test configuration
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
@@ -57,7 +57,7 @@ tap.test('should create watcher with custom options', async () => {
|
||||
// ==========================
|
||||
|
||||
tap.test('should detect add events for new files', async () => {
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-test/',
|
||||
pollIntervalMs: 500,
|
||||
@@ -94,7 +94,7 @@ tap.test('should detect add events for new files', async () => {
|
||||
// ==========================
|
||||
|
||||
tap.test('should detect modify events for changed files', async () => {
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-test/',
|
||||
pollIntervalMs: 500,
|
||||
@@ -131,7 +131,7 @@ tap.test('should detect modify events for changed files', async () => {
|
||||
// ==========================
|
||||
|
||||
tap.test('should detect delete events for removed files', async () => {
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-test/',
|
||||
pollIntervalMs: 500,
|
||||
@@ -174,7 +174,7 @@ tap.test('should emit initial state as add events when includeInitial is true',
|
||||
contents: 'content 2',
|
||||
});
|
||||
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-initial/',
|
||||
pollIntervalMs: 10000, // Long interval - we only care about initial events
|
||||
@@ -206,13 +206,13 @@ tap.test('should emit initial state as add events when includeInitial is true',
|
||||
// ==========================
|
||||
|
||||
tap.test('should emit events via EventEmitter pattern', async () => {
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-emitter/',
|
||||
pollIntervalMs: 500,
|
||||
});
|
||||
|
||||
watcher.on('change', (event: IS3ChangeEvent) => {
|
||||
watcher.on('change', (event: IStorageChangeEvent) => {
|
||||
events.push(event);
|
||||
});
|
||||
|
||||
@@ -239,7 +239,7 @@ tap.test('should emit events via EventEmitter pattern', async () => {
|
||||
// ==========================
|
||||
|
||||
tap.test('should buffer events when bufferTimeMs is set', async () => {
|
||||
const bufferedEvents: (IS3ChangeEvent | IS3ChangeEvent[])[] = [];
|
||||
const bufferedEvents: (IStorageChangeEvent | IStorageChangeEvent[])[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-buffer/',
|
||||
pollIntervalMs: 200,
|
||||
@@ -327,8 +327,8 @@ tap.test('should stop gracefully with stop()', async () => {
|
||||
await watcher.stop();
|
||||
|
||||
// Watcher should not poll after stop
|
||||
const eventsCaptured: IS3ChangeEvent[] = [];
|
||||
watcher.on('change', (event: IS3ChangeEvent) => {
|
||||
const eventsCaptured: IStorageChangeEvent[] = [];
|
||||
watcher.on('change', (event: IStorageChangeEvent) => {
|
||||
eventsCaptured.push(event);
|
||||
});
|
||||
|
||||
@@ -362,7 +362,7 @@ tap.test('should stop gracefully with close() alias', async () => {
|
||||
// ==========================
|
||||
|
||||
tap.test('should only detect changes within specified prefix', async () => {
|
||||
const events: IS3ChangeEvent[] = [];
|
||||
const events: IStorageChangeEvent[] = [];
|
||||
const watcher = testBucket.createWatcher({
|
||||
prefix: 'watcher-prefix-a/',
|
||||
pollIntervalMs: 500,
|
||||
|
||||
Reference in New Issue
Block a user