Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
export interface CrudApi {
/**
* Creates a new resource, or overwrites an existing one.
*
* @param collection Type of the resource, collection name.
* @param id Id of the resource, document name.
* @param data Blob content of the resource.
* @param options Write behavior options.
*/
put: (collection: CrudCollection, id: string, data: Uint8Array, options?: CrudPutOptions) => Promise<void>;
/**
* Retrieves the content of a resource.
*
* @param collection Type of the resource, collection name.
* @param id Id of the resource, document name.
* @returns Blob content of the resource.
*/
get: (collection: CrudCollection, id: string) => Promise<Uint8Array>;
/**
* Deletes a resource.
*
* @param collection Type of the resource, collection name.
* @param id Id of the resource, document name.
* @param silent When true, does not throw an error if the collection or
* resource does not exist. Default is false.
*/
del: (collection: CrudCollection, id: string, silent?: boolean) => Promise<void>;
/**
* Fetches information about a resource.
*
* @param collection Type of the resource, collection name.
* @param id Id of the resource, document name, if any.
* @returns Information about the resource.
*/
info: (collection: CrudCollection, id?: string) => Promise<CrudResourceInfo>;
/**
* Deletes all resources of a collection, and deletes recursively all sub-collections.
*
* @param collection Type of the resource, collection name.
* @param silent When true, does not throw an error if the collection or
* resource does not exist. Default is false.
*/
drop: (collection: CrudCollection, silent?: boolean) => Promise<void>;
/**
* Iterates over all resources of a collection.
*
* @param collection Type of the resource, collection name.
* @returns Iterator of resources of the given type.
*/
scan: (collection: CrudCollection) => AsyncIterableIterator<CrudCollectionEntry>;
/**
* Fetches a list of resources of a collection, and sub-collections.
*
* @param collection Type of the resource, collection name.
* @returns List of resources of the given type, and sub-types.
*/
list: (collection: CrudCollection) => Promise<CrudCollectionEntry[]>;
/**
* Creates a new CrudApi instance, with the given collection as root.
*
* @param collection Type of the resource, collection name.
* @returns A new CrudApi instance, with the given collection as root.
*/
from: (collection: CrudCollection) => Promise<CrudApi>;
}
export type CrudCollection = string[];
export interface CrudPutOptions {
throwIf?: 'exists' | 'missing';
}
export interface CrudCollectionEntry {
/** Kind of the resource, type or item. */
type: 'resource' | 'collection';
/** Name of the resource. */
id: string;
}
export interface CrudResourceInfo extends CrudCollectionEntry {
/** Size of the resource in bytes. */
size?: number;
/** Timestamp when the resource last modified. */
modified?: number;
/** Timestamp when the resource was created. */
created?: number;
}
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/crud/types.ts"],"names":[],"mappings":""}
+2
View File
@@ -0,0 +1,2 @@
import { CrudCollection } from './types';
export declare const assertType: (type: CrudCollection, method: string, klass: string) => void;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertType = void 0;
const util_1 = require("../node-to-fsa/util");
const assertType = (type, method, klass) => {
const length = type.length;
for (let i = 0; i < length; i++)
(0, util_1.assertName)(type[i], method, klass);
};
exports.assertType = assertType;
//# sourceMappingURL=util.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/crud/util.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AAE1C,MAAM,UAAU,GAAG,CAAC,IAAoB,EAAE,MAAc,EAAE,KAAa,EAAQ,EAAE;IACtF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;QAAE,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB"}