ac-storage 0.14.1 → 0.15.0

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/dist/index.d.ts CHANGED
@@ -168,7 +168,7 @@ type AccessTree = {
168
168
  };
169
169
  type StorageAccessControlEvent = {
170
170
  onAccess: (identifier: string, accessType: Accesses) => Promise<IAccessorManager<unknown>>;
171
- onRelease: (identifier: string) => Promise<void>;
171
+ onDestroy: (identifier: string) => Promise<void>;
172
172
  onChainDependency: (idDependBy: string, idDependTo: string) => void;
173
173
  };
174
174
 
@@ -180,9 +180,10 @@ declare class StorageAccessControl {
180
180
  copy(oldIdentifier: string, newIdentifier: string, accessType: string): Promise<void>;
181
181
  move(oldIdentifier: string, newIdentifier: string, accessType: string): Promise<void>;
182
182
  access(identifier: string, accessType: string): Promise<unknown>;
183
- release(identifier: string): Promise<void>;
184
- releaseDir(identifier: string): Promise<void>;
183
+ destroy(identifier: string): Promise<void>;
184
+ destroyDir(identifier: string): Promise<void>;
185
185
  getAccessType(identifier: string): string[];
186
+ validateAccess(identifier: string, accessType: string): Accesses;
186
187
  validateDirectoryPath(identifier: string): void;
187
188
  private validateAndResolveAccess;
188
189
  /**
@@ -212,10 +213,11 @@ declare class DirectoryAccessError extends StorageError {
212
213
  }
213
214
 
214
215
  interface IACStorage extends IACSubStorage {
215
- addListener(event: 'release' | 'access', listener: Function): void;
216
+ addListener(event: 'destroy' | 'access', listener: Function): void;
216
217
  register(tree: AccessTree): void;
217
218
  addAccessEvent<T extends string, AC>(customId: (T extends AccessType ? never : T), event: AccessorEvent<AC>): void;
218
219
  dropAll(): Promise<void>;
220
+ releaseAll(): Promise<void>;
219
221
  }
220
222
  interface IACSubStorage {
221
223
  subStorage(prefix: string): IACSubStorage;
@@ -223,11 +225,22 @@ interface IACSubStorage {
223
225
  accessAsJSON(identifier: string): Promise<IJSONAccessor>;
224
226
  accessAsText(identifier: string): Promise<ITextAccessor>;
225
227
  accessAsBinary(identifier: string): Promise<IBinaryAccessor>;
228
+ create(identifier: string, accessType: string): Promise<unknown>;
229
+ createAsJSON(identifier: string): Promise<IJSONAccessor>;
230
+ createAsText(identifier: string): Promise<ITextAccessor>;
231
+ createAsBinary(identifier: string): Promise<IBinaryAccessor>;
232
+ open(identifier: string, accessType: string): Promise<unknown>;
233
+ openAsJSON(identifier: string): Promise<IJSONAccessor>;
234
+ openAsText(identifier: string): Promise<ITextAccessor>;
235
+ openAsBinary(identifier: string): Promise<IBinaryAccessor>;
226
236
  copy(oldIdentifier: string, newIdentifier: string): Promise<void>;
227
237
  move(oldIdentifier: string, newIdentifier: string): Promise<void>;
228
238
  dropDir(identifier: string): Promise<void>;
229
239
  drop(identifier: string): Promise<void>;
230
240
  dropAll(): Promise<void>;
241
+ release(identifier: string): Promise<void>;
242
+ releaseDir(identifier: string): Promise<void>;
243
+ releaseAll(): Promise<void>;
231
244
  commit(identifier: string): Promise<void>;
232
245
  commitAll(): Promise<void>;
233
246
  }
@@ -241,8 +254,8 @@ declare class ACStorage implements IACStorage {
241
254
  protected eventListeners: {
242
255
  access?: Function;
243
256
  access_dir?: Function;
244
- release?: Function;
245
- release_dir?: Function;
257
+ destroy?: Function;
258
+ destroy_dir?: Function;
246
259
  };
247
260
  protected cachePath: string;
248
261
  protected noCache: boolean;
@@ -255,8 +268,10 @@ declare class ACStorage implements IACStorage {
255
268
  constructor(basePath: string, option?: ACStorageOption);
256
269
  protected loadCache(): void;
257
270
  protected saveCache(): void;
271
+ protected getOrCreateAccessorFromAccess(identifier: string, sa: Accesses, mode: 'create' | 'open' | 'access'): Promise<IAccessorManager<unknown>>;
272
+ protected getOrCreateAccessor(identifier: string, accessType: string, mode: 'create' | 'open' | 'access'): Promise<IAccessorManager<unknown>>;
258
273
  protected initAccessControl(): StorageAccessControl;
259
- addListener(event: 'release' | 'access', listener: Function): void;
274
+ addListener(event: 'destroy' | 'access', listener: Function): void;
260
275
  register(tree: AccessTree): void;
261
276
  addAccessEvent<T extends string, AC>(customId: (T extends AccessType ? never : T), event: AccessorEvent<AC>): void;
262
277
  subStorage(identifier: string): IACSubStorage;
@@ -264,19 +279,35 @@ declare class ACStorage implements IACStorage {
264
279
  accessAsJSON(identifier: string): Promise<IJSONAccessor>;
265
280
  accessAsText(identifier: string): Promise<ITextAccessor>;
266
281
  accessAsBinary(identifier: string): Promise<IBinaryAccessor>;
282
+ create(identifier: string, accessType: string): Promise<unknown>;
283
+ createAsJSON(identifier: string): Promise<IJSONAccessor>;
284
+ createAsText(identifier: string): Promise<ITextAccessor>;
285
+ createAsBinary(identifier: string): Promise<IBinaryAccessor>;
286
+ open(identifier: string, accessType: string): Promise<unknown>;
287
+ openAsJSON(identifier: string): Promise<IJSONAccessor>;
288
+ openAsText(identifier: string): Promise<ITextAccessor>;
289
+ openAsBinary(identifier: string): Promise<IBinaryAccessor>;
267
290
  copy(oldIdentifier: string, newIdentifier: string): Promise<void>;
268
291
  move(oldIdentifier: string, newIdentifier: string): Promise<void>;
269
292
  protected validateAndGetAccessTypePair(oldIdentifier: string, newIdentifier: string): string;
270
293
  dropDir(identifier: string): Promise<void>;
271
294
  drop(identifier: string): Promise<void>;
272
295
  dropAll(): Promise<void>;
296
+ release(identifier: string): Promise<void>;
297
+ releaseDir(identifier: string): Promise<void>;
298
+ releaseAll(): Promise<void>;
273
299
  commit(identifier?: string): Promise<void>;
274
300
  commitAll(): Promise<void>;
275
301
  }
276
302
 
277
303
  declare class MemACStorage extends ACStorage {
304
+ #private;
278
305
  constructor();
306
+ getOrCreateAccessorFromAccess(identifier: string, sa: Accesses, mode: 'create' | 'open' | 'access'): Promise<IAccessorManager<unknown>>;
279
307
  initAccessControl(): StorageAccessControl;
308
+ release(identifier: string): Promise<void>;
309
+ releaseDir(identifier: string): Promise<void>;
310
+ releaseAll(): Promise<void>;
280
311
  }
281
312
 
282
313
  export { ACStorage, AccessDeniedError, BinaryAccessor, DirectoryAccessError, MemACStorage, MemBinaryAccessor, MemTextAccessor, NotRegisterError, StorageAccess, StorageAccessControl, StorageAccessError, StorageError, TextAccessor };
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "ac-storage",
3
- "version": "0.14.1",
4
- "main": "./dist/bundle.cjs",
5
- "module": "./dist/bundle.mjs",
6
- "types": "./dist/index.d.ts",
7
- "type": "module",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/bundle.mjs",
11
- "require": "./dist/bundle.cjs",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
- "license": "MIT",
16
- "devDependencies": {
17
- "@rollup/plugin-alias": "^5.1.1",
18
- "@rollup/plugin-commonjs": "^28.0.2",
19
- "@rollup/plugin-json": "^6.1.0",
20
- "@rollup/plugin-node-resolve": "^16.0.0",
21
- "@rollup/plugin-typescript": "^12.1.2",
22
- "@types/jest": "^29.5.14",
23
- "@types/node": "^22.10.2",
24
- "jest": "^29.7.0",
25
- "rollup": "^4.28.1",
26
- "rollup-plugin-dts": "^6.1.1",
27
- "rollup-plugin-terser": "^7.0.2",
28
- "ts-jest": "^29.2.5",
29
- "ts-node": "^10.9.2",
30
- "tslib": "^2.8.1",
31
- "tsx": "^4.19.3",
32
- "typescript": "^5.7.2"
33
- },
34
- "scripts": {
35
- "build": "rollup -c",
36
- "playground": "tsx src/playground.ts",
37
- "test": "jest",
38
- "publish-public": "npm publish --access=public"
39
- },
40
- "dependencies": {
41
- "@hve/json-accessor": "^0.6.0",
42
- "fast-deep-equal": "^3.1.3",
43
- "tree-navigate": "^0.1.1"
44
- }
45
- }
1
+ {
2
+ "name": "ac-storage",
3
+ "version": "0.15.0",
4
+ "main": "./dist/bundle.cjs",
5
+ "module": "./dist/bundle.mjs",
6
+ "types": "./dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/bundle.mjs",
11
+ "require": "./dist/bundle.cjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "license": "MIT",
16
+ "devDependencies": {
17
+ "@rollup/plugin-alias": "^5.1.1",
18
+ "@rollup/plugin-commonjs": "^28.0.2",
19
+ "@rollup/plugin-json": "^6.1.0",
20
+ "@rollup/plugin-node-resolve": "^16.0.0",
21
+ "@rollup/plugin-typescript": "^12.1.2",
22
+ "@types/jest": "^29.5.14",
23
+ "@types/node": "^22.10.2",
24
+ "jest": "^29.7.0",
25
+ "rollup": "^4.28.1",
26
+ "rollup-plugin-dts": "^6.1.1",
27
+ "rollup-plugin-terser": "^7.0.2",
28
+ "ts-jest": "^29.2.5",
29
+ "ts-node": "^10.9.2",
30
+ "tslib": "^2.8.1",
31
+ "tsx": "^4.19.3",
32
+ "typescript": "^5.7.2"
33
+ },
34
+ "scripts": {
35
+ "build": "rollup -c",
36
+ "playground": "tsx src/playground.ts",
37
+ "test": "jest",
38
+ "publish-public": "npm publish --access=public"
39
+ },
40
+ "dependencies": {
41
+ "@hve/json-accessor": "^0.7.0",
42
+ "fast-deep-equal": "^3.1.3",
43
+ "tree-navigate": "^0.1.1"
44
+ }
45
+ }