{
  "version": 3,
  "sources": ["../src/main.ts"],
  "sourcesContent": ["import {packageTracer} from '@alwatr/nanolib';\n\n__dev_mode__: packageTracer.add(__package_name__, __package_version__);\n\n// *** Nitrobase File ***\n\n/**\n * The subdirectory location for each nitrobase file.\n */\nexport enum Region {\n  /**\n   * Nitrobase file location that can be accessed by anyone. e.g. Product list.\n   */\n  Public = 'p',\n\n  /**\n   * Nitrobase file location that can be accessed by authenticated users. e.g. Special price list for dealers\n   */\n  Authenticated = 'a',\n\n  /**\n   * Nitrobase file location that can be accessed by admins and managers only. e.g. User list.\n   */\n  Managers = 'm',\n\n  /**\n   * Nitrobase file location specific to each user id. Can be accessed using the user token. e.g. User profile and User orders.\n   */\n  PerUser = 'u',\n\n  /**\n   * Nitrobase file location specific to each owner id. e.g. user token or device id.\n   */\n  PerOwner = 'o',\n\n  /**\n   * Private nitrobase file location. Cannot be accessed publicly and must be directly accessed by the admin API only.\n   * e.g. User secret data.\n   */\n  Secret = '.s',\n}\n\n/**\n * The different types of nitrobase file formats.\n */\nexport enum StoreFileType {\n  /**\n   * Type used for `single document` storage.\n   */\n  Document = 'doc',\n\n  /**\n   * Type used for storing a `collection` of simpler documents, referred to as collection items.\n   */\n  Collection = 'col',\n\n  /**\n   * Type used for storing a collection of items that are `append-only`.\n   */\n  AppendOnlyCollection = 'aoc',\n}\n\n/**\n * Nitrobase file extension (encode).\n */\nexport enum StoreFileExtension {\n  /**\n   * AlwatrNitrobase JSON format.\n   */\n  Json = 'asj',\n}\n\n/**\n * Unique identifier of the nitrobase file.\n *\n * Get from user for select nitrobase file.\n */\nexport type StoreFileId = {\n  /**\n   * The nitrobase filename.\n   */\n  readonly name: string;\n\n  /**\n   * The region where the nitrobase file is located.\n   * @see {@link Region}\n   */\n  readonly region: Region;\n\n  /**\n   * The owner of the nitrobase file.\n   * If the region is `Region.PerX` then this is the user id, device id, or token id etc.\n   * @see {@link Region}\n   *\n   */\n  readonly ownerId?: string;\n\n  /**\n   * The schema version for easy migration by user.\n   * If not specified, the default value is `1`.\n   */\n  schemaVer?: number;\n};\n\n/**\n * Nitrobase the complete metadata of the file in the root database.\n */\nexport type StoreFileStat = StoreFileId & {\n  /**\n   * The type of the nitrobase file.\n   *\n   * @see {@link StoreFileType}\n   */\n  readonly type: StoreFileType;\n\n  /**\n   * The extension used for the nitrobase file.\n   *\n   * @see {@link StoreFileExtension}\n   */\n  readonly extension?: StoreFileExtension;\n\n  /**\n   * The save debounce timeout in milliseconds for minimal disk I/O usage.\n   * This is used to limit the frequency of disk writes for performance reasons.\n   * The recommended value is `40`.\n   * If not specified, the default value get from AlwatrNitrobase `defaultChangeDebounce`.\n   */\n  readonly changeDebounce?: number;\n\n  /**\n   * The name of the migration process.\n   * This is used to migrate the nitrobase file to a new schema version.\n   */\n  readonly migrateName?: string;\n\n  /**\n   * The time-to-live (TTL) of the nitrobase file in memory.\n   */\n  // readonly ttl?: number;\n};\n\n/**\n * Represents the metadata of a nitrobase file.\n */\nexport type StoreFileMeta = StoreFileStat & {\n  /**\n   * Nitrobase file format version.\n   */\n  fv: number;\n\n  /**\n   * The revision number of the nitrobase file.\n   *\n   * This number is incremented every time the nitrobase file is updated.\n   */\n  rev: number;\n\n  /**\n   * The Unix timestamp (in milliseconds since the epoch) for when the nitrobase file was created.\n   */\n  readonly created: number;\n\n  /**\n   * The Unix timestamp (in milliseconds since the epoch) for when the nitrobase file was updated.\n   */\n  updated: number;\n\n  /**\n   * Last auto increment id.\n   */\n  lastAutoId?: number;\n\n  /**\n   * The extra metadata for the nitrobase file.\n   */\n  extra: JsonObject;\n};\n\nexport type StoreFileData<T extends JsonObject = JsonObject> = T;\n\n/**\n * Represents the context of a nitrobase file.\n * @template TData The type of the data content in the nitrobase file.\n */\nexport type StoreFileContext<TData extends JsonObject = JsonObject> = {\n  /**\n   * The status of the nitrobase file.\n   *\n   * if false, the Alwatr nitrobase throws an error.\n   */\n  readonly ok: true;\n\n  /**\n   * The metadata of the nitrobase file.\n   * @see {@link StoreFileMeta}\n   */\n  readonly meta: StoreFileMeta;\n\n  /**\n   * The data content of the nitrobase file.\n   */\n  readonly data: TData;\n};\n\n/**\n * Nitrobase file meta only content type.\n */\nexport type StoreFileMetaOnlyContext = Omit<StoreFileContext<never>, 'data'>;\n\n// *** Documents ***\n\n/**\n * StoreFileContext for document type.\n */\nexport type DocumentContext<T extends JsonObject = JsonObject> = StoreFileContext<T>;\n\n// *** Collections ***\n\n/**\n * The metadata of an item in a collection.\n */\nexport type CollectionItemMeta = {\n  /**\n   * The unique identifier for the collection item.\n   */\n  readonly id: string | number;\n\n  /**\n   * The Unix timestamp (in milliseconds since the epoch) for when the collection item was created.\n   */\n  readonly created: number;\n\n  /**\n   * The Unix timestamp (in milliseconds since the epoch) for when the collection item was updated.\n   */\n  updated: number;\n\n  /**\n   * The revision number for the collection item.\n   *\n   * This number is incremented each time the item is updated.\n   */\n  rev: number;\n};\n\n/**\n * Collection item context type.\n */\nexport type CollectionItem<TData extends JsonObject = JsonObject> = {\n  /**\n   * Collection item's metadata.\n   */\n  readonly meta: CollectionItemMeta;\n\n  /**\n   * Collection item data.\n   */\n  readonly data: TData;\n};\n\n/**\n * Collection item context type.\n */\nexport type CollectionContext<T extends JsonObject = JsonObject> = StoreFileContext<DictionaryReq<CollectionItem<T>>>;\n\nexport type AlwatrAuth = {\n  userId: string;\n  userToken: string;\n};\n"],
  "mappings": ";;;AAAA,SAAQ,qBAAoB;AAE5B,aAAc,eAAc,IAAI,2BAAkB,OAAmB;AAO9D,IAAK,SAAL,kBAAKA,YAAL;AAIL,EAAAA,QAAA,YAAS;AAKT,EAAAA,QAAA,mBAAgB;AAKhB,EAAAA,QAAA,cAAW;AAKX,EAAAA,QAAA,aAAU;AAKV,EAAAA,QAAA,cAAW;AAMX,EAAAA,QAAA,YAAS;AA9BC,SAAAA;AAAA,GAAA;AAoCL,IAAK,gBAAL,kBAAKC,mBAAL;AAIL,EAAAA,eAAA,cAAW;AAKX,EAAAA,eAAA,gBAAa;AAKb,EAAAA,eAAA,0BAAuB;AAdb,SAAAA;AAAA,GAAA;AAoBL,IAAK,qBAAL,kBAAKC,wBAAL;AAIL,EAAAA,oBAAA,UAAO;AAJG,SAAAA;AAAA,GAAA;",
  "names": ["Region", "StoreFileType", "StoreFileExtension"]
}
