@tailor-platform/sdk 1.11.0 → 1.12.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/CHANGELOG.md +34 -0
- package/dist/application-DM4zTgXU.mjs +4 -0
- package/dist/{application-BKBo5tGD.mjs → application-DnWZVbDO.mjs} +164 -26
- package/dist/application-DnWZVbDO.mjs.map +1 -0
- package/dist/cli/index.mjs +13 -19
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +149 -17
- package/dist/cli/lib.mjs +132 -4
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +4 -3
- package/dist/configure/index.mjs +16 -757
- package/dist/configure/index.mjs.map +1 -1
- package/dist/env-4RO7szrH.d.mts +66 -0
- package/dist/{index-D8zIUsWi.d.mts → index-BBr_q3vB.d.mts} +20 -11
- package/dist/{index-DcOTucF6.d.mts → index-Bid18Opo.d.mts} +473 -84
- package/dist/{jiti-ygK9KoRA.mjs → jiti-DuCiUfMj.mjs} +2 -2
- package/dist/{jiti-ygK9KoRA.mjs.map → jiti-DuCiUfMj.mjs.map} +1 -1
- package/dist/{job-l-pIR9IY.mjs → job-zGAXCidt.mjs} +1 -1
- package/dist/{job-l-pIR9IY.mjs.map → job-zGAXCidt.mjs.map} +1 -1
- package/dist/kysely/index.d.mts +25 -0
- package/dist/kysely/index.mjs +27 -0
- package/dist/kysely/index.mjs.map +1 -0
- package/dist/plugin/index.d.mts +105 -0
- package/dist/plugin/index.mjs +45 -0
- package/dist/plugin/index.mjs.map +1 -0
- package/dist/schema-BmKdDzr1.mjs +784 -0
- package/dist/schema-BmKdDzr1.mjs.map +1 -0
- package/dist/{src-CG8kJBI9.mjs → src-QNTCsO6J.mjs} +2 -2
- package/dist/{src-CG8kJBI9.mjs.map → src-QNTCsO6J.mjs.map} +1 -1
- package/dist/types-r-ZratAg.mjs +13 -0
- package/dist/types-r-ZratAg.mjs.map +1 -0
- package/dist/{update-D0muqqOP.mjs → update-B_W-UQnS.mjs} +1626 -390
- package/dist/update-B_W-UQnS.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/utils/test/index.mjs +1 -1
- package/docs/cli/tailordb.md +0 -12
- package/docs/generator/builtin.md +2 -2
- package/docs/plugin/custom.md +389 -0
- package/docs/plugin/index.md +112 -0
- package/docs/services/workflow.md +28 -0
- package/package.json +16 -23
- package/dist/application-BKBo5tGD.mjs.map +0 -1
- package/dist/application-a12-7TT3.mjs +0 -4
- package/dist/update-D0muqqOP.mjs.map +0 -1
- /package/dist/{chunk-CIV_ash9.mjs → chunk-C3Kl5s5P.mjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-BmKdDzr1.mjs","names":["regex","uuid","string","bool","int","float","date","datetime","time","_enum","object","field","validators","options"],"sources":["../src/configure/types/field.ts","../src/configure/types/type.ts","../src/configure/services/tailordb/permission.ts","../src/configure/services/tailordb/schema.ts"],"sourcesContent":["import { type EnumValue } from \"@/parser/service/tailordb/types\";\n\nexport type AllowedValue = EnumValue;\n\nexport type AllowedValues = [string | EnumValue, ...(string | EnumValue)[]];\n\n/**\n * Normalize allowed values into EnumValue objects with descriptions.\n * @param values - Allowed values as strings or EnumValue objects\n * @returns Normalized allowed values\n */\nexport function mapAllowedValues(values: AllowedValues): AllowedValue[] {\n return values.map((value) => {\n if (typeof value === \"string\") {\n return { value, description: \"\" };\n }\n return { ...value, description: value.description ?? \"\" };\n });\n}\n\nexport type AllowedValuesOutput<V extends AllowedValues> = V[number] extends infer T\n ? T extends string\n ? T\n : T extends { value: infer K }\n ? K\n : never\n : never;\n","import { type AllowedValues, type AllowedValuesOutput, mapAllowedValues } from \"./field\";\nimport {\n type TailorFieldType,\n type TailorToTs,\n type FieldMetadata,\n type DefinedFieldMetadata,\n type FieldOptions,\n type FieldOutput,\n} from \"./types\";\nimport type { Prettify, InferFieldsOutput } from \"./helpers\";\nimport type { FieldValidateInput } from \"./validation\";\nimport type { TailorUser } from \"@/configure/types\";\nimport type { TailorFieldInput } from \"@/parser/service/resolver/types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>\\d{2}):(?<minute>\\d{2})$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})T(?<hour>\\d{2}):(?<minute>\\d{2}):(?<second>\\d{2})(.(?<millisec>\\d{3}))?Z$/,\n} as const;\n\n// This helper type intentionally uses `any` as a placeholder for unknown field output.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyField = TailorField<any>;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\n // Runtime input is unknown/untyped; we validate and narrow it inside the parser.\n // oxlint-disable-next-line no-explicit-any\n value: any;\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\n/**\n * TailorField interface representing a field with metadata, type information, and optional nested fields.\n * This is the base field type used by both resolver types and TailorDB types.\n * Using interface to allow self-referencing in the fields property.\n */\nexport interface TailorField<\n Defined extends DefinedFieldMetadata = DefinedFieldMetadata,\n // Generic default output type (kept loose on purpose for library ergonomics).\n // oxlint-disable-next-line no-explicit-any\n Output = any,\n M extends FieldMetadata = FieldMetadata,\n T extends TailorFieldType = TailorFieldType,\n> extends TailorFieldInput {\n readonly type: T;\n readonly fields: Record<string, TailorAnyField>;\n readonly _defined: Defined;\n readonly _output: Output;\n _metadata: M;\n\n /** Returns a shallow copy of the metadata */\n readonly metadata: M;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Set a custom type name for enum or nested types\n * @param typeName - The custom type name\n * @returns The field with updated metadata\n */\n typeName<CurrentDefined extends Defined>(\n this: CurrentDefined extends { typeName: unknown }\n ? never\n : CurrentDefined extends { type: \"enum\" | \"nested\" }\n ? TailorField<CurrentDefined, Output>\n : never,\n typeName: string,\n ): TailorField<Prettify<CurrentDefined & { typeName: true }>, Output>;\n\n /**\n * Add validation functions to the field\n * @param validate - One or more validation functions\n * @returns The field with updated metadata\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorField<Prettify<CurrentDefined & { validate: true }>, Output>;\n\n /**\n * Parse and validate a value against this field's validation rules\n * Returns StandardSchema Result type with success or failure\n * @param args - Value, context data, and user\n * @returns Validation result\n */\n parse(args: FieldParseArgs): StandardSchemaV1.Result<Output>;\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @private\n * @param args - Parse arguments\n * @returns Validation result\n */\n _parseInternal(args: FieldParseInternalArgs): StandardSchemaV1.Result<Output>;\n}\n\n/**\n * Creates a new TailorField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @returns A new TailorField\n */\nfunction createTailorField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyField>,\n values?: AllowedValues,\n): TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n const _metadata: FieldMetadata = { required: true };\n\n if (options) {\n const hasRequired = Object.prototype.hasOwnProperty.call(options, \"required\");\n const hasOptional = Object.prototype.hasOwnProperty.call(options, \"optional\");\n\n if (hasRequired) {\n const isRequired = options.required === true;\n _metadata.required = isRequired;\n if (isRequired) {\n _metadata.requiredExplicit = true;\n }\n } else if (hasOptional) {\n const isOptional = options.optional === true;\n _metadata.required = !isOptional;\n if (options.optional === false) {\n _metadata.requiredExplicit = true;\n }\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n } else if (field.fields && Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = value?.[fieldName];\n const result = nestedField._parseInternal({\n value: fieldValue,\n data,\n user,\n pathArray: pathArray.concat(fieldName),\n });\n if (result.issues) {\n issues.push(...result.issues);\n }\n }\n }\n break;\n }\n\n // Custom validation functions\n const validateFns = field._metadata.validate;\n if (validateFns && validateFns.length > 0) {\n for (const validateInput of validateFns) {\n const { fn, message } =\n typeof validateInput === \"function\"\n ? { fn: validateInput, message: \"Validation failed\" }\n : { fn: validateInput[0], message: validateInput[1] };\n\n if (!fn({ value, data, user })) {\n issues.push({\n message,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // Validate each array element (without array flag)\n for (let i = 0; i < value.length; i++) {\n const elementValue = value[i];\n const elementPath = pathArray.concat(`[${i}]`);\n\n // Validate element with same type but without array flag\n const elementIssues = validateValue({\n value: elementValue,\n data,\n user,\n pathArray: elementPath,\n });\n if (elementIssues.length > 0) {\n issues.push(...elementIssues);\n }\n }\n\n if (issues.length > 0) {\n return { issues };\n }\n return { value: value as FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = validateValue({ value, data, user, pathArray });\n issues.push(...valueIssues);\n\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value };\n }\n\n const field: TailorField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n > = {\n type,\n fields: fields ?? {},\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n description(description: string) {\n this._metadata.description = description;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n typeName(typeName: string) {\n this._metadata.typeName = typeName;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n this._metadata.validate = validateInputs;\n // Fluent API returns this with updated type\n // oxlint-disable-next-line no-explicit-any\n return this as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n };\n\n return field;\n}\n\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"uuid\", options);\n}\n\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"string\", options);\n}\n\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"boolean\", options);\n}\n\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"integer\", options);\n}\n\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"float\", options);\n}\n\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"date\", options);\n}\n\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"datetime\", options);\n}\n\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createTailorField(\"time\", options);\n}\n\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createTailorField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\nfunction object<const F extends Record<string, TailorAnyField>, const Opt extends FieldOptions>(\n fields: F,\n options?: Opt,\n) {\n const objectField = createTailorField(\"nested\", options, fields) as TailorField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n return objectField;\n}\n\nexport const t = {\n uuid,\n string,\n bool,\n int,\n float,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n};\n","import type { InferredAttributeMap } from \"../../types\";\n\nexport type TailorTypePermission<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = {\n create: readonly ActionPermission<\"record\", User, Type, false>[];\n read: readonly ActionPermission<\"record\", User, Type, false>[];\n update: readonly ActionPermission<\"record\", User, Type, true>[];\n delete: readonly ActionPermission<\"record\", User, Type, false>[];\n};\n\ntype ActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n User extends object = InferredAttributeMap,\n Type extends object = object,\n Update extends boolean = boolean,\n> =\n | {\n conditions:\n | PermissionCondition<Level, User, Update, Type>\n | readonly PermissionCondition<Level, User, Update, Type>[];\n description?: string | undefined;\n permit?: boolean;\n }\n | readonly [...PermissionCondition<Level, User, Update, Type>, ...([] | [boolean])] // single array condition\n | readonly [...PermissionCondition<Level, User, Update, Type>[], ...([] | [boolean])]; // multiple array condition\n\nexport type TailorTypeGqlPermission<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = readonly GqlPermissionPolicy<User, Type>[];\n\ntype GqlPermissionPolicy<\n User extends object = InferredAttributeMap,\n Type extends object = object,\n> = {\n conditions: readonly PermissionCondition<\"gql\", User, boolean, Type>[];\n actions: \"all\" | readonly GqlPermissionAction[];\n permit?: boolean;\n description?: string;\n};\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype EqualityOperator = \"=\" | \"!=\";\ntype ContainsOperator = \"in\" | \"not in\";\n\n// Helper types for User field extraction\ntype StringFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends string ? K : never;\n}[keyof User];\n\ntype StringArrayFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends string[] ? K : never;\n}[keyof User];\n\ntype BooleanFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends boolean ? K : never;\n}[keyof User];\n\ntype BooleanArrayFieldKeys<User extends object> = {\n [K in keyof User]: User[K] extends boolean[] ? K : never;\n}[keyof User];\n\ntype UserStringOperand<User extends object = InferredAttributeMap> = {\n user: StringFieldKeys<User> | \"id\";\n};\n\ntype UserStringArrayOperand<User extends object = InferredAttributeMap> = {\n user: StringArrayFieldKeys<User>;\n};\n\ntype UserBooleanOperand<User extends object = InferredAttributeMap> = {\n user: BooleanFieldKeys<User> | \"_loggedIn\";\n};\n\ntype UserBooleanArrayOperand<User extends object = InferredAttributeMap> = {\n user: BooleanArrayFieldKeys<User>;\n};\n\ntype RecordOperand<Type extends object, Update extends boolean = false> = Update extends true\n ? { oldRecord: (keyof Type & string) | \"id\" } | { newRecord: (keyof Type & string) | \"id\" }\n : { record: (keyof Type & string) | \"id\" };\n\ntype StringEqualityCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | (Level extends \"gql\" ? readonly [string, EqualityOperator, boolean] : never)\n | readonly [string, EqualityOperator, string]\n | readonly [UserStringOperand<User>, EqualityOperator, string]\n | readonly [string, EqualityOperator, UserStringOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n EqualityOperator,\n string | UserStringOperand<User>,\n ]\n | readonly [\n string | UserStringOperand<User>,\n EqualityOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype BooleanEqualityCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | readonly [boolean, EqualityOperator, boolean]\n | readonly [UserBooleanOperand<User>, EqualityOperator, boolean]\n | readonly [boolean, EqualityOperator, UserBooleanOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n EqualityOperator,\n boolean | UserBooleanOperand<User>,\n ]\n | readonly [\n boolean | UserBooleanOperand<User>,\n EqualityOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype EqualityCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> =\n | StringEqualityCondition<Level, User, Update, Type>\n | BooleanEqualityCondition<Level, User, Update, Type>;\n\ntype StringContainsCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | readonly [string, ContainsOperator, string[]]\n | readonly [UserStringOperand<User>, ContainsOperator, string[]]\n | readonly [string, ContainsOperator, UserStringArrayOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n ContainsOperator,\n string[] | UserStringArrayOperand<User>,\n ]\n | readonly [\n string | UserStringOperand<User>,\n ContainsOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype BooleanContainsCondition<\n Level extends \"record\" | \"gql\",\n User extends object,\n Update extends boolean,\n Type extends object,\n> =\n | (Level extends \"gql\" ? readonly [string, ContainsOperator, boolean[]] : never)\n | readonly [boolean, ContainsOperator, boolean[]]\n | readonly [UserBooleanOperand<User>, ContainsOperator, boolean[]]\n | readonly [boolean, ContainsOperator, UserBooleanArrayOperand<User>]\n | (Level extends \"record\"\n ?\n | readonly [\n RecordOperand<Type, Update>,\n ContainsOperator,\n boolean[] | UserBooleanArrayOperand<User>,\n ]\n | readonly [\n boolean | UserBooleanOperand<User>,\n ContainsOperator,\n RecordOperand<Type, Update>,\n ]\n : never);\n\ntype ContainsCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> =\n | StringContainsCondition<Level, User, Update, Type>\n | BooleanContainsCondition<Level, User, Update, Type>;\n\n/**\n * Type representing a permission condition that combines user attributes, record fields, and literal values using comparison operators.\n *\n * The User type is extended by `user-defined.d.ts`, which is automatically generated when running `tailor-sdk generate`.\n * Attributes enabled in the config file's `auth.userProfile.attributes` (or\n * `auth.machineUserAttributes` when userProfile is omitted) become available as types.\n * @example\n * ```ts\n * // tailor.config.ts\n * export const auth = defineAuth(\"my-auth\", {\n * userProfile: {\n * type: user,\n * attributes: {\n * isAdmin: true,\n * roles: true,\n * }\n * }\n * });\n * ```\n */\nexport type PermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\",\n User extends object = InferredAttributeMap,\n Update extends boolean = boolean,\n Type extends object = object,\n> = EqualityCondition<Level, User, Update, Type> | ContainsCondition<Level, User, Update, Type>;\n\n/**\n * Grants full record-level access without any conditions.\n *\n * Unsafe and intended only for local development, prototyping, or tests.\n * Do not use this in production environments, as it effectively disables\n * authorization checks.\n */\nexport const unsafeAllowAllTypePermission: TailorTypePermission = {\n create: [{ conditions: [], permit: true }],\n read: [{ conditions: [], permit: true }],\n update: [{ conditions: [], permit: true }],\n delete: [{ conditions: [], permit: true }],\n};\n\n/**\n * Grants full GraphQL access (all actions) without any conditions.\n *\n * Unsafe and intended only for local development, prototyping, or tests.\n * Do not use this in production environments, as it effectively disables\n * authorization checks.\n */\nexport const unsafeAllowAllGqlPermission: TailorTypeGqlPermission = [\n { conditions: [], actions: \"all\", permit: true },\n];\n","import { cloneDeep } from \"es-toolkit\";\nimport {\n type AllowedValues,\n type AllowedValuesOutput,\n mapAllowedValues,\n} from \"@/configure/types/field\";\nimport { type TailorField, type TailorAnyField } from \"@/configure/types/type\";\nimport {\n type FieldOptions,\n type FieldOutput,\n type TailorFieldType,\n type TailorToTs,\n} from \"@/configure/types/types\";\nimport {\n type TailorDBTypeMetadata,\n type RawPermissions,\n type RawRelationConfig,\n type RelationType,\n} from \"@/parser/service/tailordb/types\";\nimport { type TailorTypeGqlPermission, type TailorTypePermission } from \"./permission\";\nimport {\n type DBFieldMetadata,\n type DefinedDBFieldMetadata,\n type Hooks,\n type Hook,\n type SerialConfig,\n type IndexDef,\n type TypeFeatures,\n type ExcludeNestedDBFields,\n} from \"./types\";\nimport type { InferredAttributeMap, TailorUser } from \"@/configure/types\";\nimport type { Prettify, output, InferFieldsOutput } from \"@/configure/types/helpers\";\nimport type { FieldValidateInput, ValidateConfig, Validators } from \"@/configure/types/validation\";\nimport type { PluginAttachment, PluginConfigs } from \"@/parser/plugin-config/types\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\ninterface RelationConfig<S extends RelationType, T extends TailorDBType> {\n type: S;\n toward: {\n type: T;\n as?: string;\n key?: keyof T[\"fields\"] & string;\n };\n backward?: string;\n}\n\n// Special config variant for self-referencing relations\ntype RelationSelfConfig = {\n type: RelationType;\n toward: {\n type: \"self\";\n as?: string;\n key?: string;\n };\n backward?: string;\n};\n\nfunction isRelationSelfConfig(\n config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig,\n): config is RelationSelfConfig {\n return config.toward.type === \"self\";\n}\n\n// Helper alias: DB fields can be arbitrarily nested, so we intentionally keep this loose.\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBField = TailorDBField<any, any>;\n\n// Helper alias\n// oxlint-disable-next-line no-explicit-any\nexport type TailorAnyDBType = TailorDBType<any, any>;\n\nconst regex = {\n uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\n date: /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})$/,\n time: /^(?<hour>\\d{2}):(?<minute>\\d{2})$/,\n datetime:\n /^(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})T(?<hour>\\d{2}):(?<minute>\\d{2}):(?<second>\\d{2})(.(?<millisec>\\d{3}))?Z$/,\n} as const;\n\ntype FieldParseArgs = {\n value: unknown;\n data: unknown;\n user: TailorUser;\n};\n\ntype FieldValidateValueArgs<T extends TailorFieldType> = {\n value: TailorToTs[T];\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\ntype FieldParseInternalArgs = {\n // Runtime input is unknown/untyped; we validate and narrow it inside the parser.\n // oxlint-disable-next-line no-explicit-any\n value: any;\n data: unknown;\n user: TailorUser;\n pathArray: string[];\n};\n\n/**\n * TailorDBField interface representing a database field with extended metadata.\n * Extends TailorField with database-specific features like relations, indexes, and hooks.\n */\nexport interface TailorDBField<Defined extends DefinedDBFieldMetadata, Output> extends Omit<\n TailorField<Defined, Output, DBFieldMetadata, Defined[\"type\"]>,\n \"description\" | \"validate\"\n> {\n /** Returns a shallow copy of the raw relation config if set */\n readonly rawRelation: Readonly<RawRelationConfig> | undefined;\n\n /**\n * Set a description for the field\n * @param description - The description text\n * @returns The field with updated metadata\n */\n description<CurrentDefined extends Defined>(\n this: CurrentDefined extends { description: unknown }\n ? never\n : TailorField<CurrentDefined, Output>,\n description: string,\n ): TailorDBField<Prettify<CurrentDefined & { description: true }>, Output>;\n\n /**\n * Define a relation to another type\n */\n relation<S extends RelationType, T extends TailorAnyDBType, CurrentDefined extends Defined>(\n this: CurrentDefined extends { relation: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n config: RelationConfig<S, T>,\n ): TailorDBField<\n S extends \"oneToOne\" | \"1-1\"\n ? Prettify<CurrentDefined & { unique: true; index: true; relation: true }>\n : Prettify<CurrentDefined & { index: true; relation: true }>,\n Output\n >;\n\n /**\n * Define a self-referencing relation\n */\n relation<S extends RelationSelfConfig, CurrentDefined extends Defined>(\n this: CurrentDefined extends { relation: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n config: S,\n ): TailorDBField<\n S[\"type\"] extends \"oneToOne\" | \"1-1\"\n ? Prettify<CurrentDefined & { unique: true; index: true; relation: true }>\n : Prettify<CurrentDefined & { index: true; relation: true }>,\n Output\n >;\n\n /**\n * Add an index to the field\n */\n index<CurrentDefined extends Defined>(\n this: CurrentDefined extends { index: unknown }\n ? never\n : CurrentDefined extends { array: true }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ): TailorDBField<Prettify<CurrentDefined & { index: true }>, Output>;\n\n /**\n * Make the field unique (also adds an index)\n */\n unique<CurrentDefined extends Defined>(\n this: CurrentDefined extends { unique: unknown }\n ? never\n : CurrentDefined extends { array: true }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ): TailorDBField<Prettify<CurrentDefined & { unique: true; index: true }>, Output>;\n\n /**\n * Enable vector search on the field (string type only)\n */\n vector<CurrentDefined extends Defined>(\n this: CurrentDefined extends { vector: unknown }\n ? never\n : CurrentDefined extends { type: \"string\"; array: false }\n ? TailorDBField<CurrentDefined, Output>\n : never,\n ): TailorDBField<Prettify<CurrentDefined & { vector: true }>, Output>;\n\n /**\n * Add hooks for create/update operations\n */\n hooks<CurrentDefined extends Defined, const H extends Hook<unknown, Output>>(\n this: CurrentDefined extends { hooks: unknown }\n ? never\n : CurrentDefined extends { type: \"nested\" }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n hooks: H,\n ): TailorDBField<\n Prettify<\n CurrentDefined & {\n hooks?: {\n create: H extends { create: unknown } ? true : false;\n update: H extends { update: unknown } ? true : false;\n };\n serial: false;\n }\n >,\n Output\n >;\n\n /**\n * Add validation functions to the field\n */\n validate<CurrentDefined extends Defined>(\n this: CurrentDefined extends { validate: unknown }\n ? never\n : TailorDBField<CurrentDefined, Output>,\n ...validate: FieldValidateInput<Output>[]\n ): TailorDBField<Prettify<CurrentDefined & { validate: true }>, Output>;\n\n /**\n * Configure serial/auto-increment behavior\n */\n serial<CurrentDefined extends Defined>(\n this: CurrentDefined extends { serial: unknown }\n ? never\n : Output extends null\n ? never\n : CurrentDefined extends { type: \"integer\" | \"string\"; array: false }\n ? TailorDBField<CurrentDefined, Output>\n : never,\n config: SerialConfig<CurrentDefined[\"type\"] & (\"integer\" | \"string\")>,\n ): TailorDBField<\n Prettify<\n CurrentDefined & {\n serial: true;\n hooks: { create: false; update: false };\n }\n >,\n Output\n >;\n\n /**\n * Clone the field with optional overrides for field options\n * @param options - Optional field options to override\n * @returns A new TailorDBField instance with the same configuration\n */\n clone<const NewOpt extends FieldOptions>(\n options?: NewOpt,\n ): TailorDBField<\n Prettify<\n Omit<Defined, \"array\"> & {\n array: NewOpt extends { array: true } ? true : Defined[\"array\"];\n }\n >,\n FieldOutput<TailorToTs[Defined[\"type\"]], NewOpt>\n >;\n}\n\n/**\n * Creates a new TailorDBField instance.\n * @param type - Field type\n * @param options - Field options\n * @param fields - Nested fields for object-like types\n * @param values - Allowed values for enum-like fields\n * @returns A new TailorDBField\n */\nfunction createTailorDBField<\n const T extends TailorFieldType,\n const TOptions extends FieldOptions,\n const OutputBase = TailorToTs[T],\n>(\n type: T,\n options?: TOptions,\n fields?: Record<string, TailorAnyDBField>,\n values?: AllowedValues,\n): TailorDBField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n> {\n type FieldType = TailorDBField<\n { type: T; array: TOptions extends { array: true } ? true : false },\n FieldOutput<OutputBase, TOptions>\n >;\n\n const _metadata: DBFieldMetadata = { required: true };\n let _rawRelation: RawRelationConfig | undefined;\n\n if (options) {\n if (options.optional === true) {\n _metadata.required = false;\n }\n if (options.array === true) {\n _metadata.array = true;\n }\n }\n if (values) {\n _metadata.allowedValues = mapAllowedValues(values);\n }\n\n /**\n * Validate a single value (not an array element)\n * Used internally for array element validation\n * @param args - Value, context data, and user\n * @returns Array of validation issues\n */\n function validateValue(args: FieldValidateValueArgs<T>): StandardSchemaV1.Issue[] {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // Type-specific validation\n switch (type) {\n case \"string\":\n if (typeof value !== \"string\") {\n issues.push({\n message: `Expected a string: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"integer\":\n if (typeof value !== \"number\" || !Number.isInteger(value)) {\n issues.push({\n message: `Expected an integer: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"float\":\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n issues.push({\n message: `Expected a number: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"boolean\":\n if (typeof value !== \"boolean\") {\n issues.push({\n message: `Expected a boolean: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n\n case \"uuid\":\n if (typeof value !== \"string\" || !regex.uuid.test(value)) {\n issues.push({\n message: `Expected a valid UUID: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"date\":\n if (typeof value !== \"string\" || !regex.date.test(value)) {\n issues.push({\n message: `Expected to match \"yyyy-MM-dd\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"datetime\":\n if (typeof value !== \"string\" || !regex.datetime.test(value)) {\n issues.push({\n message: `Expected to match ISO format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"time\":\n if (typeof value !== \"string\" || !regex.time.test(value)) {\n issues.push({\n message: `Expected to match \"HH:mm\" format: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n break;\n case \"enum\":\n if (field._metadata.allowedValues) {\n const allowedValues = field._metadata.allowedValues.map((v) => v.value);\n if (typeof value !== \"string\" || !allowedValues.includes(value)) {\n issues.push({\n message: `Must be one of [${allowedValues.join(\", \")}]: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n break;\n\n case \"nested\":\n // Validate nested object fields\n if (\n typeof value !== \"object\" ||\n value === null ||\n Array.isArray(value) ||\n value instanceof Date\n ) {\n issues.push({\n message: `Expected an object: received ${String(value)}`,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n } else if (field.fields && Object.keys(field.fields).length > 0) {\n for (const [fieldName, nestedField] of Object.entries(field.fields)) {\n const fieldValue = value?.[fieldName];\n const result = nestedField._parseInternal({\n value: fieldValue,\n data,\n user,\n pathArray: pathArray.concat(fieldName),\n });\n if (result.issues) {\n issues.push(...result.issues);\n }\n }\n }\n break;\n }\n\n // Custom validation functions\n const validateFns = field._metadata.validate;\n if (validateFns && validateFns.length > 0) {\n for (const validateInput of validateFns) {\n const { fn, message } =\n typeof validateInput === \"function\"\n ? { fn: validateInput, message: \"Validation failed\" }\n : { fn: validateInput[0], message: validateInput[1] };\n\n if (!fn({ value, data, user })) {\n issues.push({\n message,\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n }\n }\n }\n\n return issues;\n }\n\n /**\n * Internal parse method that tracks field path for nested validation\n * @param args - Parse arguments\n * @returns Parse result with value or issues\n */\n function parseInternal(\n args: FieldParseInternalArgs,\n ): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n const { value, data, user, pathArray } = args;\n const issues: StandardSchemaV1.Issue[] = [];\n\n // 1. Check required/optional\n const isNullOrUndefined = value === null || value === undefined;\n if (field._metadata.required && isNullOrUndefined) {\n issues.push({\n message: \"Required field is missing\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // If optional and null/undefined, skip further validation and normalize to null\n if (!field._metadata.required && isNullOrUndefined) {\n return { value: value ?? null };\n }\n\n // 2. Check array type\n if (field._metadata.array) {\n if (!Array.isArray(value)) {\n issues.push({\n message: \"Expected an array\",\n path: pathArray.length > 0 ? pathArray : undefined,\n });\n return { issues };\n }\n\n // Validate each array element (without array flag)\n for (let i = 0; i < value.length; i++) {\n const elementValue = value[i];\n const elementPath = pathArray.concat(`[${i}]`);\n\n // Validate element with same type but without array flag\n const elementIssues = validateValue({\n value: elementValue,\n data,\n user,\n pathArray: elementPath,\n });\n if (elementIssues.length > 0) {\n issues.push(...elementIssues);\n }\n }\n\n if (issues.length > 0) {\n return { issues };\n }\n return { value: value as FieldOutput<OutputBase, TOptions> };\n }\n\n // 3. Type-specific validation and custom validation\n const valueIssues = validateValue({ value, data, user, pathArray });\n issues.push(...valueIssues);\n\n if (issues.length > 0) {\n return { issues };\n }\n\n return { value };\n }\n\n function cloneWith(metadataUpdates: Partial<DBFieldMetadata>) {\n const cloned = field.clone();\n Object.assign(cloned._metadata, metadataUpdates);\n return cloned;\n }\n\n const field: FieldType = {\n type,\n fields: (fields ?? {}) as Record<string, TailorAnyField>,\n _defined: undefined as unknown as {\n type: T;\n array: TOptions extends { array: true } ? true : false;\n },\n _output: undefined as FieldOutput<OutputBase, TOptions>,\n _metadata,\n\n get metadata() {\n return { ...this._metadata };\n },\n\n get rawRelation(): Readonly<RawRelationConfig> | undefined {\n return _rawRelation ? { ..._rawRelation, toward: { ..._rawRelation.toward } } : undefined;\n },\n\n description(description: string) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ description }) as any;\n },\n\n typeName(typeName: string) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ typeName }) as any;\n },\n\n validate(...validateInputs: FieldValidateInput<FieldOutput<OutputBase, TOptions>>[]) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ validate: validateInputs }) as any;\n },\n\n parse(args: FieldParseArgs): StandardSchemaV1.Result<FieldOutput<OutputBase, TOptions>> {\n return parseInternal({\n value: args.value,\n data: args.data,\n user: args.user,\n pathArray: [],\n });\n },\n\n _parseInternal: parseInternal,\n\n // TailorDBField specific methods\n relation(config: RelationConfig<RelationType, TailorDBType> | RelationSelfConfig) {\n const cloned = field.clone();\n const targetType = isRelationSelfConfig(config) ? \"self\" : config.toward.type.name;\n // oxlint-disable-next-line no-explicit-any\n (cloned as any)._setRawRelation({\n type: config.type,\n toward: {\n type: targetType,\n as: config.toward.as,\n key: config.toward.key,\n },\n backward: config.backward,\n });\n // oxlint-disable-next-line no-explicit-any\n return cloned as any;\n },\n\n index() {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ index: true }) as any;\n },\n\n unique() {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ unique: true, index: true }) as any;\n },\n\n vector() {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ vector: true }) as any;\n },\n\n hooks(hooks: Hook<unknown, FieldOutput<OutputBase, TOptions>>) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ hooks }) as any;\n },\n\n serial(config: SerialConfig) {\n // oxlint-disable-next-line no-explicit-any\n return cloneWith({ serial: config }) as any;\n },\n\n clone(cloneOptions?: FieldOptions) {\n // Deep clone nested object fields if present\n let clonedFields = fields;\n if (fields) {\n const cloned: Record<string, TailorAnyDBField> = {};\n for (const [key, field] of Object.entries(fields)) {\n cloned[key] = field.clone();\n }\n clonedFields = cloned;\n }\n\n // Create a new field with cloned configuration\n const clonedField = createTailorDBField(type, options, clonedFields, values);\n\n // Deep copy metadata using cloneDeep (preserves function references)\n Object.assign(clonedField._metadata, cloneDeep(this._metadata));\n\n // Apply new options if provided\n if (cloneOptions) {\n if (cloneOptions.optional !== undefined) {\n clonedField._metadata.required = !cloneOptions.optional;\n }\n if (cloneOptions.array !== undefined) {\n clonedField._metadata.array = cloneOptions.array;\n }\n }\n\n // Copy raw relation if exists\n if (_rawRelation) {\n const clonedRawRelation = cloneDeep(_rawRelation);\n // oxlint-disable-next-line no-explicit-any\n (clonedField as any)._setRawRelation(clonedRawRelation);\n }\n\n // oxlint-disable-next-line no-explicit-any\n return clonedField as any;\n },\n\n // Internal method for clone to set rawRelation\n // @ts-ignore - Internal method not in interface\n _setRawRelation(relation: RawRelationConfig) {\n _rawRelation = relation;\n },\n };\n\n return field;\n}\n\nconst createField = createTailorDBField;\n\nfunction uuid<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"uuid\", options);\n}\n\nfunction string<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"string\", options);\n}\n\nfunction bool<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"boolean\", options);\n}\n\nfunction int<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"integer\", options);\n}\n\nfunction float<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"float\", options);\n}\n\nfunction date<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"date\", options);\n}\n\nfunction datetime<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"datetime\", options);\n}\n\nfunction time<const Opt extends FieldOptions>(options?: Opt) {\n return createField(\"time\", options);\n}\n\nfunction _enum<const V extends AllowedValues, const Opt extends FieldOptions>(\n values: V,\n options?: Opt,\n): TailorDBField<\n { type: \"enum\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<AllowedValuesOutput<V>, Opt>\n> {\n return createField<\"enum\", Opt, AllowedValuesOutput<V>>(\"enum\", options, undefined, values);\n}\n\nfunction object<\n const F extends Record<string, TailorAnyDBField> & ExcludeNestedDBFields<F>,\n const Opt extends FieldOptions,\n>(fields: F, options?: Opt) {\n return createField(\"nested\", options, fields) as unknown as TailorDBField<\n { type: \"nested\"; array: Opt extends { array: true } ? true : false },\n FieldOutput<InferFieldsOutput<F>, Opt>\n >;\n}\n\n/**\n * TailorDBType interface representing a database type definition with fields, permissions, and settings.\n */\nexport interface TailorDBType<\n // Default kept loose to avoid forcing callers to supply generics.\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributeMap,\n> {\n readonly name: string;\n readonly fields: Fields;\n readonly _output: InferFieldsOutput<Fields>;\n _description?: string;\n\n /** Returns metadata for the type */\n readonly metadata: TailorDBTypeMetadata;\n\n /**\n * Add hooks for fields\n */\n hooks(hooks: Hooks<Fields>): TailorDBType<Fields, User>;\n\n /**\n * Add validators for fields\n */\n validate(validators: Validators<Fields>): TailorDBType<Fields, User>;\n\n /**\n * Configure type features\n */\n features(features: Omit<TypeFeatures, \"pluralForm\">): TailorDBType<Fields, User>;\n\n /**\n * Define composite indexes\n */\n indexes(...indexes: IndexDef<TailorDBType<Fields, User>>[]): TailorDBType<Fields, User>;\n\n /**\n * Define file fields\n */\n files<const F extends string>(\n files: Record<F, string> & Partial<Record<keyof output<TailorDBType<Fields, User>>, never>>,\n ): TailorDBType<Fields, User>;\n\n /**\n * Set record-level permissions\n */\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User>>> = TailorTypePermission<\n U,\n output<TailorDBType<Fields, User>>\n >,\n >(\n permission: P,\n ): TailorDBType<Fields, U>;\n\n /**\n * Set GraphQL-level permissions\n */\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(\n permission: P,\n ): TailorDBType<Fields, U>;\n\n /**\n * Set type description\n */\n description(description: string): TailorDBType<Fields, User>;\n\n /**\n * Pick specific fields from the type\n */\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(\n keys: K[],\n options: Opt,\n ): {\n [P in K]: Fields[P] extends TailorDBField<infer D, infer _O>\n ? TailorDBField<\n Omit<D, \"array\"> & {\n array: Opt extends { array: true } ? true : D[\"array\"];\n },\n FieldOutput<TailorToTs[D[\"type\"]], Opt>\n >\n : never;\n };\n\n /**\n * Omit specific fields from the type\n */\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;\n\n /**\n * Plugin attachments for this type\n */\n readonly plugins: PluginAttachment[];\n\n /**\n * Attach a plugin to this type\n * @param config - Plugin configuration in the format { pluginId: config }\n * @returns The type with the plugin attached\n */\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User>;\n}\n\n/**\n * Creates a new TailorDBType instance.\n * @param name - Type name\n * @param fields - Field definitions\n * @param options - Type options\n * @param options.pluralForm - Optional plural form\n * @param options.description - Optional description\n * @returns A new TailorDBType\n */\nfunction createTailorDBType<\n // oxlint-disable-next-line no-explicit-any\n const Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributeMap,\n>(\n name: string,\n fields: Fields,\n options: { pluralForm?: string; description?: string },\n): TailorDBType<Fields, User> {\n let _description = options.description;\n let _settings: TypeFeatures = {};\n let _indexes: IndexDef<TailorDBType<Fields, User>>[] = [];\n const _permissions: RawPermissions = {};\n let _files: Record<string, string> = {};\n const _plugins: PluginAttachment[] = [];\n\n if (options.pluralForm) {\n if (name === options.pluralForm) {\n throw new Error(`The name and the plural form must be different. name=${name}`);\n }\n _settings.pluralForm = options.pluralForm;\n }\n\n const dbType: TailorDBType<Fields, User> = {\n name,\n fields: { ...fields },\n _output: null as unknown as InferFieldsOutput<Fields>,\n _description,\n\n get metadata(): TailorDBTypeMetadata {\n // Convert indexes to the format expected by the manifest\n const indexes: Record<string, { fields: string[]; unique?: boolean }> = {};\n if (_indexes && _indexes.length > 0) {\n _indexes.forEach((index) => {\n const fieldNames = index.fields.map((field) => String(field));\n const key = index.name || `idx_${fieldNames.join(\"_\")}`;\n indexes[key] = {\n fields: fieldNames,\n unique: index.unique,\n };\n });\n }\n\n return {\n name: this.name,\n description: _description,\n settings: _settings,\n permissions: _permissions,\n files: _files,\n ...(Object.keys(indexes).length > 0 && { indexes }),\n };\n },\n\n hooks(hooks: Hooks<Fields>) {\n // `Hooks<Fields>` is strongly typed, but `Object.entries()` loses that information.\n // oxlint-disable-next-line no-explicit-any\n Object.entries(hooks).forEach(([fieldName, fieldHooks]: [string, any]) => {\n (this.fields as Record<string, TailorAnyDBField>)[fieldName] =\n this.fields[fieldName].hooks(fieldHooks);\n });\n return this;\n },\n\n validate(validators: Validators<Fields>) {\n Object.entries(validators).forEach(([fieldName, fieldValidators]) => {\n const field = this.fields[fieldName] as TailorAnyDBField;\n\n const validators = fieldValidators as\n | FieldValidateInput<unknown>\n | FieldValidateInput<unknown>[];\n\n const isValidateConfig = (v: unknown): v is ValidateConfig<unknown> => {\n return Array.isArray(v) && v.length === 2 && typeof v[1] === \"string\";\n };\n\n let updatedField: TailorAnyDBField;\n if (Array.isArray(validators)) {\n if (isValidateConfig(validators)) {\n updatedField = field.validate(validators);\n } else {\n updatedField = field.validate(...validators);\n }\n } else {\n updatedField = field.validate(validators);\n }\n (this.fields as Record<string, TailorAnyDBField>)[fieldName] = updatedField;\n });\n return this;\n },\n\n features(features: Omit<TypeFeatures, \"pluralForm\">) {\n _settings = {\n ..._settings,\n ...features,\n };\n return this;\n },\n\n indexes(...indexes: IndexDef<TailorDBType<Fields, User>>[]) {\n _indexes = indexes;\n return this;\n },\n\n files<const F extends string>(\n files: Record<F, string> & Partial<Record<keyof output<TailorDBType<Fields, User>>, never>>,\n ) {\n _files = files;\n return this;\n },\n\n permission<\n U extends object = User,\n P extends TailorTypePermission<U, output<TailorDBType<Fields, User>>> = TailorTypePermission<\n U,\n output<TailorDBType<Fields, User>>\n >,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n _permissions.record = permission;\n return ret;\n },\n\n gqlPermission<\n U extends object = User,\n P extends TailorTypeGqlPermission<U> = TailorTypeGqlPermission<U>,\n >(permission: P) {\n const ret = this as TailorDBType<Fields, U>;\n _permissions.gql = permission;\n return ret;\n },\n\n description(description: string) {\n _description = description;\n this._description = description;\n return this;\n },\n\n pickFields<K extends keyof Fields, const Opt extends FieldOptions>(keys: K[], options: Opt) {\n const result = {} as Record<K, TailorAnyDBField>;\n for (const key of keys) {\n if (options) {\n result[key] = this.fields[key].clone(options);\n } else {\n result[key] = this.fields[key];\n }\n }\n return result as {\n [P in K]: Fields[P] extends TailorDBField<infer D, infer _O>\n ? TailorDBField<\n Omit<D, \"array\"> & {\n array: Opt extends { array: true } ? true : D[\"array\"];\n },\n FieldOutput<TailorToTs[D[\"type\"]], Opt>\n >\n : never;\n };\n },\n\n omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K> {\n const keysSet = new Set(keys);\n const result = {} as Record<string, TailorAnyDBField>;\n for (const key in this.fields) {\n if (Object.hasOwn(this.fields, key) && !keysSet.has(key as unknown as K)) {\n result[key] = this.fields[key];\n }\n }\n return result as Omit<Fields, K>;\n },\n\n get plugins(): PluginAttachment[] {\n return _plugins;\n },\n\n plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: {\n [K in P]: PluginConfigs<keyof Fields & string>[K];\n }): TailorDBType<Fields, User> {\n for (const [pluginId, pluginConfig] of Object.entries(config)) {\n _plugins.push({ pluginId, config: pluginConfig });\n }\n return this;\n },\n };\n\n return dbType;\n}\n\nexport type TailorDBInstance<\n // Default kept loose for convenience; callers still get fully inferred types from `db.type()`.\n // oxlint-disable-next-line no-explicit-any\n Fields extends Record<string, TailorAnyDBField> = any,\n User extends object = InferredAttributeMap,\n> = TailorDBType<Fields, User>;\n\nconst idField = uuid();\ntype idField = typeof idField;\ntype DBType<F extends { id?: never } & Record<string, TailorAnyDBField>> = TailorDBInstance<\n { id: idField } & F\n>;\n\n/**\n * Creates a new database type with the specified fields\n * @param name - The name of the type, or a tuple of [name, pluralForm]\n * @param fields - The field definitions for the type\n * @returns A new TailorDBType instance\n */\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fields: F,\n): DBType<F>;\n/**\n * Creates a new database type with the specified fields and description\n * @param name - The name of the type, or a tuple of [name, pluralForm]\n * @param description - A description of the type\n * @param fields - The field definitions for the type\n * @returns A new TailorDBType instance\n */\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n description: string,\n fields: F,\n): DBType<F>;\nfunction dbType<const F extends { id?: never } & Record<string, TailorAnyDBField>>(\n name: string | [string, string],\n fieldsOrDescription: string | F,\n fields?: F,\n): DBType<F> {\n const typeName = Array.isArray(name) ? name[0] : name;\n const pluralForm = Array.isArray(name) ? name[1] : undefined;\n\n let description: string | undefined;\n let fieldDef: F;\n if (typeof fieldsOrDescription === \"string\") {\n description = fieldsOrDescription;\n fieldDef = fields as F;\n } else {\n fieldDef = fieldsOrDescription;\n }\n return createTailorDBType<{ id: idField } & F>(\n typeName,\n {\n id: idField,\n ...fieldDef,\n },\n { pluralForm, description },\n ) as DBType<F>;\n}\n\nexport const db = {\n type: dbType,\n uuid,\n string,\n bool,\n int,\n float,\n date,\n datetime,\n time,\n enum: _enum,\n object,\n fields: {\n timestamps: () => ({\n createdAt: datetime()\n .hooks({ create: () => new Date() })\n .description(\"Record creation timestamp\"),\n updatedAt: datetime({ optional: true })\n .hooks({ update: () => new Date() })\n .description(\"Record last update timestamp\"),\n }),\n },\n};\n"],"mappings":";;;;;;;;AAWA,SAAgB,iBAAiB,QAAuC;AACtE,QAAO,OAAO,KAAK,UAAU;AAC3B,MAAI,OAAO,UAAU,SACnB,QAAO;GAAE;GAAO,aAAa;GAAI;AAEnC,SAAO;GAAE,GAAG;GAAO,aAAa,MAAM,eAAe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,MAAM,aAAa,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK;CAEnD,IAAI;CACJ,IAAI;AACJ,KAAI,OAAO,wBAAwB,UAAU;AAC3C,gBAAc;AACd,aAAW;OAEX,YAAW;AAEb,QAAO,mBACL,UACA;EACE,IAAI;EACJ,GAAG;EACJ,EACD;EAAE;EAAY;EAAa,CAC5B;;AAGH,MAAa,KAAK;CAChB,MAAM;CACN;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,MAAM;CACN;CACA,QAAQ,EACN,mBAAmB;EACjB,WAAW,UAAU,CAClB,MAAM,EAAE,8BAAc,IAAI,MAAM,EAAE,CAAC,CACnC,YAAY,4BAA4B;EAC3C,WAAW,SAAS,EAAE,UAAU,MAAM,CAAC,CACpC,MAAM,EAAE,8BAAc,IAAI,MAAM,EAAE,CAAC,CACnC,YAAY,+BAA+B;EAC/C,GACF;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as __esmMin } from "./chunk-
|
|
1
|
+
import { n as __esmMin } from "./chunk-C3Kl5s5P.mjs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import nativeFsp from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
@@ -1035,4 +1035,4 @@ var init_src = __esmMin((() => {
|
|
|
1035
1035
|
//#endregion
|
|
1036
1036
|
init_src();
|
|
1037
1037
|
export { hfs };
|
|
1038
|
-
//# sourceMappingURL=src-
|
|
1038
|
+
//# sourceMappingURL=src-QNTCsO6J.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"src-CG8kJBI9.mjs","names":["#baseImpl","#impl","#logs","#log","#assertImplMethod","#assertImplMethodAlt","#callImplMethodAlt","#callImplMethod","#callImplMethodWithoutLog","dirPath","entryFilter","directoryFilter","#check","#timeout","#maxDelay","#queue","#processQueue","#timerId","#fsp","#retrier"],"sources":["../../../node_modules/@humanfs/core/src/hfs.js","../../../node_modules/@humanfs/core/src/errors.js","../../../node_modules/@humanfs/core/src/index.js","../../../node_modules/@humanwhocodes/retry/dist/retrier.js","../../../node_modules/@humanfs/node/src/node-hfs.js","../../../node_modules/@humanfs/node/src/index.js"],"sourcesContent":["/**\n * @fileoverview The main file for the humanfs package.\n * @author Nicholas C. Zakas\n */\n\n/* global URL, TextDecoder, TextEncoder */\n\n//-----------------------------------------------------------------------------\n// Types\n//-----------------------------------------------------------------------------\n\n/** @typedef {import(\"@humanfs/types\").HfsImpl} HfsImpl */\n/** @typedef {import(\"@humanfs/types\").HfsDirectoryEntry} HfsDirectoryEntry */\n/** @typedef {import(\"@humanfs/types\").HfsWalkEntry} HfsWalkEntry */\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nconst decoder = new TextDecoder();\nconst encoder = new TextEncoder();\n\n/**\n * Error to represent when a method is missing on an impl.\n */\nexport class NoSuchMethodError extends Error {\n\t/**\n\t * Creates a new instance.\n\t * @param {string} methodName The name of the method that was missing.\n\t */\n\tconstructor(methodName) {\n\t\tsuper(`Method \"${methodName}\" does not exist on impl.`);\n\t}\n}\n\n/**\n * Error to represent when a method is not supported on an impl. This happens\n * when a method on `Hfs` is called with one name and the corresponding method\n * on the impl has a different name. (Example: `text()` and `bytes()`.)\n */\nexport class MethodNotSupportedError extends Error {\n\t/**\n\t * Creates a new instance.\n\t * @param {string} methodName The name of the method that was missing.\n\t */\n\tconstructor(methodName) {\n\t\tsuper(`Method \"${methodName}\" is not supported on this impl.`);\n\t}\n}\n\n/**\n * Error to represent when an impl is already set.\n */\nexport class ImplAlreadySetError extends Error {\n\t/**\n\t * Creates a new instance.\n\t */\n\tconstructor() {\n\t\tsuper(`Implementation already set.`);\n\t}\n}\n\n/**\n * Asserts that the given path is a valid file path.\n * @param {any} fileOrDirPath The path to check.\n * @returns {void}\n * @throws {TypeError} When the path is not a non-empty string.\n */\nfunction assertValidFileOrDirPath(fileOrDirPath) {\n\tif (\n\t\t!fileOrDirPath ||\n\t\t(!(fileOrDirPath instanceof URL) && typeof fileOrDirPath !== \"string\")\n\t) {\n\t\tthrow new TypeError(\"Path must be a non-empty string or URL.\");\n\t}\n}\n\n/**\n * Asserts that the given file contents are valid.\n * @param {any} contents The contents to check.\n * @returns {void}\n * @throws {TypeError} When the contents are not a string or ArrayBuffer.\n */\nfunction assertValidFileContents(contents) {\n\tif (\n\t\ttypeof contents !== \"string\" &&\n\t\t!(contents instanceof ArrayBuffer) &&\n\t\t!ArrayBuffer.isView(contents)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\",\n\t\t);\n\t}\n}\n\n/**\n * Converts the given contents to Uint8Array.\n * @param {any} contents The data to convert.\n * @returns {Uint8Array} The converted Uint8Array.\n * @throws {TypeError} When the contents are not a string or ArrayBuffer.\n */\nfunction toUint8Array(contents) {\n\tif (contents instanceof Uint8Array) {\n\t\treturn contents;\n\t}\n\n\tif (typeof contents === \"string\") {\n\t\treturn encoder.encode(contents);\n\t}\n\n\tif (contents instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(contents);\n\t}\n\n\tif (ArrayBuffer.isView(contents)) {\n\t\tconst bytes = contents.buffer.slice(\n\t\t\tcontents.byteOffset,\n\t\t\tcontents.byteOffset + contents.byteLength,\n\t\t);\n\t\treturn new Uint8Array(bytes);\n\t}\n\tthrow new TypeError(\n\t\t\"Invalid contents type. Expected string or ArrayBuffer.\",\n\t);\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing a log entry.\n */\nexport class LogEntry {\n\t/**\n\t * The type of log entry.\n\t * @type {string}\n\t */\n\ttype;\n\n\t/**\n\t * The data associated with the log entry.\n\t * @type {any}\n\t */\n\tdata;\n\n\t/**\n\t * The time at which the log entry was created.\n\t * @type {number}\n\t */\n\ttimestamp = Date.now();\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} type The type of log entry.\n\t * @param {any} [data] The data associated with the log entry.\n\t */\n\tconstructor(type, data) {\n\t\tthis.type = type;\n\t\tthis.data = data;\n\t}\n}\n\n/**\n * A class representing a file system utility library.\n * @implements {HfsImpl}\n */\nexport class Hfs {\n\t/**\n\t * The base implementation for this instance.\n\t * @type {HfsImpl}\n\t */\n\t#baseImpl;\n\n\t/**\n\t * The current implementation for this instance.\n\t * @type {HfsImpl}\n\t */\n\t#impl;\n\n\t/**\n\t * A map of log names to their corresponding entries.\n\t * @type {Map<string,Array<LogEntry>>}\n\t */\n\t#logs = new Map();\n\n\t/**\n\t * Creates a new instance.\n\t * @param {object} options The options for the instance.\n\t * @param {HfsImpl} options.impl The implementation to use.\n\t */\n\tconstructor({ impl }) {\n\t\tthis.#baseImpl = impl;\n\t\tthis.#impl = impl;\n\t}\n\n\t/**\n\t * Logs an entry onto all currently open logs.\n\t * @param {string} methodName The name of the method being called.\n\t * @param {...*} args The arguments to the method.\n\t * @returns {void}\n\t */\n\t#log(methodName, ...args) {\n\t\tfor (const logs of this.#logs.values()) {\n\t\t\tlogs.push(new LogEntry(\"call\", { methodName, args }));\n\t\t}\n\t}\n\n\t/**\n\t * Starts a new log with the given name.\n\t * @param {string} name The name of the log to start;\n\t * @returns {void}\n\t * @throws {Error} When the log already exists.\n\t * @throws {TypeError} When the name is not a non-empty string.\n\t */\n\tlogStart(name) {\n\t\tif (!name || typeof name !== \"string\") {\n\t\t\tthrow new TypeError(\"Log name must be a non-empty string.\");\n\t\t}\n\n\t\tif (this.#logs.has(name)) {\n\t\t\tthrow new Error(`Log \"${name}\" already exists.`);\n\t\t}\n\n\t\tthis.#logs.set(name, []);\n\t}\n\n\t/**\n\t * Ends a log with the given name and returns the entries.\n\t * @param {string} name The name of the log to end.\n\t * @returns {Array<LogEntry>} The entries in the log.\n\t * @throws {Error} When the log does not exist.\n\t */\n\tlogEnd(name) {\n\t\tif (this.#logs.has(name)) {\n\t\t\tconst logs = this.#logs.get(name);\n\t\t\tthis.#logs.delete(name);\n\t\t\treturn logs;\n\t\t}\n\n\t\tthrow new Error(`Log \"${name}\" does not exist.`);\n\t}\n\n\t/**\n\t * Determines if the current implementation is the base implementation.\n\t * @returns {boolean} True if the current implementation is the base implementation.\n\t */\n\tisBaseImpl() {\n\t\treturn this.#impl === this.#baseImpl;\n\t}\n\n\t/**\n\t * Sets the implementation for this instance.\n\t * @param {object} impl The implementation to use.\n\t * @returns {void}\n\t */\n\tsetImpl(impl) {\n\t\tthis.#log(\"implSet\", impl);\n\n\t\tif (this.#impl !== this.#baseImpl) {\n\t\t\tthrow new ImplAlreadySetError();\n\t\t}\n\n\t\tthis.#impl = impl;\n\t}\n\n\t/**\n\t * Resets the implementation for this instance back to its original.\n\t * @returns {void}\n\t */\n\tresetImpl() {\n\t\tthis.#log(\"implReset\");\n\t\tthis.#impl = this.#baseImpl;\n\t}\n\n\t/**\n\t * Asserts that the given method exists on the current implementation.\n\t * @param {string} methodName The name of the method to check.\n\t * @returns {void}\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#assertImplMethod(methodName) {\n\t\tif (typeof this.#impl[methodName] !== \"function\") {\n\t\t\tthrow new NoSuchMethodError(methodName);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts that the given method exists on the current implementation, and if not,\n\t * throws an error with a different method name.\n\t * @param {string} methodName The name of the method to check.\n\t * @param {string} targetMethodName The name of the method that should be reported\n\t * as an error when methodName does not exist.\n\t * @returns {void}\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#assertImplMethodAlt(methodName, targetMethodName) {\n\t\tif (typeof this.#impl[methodName] !== \"function\") {\n\t\t\tthrow new MethodNotSupportedError(targetMethodName);\n\t\t}\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethod(methodName, ...args) {\n\t\tthis.#log(methodName, ...args);\n\t\tthis.#assertImplMethod(methodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation and doesn't log the call.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethodWithoutLog(methodName, ...args) {\n\t\tthis.#assertImplMethod(methodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation but logs a different method name.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {string} targetMethodName The name of the method to log.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethodAlt(methodName, targetMethodName, ...args) {\n\t\tthis.#log(targetMethodName, ...args);\n\t\tthis.#assertImplMethodAlt(methodName, targetMethodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as text. Assumes UTF-8 encoding.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<string|undefined>} The contents of the file.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync text(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\"bytes\", \"text\", filePath);\n\t\treturn result ? decoder.decode(result) : undefined;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as JSON. Assumes UTF-8 encoding.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<any|undefined>} The contents of the file as JSON.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {SyntaxError} When the file contents are not valid JSON.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync json(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\"bytes\", \"json\", filePath);\n\t\treturn result ? JSON.parse(decoder.decode(result)) : undefined;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as an ArrayBuffer.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<ArrayBuffer|undefined>} The contents of the file as an ArrayBuffer.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t * @deprecated Use bytes() instead.\n\t */\n\tasync arrayBuffer(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\n\t\t\t\"bytes\",\n\t\t\t\"arrayBuffer\",\n\t\t\tfilePath,\n\t\t);\n\t\treturn result?.buffer;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as an Uint8Array.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<Uint8Array|undefined>} The contents of the file as an Uint8Array.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync bytes(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"bytes\", filePath);\n\t}\n\n\t/**\n\t * Writes the given data to the given file. Creates any necessary directories along the way.\n\t * If the data is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The file to write.\n\t * @param {string|ArrayBuffer|ArrayBufferView} contents The data to write.\n\t * @returns {Promise<void>} A promise that resolves when the file is written.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync write(filePath, contents) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\tassertValidFileContents(contents);\n\t\tthis.#log(\"write\", filePath, contents);\n\n\t\tlet value = toUint8Array(contents);\n\t\treturn this.#callImplMethodWithoutLog(\"write\", filePath, value);\n\t}\n\n\t/**\n\t * Appends the given data to the given file. Creates any necessary directories along the way.\n\t * If the data is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The file to append to.\n\t * @param {string|ArrayBuffer|ArrayBufferView} contents The data to append.\n\t * @returns {Promise<void>} A promise that resolves when the file is appended to.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t * @throws {TypeError} When the file contents are not a string or ArrayBuffer.\n\t * @throws {Error} When the file cannot be appended to.\n\t */\n\tasync append(filePath, contents) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\tassertValidFileContents(contents);\n\t\tthis.#log(\"append\", filePath, contents);\n\n\t\tlet value = toUint8Array(contents);\n\t\treturn this.#callImplMethodWithoutLog(\"append\", filePath, value);\n\t}\n\n\t/**\n\t * Determines if the given file exists.\n\t * @param {string|URL} filePath The file to check.\n\t * @returns {Promise<boolean>} True if the file exists.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync isFile(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"isFile\", filePath);\n\t}\n\n\t/**\n\t * Determines if the given directory exists.\n\t * @param {string|URL} dirPath The directory to check.\n\t * @returns {Promise<boolean>} True if the directory exists.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync isDirectory(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"isDirectory\", dirPath);\n\t}\n\n\t/**\n\t * Creates the given directory.\n\t * @param {string|URL} dirPath The directory to create.\n\t * @returns {Promise<void>} A promise that resolves when the directory is created.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync createDirectory(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"createDirectory\", dirPath);\n\t}\n\n\t/**\n\t * Deletes the given file or empty directory.\n\t * @param {string|URL} filePath The file to delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync delete(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"delete\", filePath);\n\t}\n\n\t/**\n\t * Deletes the given file or directory recursively.\n\t * @param {string|URL} dirPath The directory to delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync deleteAll(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"deleteAll\", dirPath);\n\t}\n\n\t/**\n\t * Returns a list of directory entries for the given path.\n\t * @param {string|URL} dirPath The path to the directory to read.\n\t * @returns {AsyncIterable<HfsDirectoryEntry>} A promise that resolves with the\n\t * directory entries.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *list(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\tyield* await this.#callImplMethod(\"list\", dirPath);\n\t}\n\n\t/**\n\t * Walks a directory using a depth-first traversal and returns the entries\n\t * from the traversal.\n\t * @param {string|URL} dirPath The path to the directory to walk.\n\t * @param {Object} [options] The options for the walk.\n\t * @param {(entry:HfsWalkEntry) => Promise<boolean>|boolean} [options.directoryFilter] A filter function to determine\n\t * \tif a directory's entries should be included in the walk.\n\t * @param {(entry:HfsWalkEntry) => Promise<boolean>|boolean} [options.entryFilter] A filter function to determine if\n\t * \tan entry should be included in the walk.\n\t * @returns {AsyncIterable<HfsWalkEntry>} A promise that resolves with the\n\t * \tdirectory entries.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *walk(\n\t\tdirPath,\n\t\t{ directoryFilter = () => true, entryFilter = () => true } = {},\n\t) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\tthis.#log(\"walk\", dirPath, { directoryFilter, entryFilter });\n\n\t\t// inner function for recursion without additional logging\n\t\tconst walk = async function* (\n\t\t\tdirPath,\n\t\t\t{ directoryFilter, entryFilter, parentPath = \"\", depth = 1 },\n\t\t) {\n\t\t\tlet dirEntries;\n\n\t\t\ttry {\n\t\t\t\tdirEntries = await this.#callImplMethodWithoutLog(\n\t\t\t\t\t\"list\",\n\t\t\t\t\tdirPath,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// if the directory does not exist then return an empty array\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// otherwise, rethrow the error\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tfor await (const listEntry of dirEntries) {\n\t\t\t\tconst walkEntry = {\n\t\t\t\t\tpath: listEntry.name,\n\t\t\t\t\tdepth,\n\t\t\t\t\t...listEntry,\n\t\t\t\t};\n\n\t\t\t\tif (parentPath) {\n\t\t\t\t\twalkEntry.path = `${parentPath}/${walkEntry.path}`;\n\t\t\t\t}\n\n\t\t\t\t// first emit the entry but only if the entry filter returns true\n\t\t\t\tlet shouldEmitEntry = entryFilter(walkEntry);\n\t\t\t\tif (shouldEmitEntry.then) {\n\t\t\t\t\tshouldEmitEntry = await shouldEmitEntry;\n\t\t\t\t}\n\n\t\t\t\tif (shouldEmitEntry) {\n\t\t\t\t\tyield walkEntry;\n\t\t\t\t}\n\n\t\t\t\t// if it's a directory then yield the entry and walk the directory\n\t\t\t\tif (listEntry.isDirectory) {\n\t\t\t\t\t// if the directory filter returns false, skip the directory\n\t\t\t\t\tlet shouldWalkDirectory = directoryFilter(walkEntry);\n\t\t\t\t\tif (shouldWalkDirectory.then) {\n\t\t\t\t\t\tshouldWalkDirectory = await shouldWalkDirectory;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!shouldWalkDirectory) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// make sure there's a trailing slash on the directory path before appending\n\t\t\t\t\tconst directoryPath =\n\t\t\t\t\t\tdirPath instanceof URL\n\t\t\t\t\t\t\t? new URL(\n\t\t\t\t\t\t\t\t\tlistEntry.name,\n\t\t\t\t\t\t\t\t\tdirPath.href.endsWith(\"/\")\n\t\t\t\t\t\t\t\t\t\t? dirPath.href\n\t\t\t\t\t\t\t\t\t\t: `${dirPath.href}/`,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: `${dirPath.endsWith(\"/\") ? dirPath : `${dirPath}/`}${listEntry.name}`;\n\n\t\t\t\t\tyield* walk(directoryPath, {\n\t\t\t\t\t\tdirectoryFilter,\n\t\t\t\t\t\tentryFilter,\n\t\t\t\t\t\tparentPath: walkEntry.path,\n\t\t\t\t\t\tdepth: depth + 1,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}.bind(this);\n\n\t\tyield* walk(dirPath, { directoryFilter, entryFilter });\n\t}\n\n\t/**\n\t * Returns the size of the given file.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<number>} A promise that resolves with the size of the file.\n\t * @throws {TypeError} If the file path is not a string or URL.\n\t * @throws {Error} If the file cannot be read.\n\t */\n\tasync size(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"size\", filePath);\n\t}\n\n\t/**\n\t * Returns the last modified timestamp of the given file or directory.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory.\n\t * @returns {Promise<Date|undefined>} A promise that resolves with the last modified date\n\t * or undefined if the file or directory does not exist.\n\t * @throws {TypeError} If the path is not a string or URL.\n\t */\n\tasync lastModified(fileOrDirPath) {\n\t\tassertValidFileOrDirPath(fileOrDirPath);\n\t\treturn this.#callImplMethod(\"lastModified\", fileOrDirPath);\n\t}\n\n\t/**\n\t * Copys a file from one location to another.\n\t * @param {string|URL} source The path to the file to copy.\n\t * @param {string|URL} destination The path to the new file.\n\t * @returns {Promise<void>} A promise that resolves when the file is copied.\n\t * @throws {TypeError} If the file path is not a string or URL.\n\t * @throws {Error} If the file cannot be copied.\n\t */\n\tasync copy(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"copy\", source, destination);\n\t}\n\n\t/**\n\t * Copies a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to copy.\n\t * @param {string|URL} destination The path to copy the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * copied.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be copied.\n\t */\n\tasync copyAll(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"copyAll\", source, destination);\n\t}\n\n\t/**\n\t * Moves a file from the source path to the destination path.\n\t * @param {string|URL} source The location of the file to move.\n\t * @param {string|URL} destination The destination of the file to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file or directory paths are not strings.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync move(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"move\", source, destination);\n\t}\n\n\t/**\n\t * Moves a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to move.\n\t * @param {string|URL} destination The path to move the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * moved.\n\t * @throws {TypeError} If the source is not a string or URL.\n\t * @throws {TypeError} If the destination is not a string or URL.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync moveAll(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"moveAll\", source, destination);\n\t}\n}\n","/**\n * @fileoverview Common error classes\n * @author Nicholas C. Zakas\n */\n\n/**\n * Error thrown when a file or directory is not found.\n */\nexport class NotFoundError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"NotFoundError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"ENOENT\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`ENOENT: No such file or directory, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when an operation is not permitted.\n */\nexport class PermissionError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"PermissionError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"EPERM\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`EPERM: Operation not permitted, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when an operation is not allowed on a directory.\n */\n\nexport class DirectoryError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"DirectoryError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"EISDIR\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`EISDIR: Illegal operation on a directory, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when a directory is not empty.\n */\nexport class NotEmptyError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"NotEmptyError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"ENOTEMPTY\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`ENOTEMPTY: Directory not empty, ${message}`);\n\t}\n}\n","/**\n * @fileoverview API entrypoint for hfs/core\n * @author Nicholas C. Zakas\n */\n\nexport { Hfs } from \"./hfs.js\";\nexport { Path } from \"./path.js\";\nexport * from \"./errors.js\";\n","// @ts-self-types=\"./retrier.d.ts\"\n/**\n * @fileoverview A utility for retrying failed async method calls.\n */\n\n/* global setTimeout, clearTimeout */\n\n//-----------------------------------------------------------------------------\n// Constants\n//-----------------------------------------------------------------------------\n\nconst MAX_TASK_TIMEOUT = 60000;\nconst MAX_TASK_DELAY = 100;\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\n/*\n * The following logic has been extracted from graceful-fs.\n *\n * The ISC License\n *\n * Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR\n * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Checks if it is time to retry a task based on the timestamp and last attempt time.\n * @param {RetryTask} task The task to check.\n * @param {number} maxDelay The maximum delay for the queue.\n * @returns {boolean} true if it is time to retry, false otherwise.\n */\nfunction isTimeToRetry(task, maxDelay) {\n const timeSinceLastAttempt = Date.now() - task.lastAttempt;\n const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1);\n const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay);\n\n return timeSinceLastAttempt >= desiredDelay;\n}\n\n/**\n * Checks if it is time to bail out based on the given timestamp.\n * @param {RetryTask} task The task to check.\n * @param {number} timeout The timeout for the queue.\n * @returns {boolean} true if it is time to bail, false otherwise.\n */\nfunction isTimeToBail(task, timeout) {\n return task.age > timeout;\n}\n\n\n/**\n * A class to represent a task in the retry queue.\n */\nclass RetryTask {\n\n /**\n * The unique ID for the task.\n * @type {string}\n */\n id = Math.random().toString(36).slice(2);\n\n /**\n * The function to call.\n * @type {Function}\n */\n fn;\n\n /**\n * The error that was thrown.\n * @type {Error}\n */\n error;\n \n /**\n * The timestamp of the task.\n * @type {number}\n */\n timestamp = Date.now();\n\n /**\n * The timestamp of the last attempt.\n * @type {number}\n */\n lastAttempt = this.timestamp;\n\n /**\n * The resolve function for the promise.\n * @type {Function}\n */\n resolve;\n\n /**\n * The reject function for the promise.\n * @type {Function}\n */\n reject;\n\n /**\n * The AbortSignal to monitor for cancellation.\n * @type {AbortSignal|undefined}\n */\n signal;\n\n /**\n * Creates a new instance.\n * @param {Function} fn The function to call.\n * @param {Error} error The error that was thrown.\n * @param {Function} resolve The resolve function for the promise.\n * @param {Function} reject The reject function for the promise.\n * @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation.\n */\n constructor(fn, error, resolve, reject, signal) {\n this.fn = fn;\n this.error = error;\n this.timestamp = Date.now();\n this.lastAttempt = Date.now();\n this.resolve = resolve;\n this.reject = reject;\n this.signal = signal;\n }\n \n /**\n * Gets the age of the task.\n * @returns {number} The age of the task in milliseconds.\n * @readonly\n */\n get age() {\n return Date.now() - this.timestamp;\n }\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class that manages a queue of retry jobs.\n */\nclass Retrier {\n\n /**\n * Represents the queue for processing tasks.\n * @type {Array<RetryTask>}\n */\n #queue = [];\n\n /**\n * The timeout for the queue.\n * @type {number}\n */\n #timeout;\n\n /**\n * The maximum delay for the queue.\n * @type {number}\n */\n #maxDelay;\n\n /**\n * The setTimeout() timer ID.\n * @type {NodeJS.Timeout|undefined}\n */\n #timerId;\n\n /**\n * The function to call.\n * @type {Function}\n */\n #check;\n\n /**\n * Creates a new instance.\n * @param {Function} check The function to call.\n * @param {object} [options] The options for the instance.\n * @param {number} [options.timeout] The timeout for the queue.\n * @param {number} [options.maxDelay] The maximum delay for the queue.\n */\n constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY } = {}) {\n\n if (typeof check !== \"function\") {\n throw new Error(\"Missing function to check errors\");\n }\n\n this.#check = check;\n this.#timeout = timeout;\n this.#maxDelay = maxDelay;\n }\n\n /**\n * Adds a new retry job to the queue.\n * @param {Function} fn The function to call.\n * @param {object} [options] The options for the job.\n * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation.\n * @returns {Promise<any>} A promise that resolves when the queue is\n * processed.\n */\n retry(fn, { signal } = {}) {\n\n signal?.throwIfAborted();\n\n let result;\n\n try {\n result = fn();\n } catch (/** @type {any} */ error) {\n return Promise.reject(new Error(`Synchronous error: ${error.message}`, { cause: error }));\n }\n\n // if the result is not a promise then reject an error\n if (!result || typeof result.then !== \"function\") {\n return Promise.reject(new Error(\"Result is not a promise.\"));\n }\n\n // call the original function and catch any ENFILE or EMFILE errors\n // @ts-ignore because we know it's any\n return Promise.resolve(result).catch(error => {\n if (!this.#check(error)) {\n throw error;\n }\n\n return new Promise((resolve, reject) => {\n this.#queue.push(new RetryTask(fn, error, resolve, reject, signal));\n\n signal?.addEventListener(\"abort\", () => {\n reject(signal.reason);\n });\n\n this.#processQueue();\n });\n });\n }\n\n /**\n * Processes the queue.\n * @returns {void}\n */\n #processQueue() {\n // clear any timer because we're going to check right now\n clearTimeout(this.#timerId);\n this.#timerId = undefined;\n\n // if there's nothing in the queue, we're done\n const task = this.#queue.shift();\n if (!task) {\n return;\n }\n const processAgain = () => {\n this.#timerId = setTimeout(() => this.#processQueue(), 0);\n };\n\n // if it's time to bail, then bail\n if (isTimeToBail(task, this.#timeout)) {\n task.reject(task.error);\n processAgain();\n return;\n }\n\n // if it's not time to retry, then wait and try again\n if (!isTimeToRetry(task, this.#maxDelay)) {\n this.#queue.push(task);\n processAgain();\n return;\n }\n\n // otherwise, try again\n task.lastAttempt = Date.now();\n \n // Promise.resolve needed in case it's a thenable but not a Promise\n Promise.resolve(task.fn())\n // @ts-ignore because we know it's any\n .then(result => task.resolve(result))\n\n // @ts-ignore because we know it's any\n .catch(error => {\n if (!this.#check(error)) {\n task.reject(error);\n return;\n }\n\n // update the task timestamp and push to back of queue to try again\n task.lastAttempt = Date.now();\n this.#queue.push(task);\n\n })\n .finally(() => this.#processQueue());\n }\n}\n\nexport { Retrier };\n","/**\n * @fileoverview The main file for the hfs package.\n * @author Nicholas C. Zakas\n */\n/* global Buffer:readonly, URL */\n\n//-----------------------------------------------------------------------------\n// Types\n//-----------------------------------------------------------------------------\n\n/** @typedef {import(\"@humanfs/types\").HfsImpl} HfsImpl */\n/** @typedef {import(\"@humanfs/types\").HfsDirectoryEntry} HfsDirectoryEntry */\n/** @typedef {import(\"node:fs/promises\")} Fsp */\n/** @typedef {import(\"fs\").Dirent} Dirent */\n\n//-----------------------------------------------------------------------------\n// Imports\n//-----------------------------------------------------------------------------\n\nimport { Hfs } from \"@humanfs/core\";\nimport path from \"node:path\";\nimport { Retrier } from \"@humanwhocodes/retry\";\nimport nativeFsp from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\n\n//-----------------------------------------------------------------------------\n// Constants\n//-----------------------------------------------------------------------------\n\nconst RETRY_ERROR_CODES = new Set([\"ENFILE\", \"EMFILE\"]);\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing a directory entry.\n * @implements {HfsDirectoryEntry}\n */\nclass NodeHfsDirectoryEntry {\n\t/**\n\t * The name of the directory entry.\n\t * @type {string}\n\t */\n\tname;\n\n\t/**\n\t * True if the entry is a file.\n\t * @type {boolean}\n\t */\n\tisFile;\n\n\t/**\n\t * True if the entry is a directory.\n\t * @type {boolean}\n\t */\n\tisDirectory;\n\n\t/**\n\t * True if the entry is a symbolic link.\n\t * @type {boolean}\n\t */\n\tisSymlink;\n\n\t/**\n\t * Creates a new instance.\n\t * @param {Dirent} dirent The directory entry to wrap.\n\t */\n\tconstructor(dirent) {\n\t\tthis.name = dirent.name;\n\t\tthis.isFile = dirent.isFile();\n\t\tthis.isDirectory = dirent.isDirectory();\n\t\tthis.isSymlink = dirent.isSymbolicLink();\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing the Node.js implementation of Hfs.\n * @implements {HfsImpl}\n */\nexport class NodeHfsImpl {\n\t/**\n\t * The file system module to use.\n\t * @type {Fsp}\n\t */\n\t#fsp;\n\n\t/**\n\t * The retryer object used for retrying operations.\n\t * @type {Retrier}\n\t */\n\t#retrier;\n\n\t/**\n\t * Creates a new instance.\n\t * @param {object} [options] The options for the instance.\n\t * @param {Fsp} [options.fsp] The file system module to use.\n\t */\n\tconstructor({ fsp = nativeFsp } = {}) {\n\t\tthis.#fsp = fsp;\n\t\tthis.#retrier = new Retrier(error => RETRY_ERROR_CODES.has(error.code));\n\t}\n\n\t/**\n\t * Reads a file and returns the contents as an Uint8Array.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<Uint8Array|undefined>} A promise that resolves with the contents\n\t * of the file or undefined if the file doesn't exist.\n\t * @throws {Error} If the file cannot be read.\n\t * @throws {TypeError} If the file path is not a string.\n\t */\n\tbytes(filePath) {\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.readFile(filePath))\n\t\t\t.then(buffer => new Uint8Array(buffer.buffer))\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Writes a value to a file. If the value is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The path to the file to write.\n\t * @param {Uint8Array} contents The contents to write to the\n\t * file.\n\t * @returns {Promise<void>} A promise that resolves when the file is\n\t * written.\n\t * @throws {TypeError} If the file path is not a string.\n\t * @throws {Error} If the file cannot be written.\n\t */\n\tasync write(filePath, contents) {\n\t\tconst value = Buffer.from(contents);\n\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.writeFile(filePath, value))\n\t\t\t.catch(error => {\n\t\t\t\t// the directory may not exist, so create it\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\tconst dirPath = path.dirname(\n\t\t\t\t\t\tfilePath instanceof URL\n\t\t\t\t\t\t\t? fileURLToPath(filePath)\n\t\t\t\t\t\t\t: filePath,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn this.#fsp\n\t\t\t\t\t\t.mkdir(dirPath, { recursive: true })\n\t\t\t\t\t\t.then(() => this.#fsp.writeFile(filePath, value));\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Appends a value to a file. If the value is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The path to the file to append to.\n\t * @param {Uint8Array} contents The contents to append to the\n\t * file.\n\t * @returns {Promise<void>} A promise that resolves when the file is\n\t * written.\n\t * @throws {TypeError} If the file path is not a string.\n\t * @throws {Error} If the file cannot be appended to.\n\t */\n\tasync append(filePath, contents) {\n\t\tconst value = Buffer.from(contents);\n\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.appendFile(filePath, value))\n\t\t\t.catch(error => {\n\t\t\t\t// the directory may not exist, so create it\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\tconst dirPath = path.dirname(\n\t\t\t\t\t\tfilePath instanceof URL\n\t\t\t\t\t\t\t? fileURLToPath(filePath)\n\t\t\t\t\t\t\t: filePath,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn this.#fsp\n\t\t\t\t\t\t.mkdir(dirPath, { recursive: true })\n\t\t\t\t\t\t.then(() => this.#fsp.appendFile(filePath, value));\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Checks if a file exists.\n\t * @param {string|URL} filePath The path to the file to check.\n\t * @returns {Promise<boolean>} A promise that resolves with true if the\n\t * file exists or false if it does not.\n\t * @throws {Error} If the operation fails with a code other than ENOENT.\n\t */\n\tisFile(filePath) {\n\t\treturn this.#fsp\n\t\t\t.stat(filePath)\n\t\t\t.then(stat => stat.isFile())\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Checks if a directory exists.\n\t * @param {string|URL} dirPath The path to the directory to check.\n\t * @returns {Promise<boolean>} A promise that resolves with true if the\n\t * directory exists or false if it does not.\n\t * @throws {Error} If the operation fails with a code other than ENOENT.\n\t */\n\tisDirectory(dirPath) {\n\t\treturn this.#fsp\n\t\t\t.stat(dirPath)\n\t\t\t.then(stat => stat.isDirectory())\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Creates a directory recursively.\n\t * @param {string|URL} dirPath The path to the directory to create.\n\t * @returns {Promise<void>} A promise that resolves when the directory is\n\t * created.\n\t */\n\tasync createDirectory(dirPath) {\n\t\tawait this.#fsp.mkdir(dirPath, { recursive: true });\n\t}\n\n\t/**\n\t * Deletes a file or empty directory.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory to\n\t * delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {TypeError} If the file or directory path is not a string.\n\t * @throws {Error} If the file or directory cannot be deleted.\n\t */\n\tdelete(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.rm(fileOrDirPath)\n\t\t\t.then(() => true)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ERR_FS_EISDIR\") {\n\t\t\t\t\treturn this.#fsp.rmdir(fileOrDirPath).then(() => true);\n\t\t\t\t}\n\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Deletes a file or directory recursively.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory to\n\t * delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {TypeError} If the file or directory path is not a string.\n\t * @throws {Error} If the file or directory cannot be deleted.\n\t */\n\tdeleteAll(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.rm(fileOrDirPath, { recursive: true })\n\t\t\t.then(() => true)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Returns a list of directory entries for the given path.\n\t * @param {string|URL} dirPath The path to the directory to read.\n\t * @returns {AsyncIterable<HfsDirectoryEntry>} A promise that resolves with the\n\t * directory entries.\n\t * @throws {TypeError} If the directory path is not a string.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *list(dirPath) {\n\t\tconst entries = await this.#fsp.readdir(dirPath, {\n\t\t\twithFileTypes: true,\n\t\t});\n\n\t\tfor (const entry of entries) {\n\t\t\tyield new NodeHfsDirectoryEntry(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the size of a file. This method handles ENOENT errors\n\t * and returns undefined in that case.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<number|undefined>} A promise that resolves with the size of the\n\t * file in bytes or undefined if the file doesn't exist.\n\t */\n\tsize(filePath) {\n\t\treturn this.#fsp\n\t\t\t.stat(filePath)\n\t\t\t.then(stat => stat.size)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Returns the last modified date of a file or directory. This method handles ENOENT errors\n\t * and returns undefined in that case.\n\t * @param {string|URL} fileOrDirPath The path to the file to read.\n\t * @returns {Promise<Date|undefined>} A promise that resolves with the last modified\n\t * date of the file or directory, or undefined if the file doesn't exist.\n\t */\n\tlastModified(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.stat(fileOrDirPath)\n\t\t\t.then(stat => stat.mtime)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Copies a file from one location to another.\n\t * @param {string|URL} source The path to the file to copy.\n\t * @param {string|URL} destination The path to copy the file to.\n\t * @returns {Promise<void>} A promise that resolves when the file is copied.\n\t * @throws {Error} If the source file does not exist.\n\t * @throws {Error} If the source file is a directory.\n\t * @throws {Error} If the destination file is a directory.\n\t */\n\tcopy(source, destination) {\n\t\treturn this.#fsp.copyFile(source, destination);\n\t}\n\n\t/**\n\t * Copies a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to copy.\n\t * @param {string|URL} destination The path to copy the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * copied.\n\t * @throws {Error} If the source file or directory does not exist.\n\t * @throws {Error} If the destination file or directory is a directory.\n\t */\n\tasync copyAll(source, destination) {\n\t\t// for files use copy() and exit\n\t\tif (await this.isFile(source)) {\n\t\t\treturn this.copy(source, destination);\n\t\t}\n\n\t\tconst sourceStr =\n\t\t\tsource instanceof URL ? fileURLToPath(source) : source;\n\n\t\tconst destinationStr =\n\t\t\tdestination instanceof URL\n\t\t\t\t? fileURLToPath(destination)\n\t\t\t\t: destination;\n\n\t\t// for directories, create the destination directory and copy each entry\n\t\tawait this.createDirectory(destination);\n\n\t\tfor await (const entry of this.list(source)) {\n\t\t\tconst fromEntryPath = path.join(sourceStr, entry.name);\n\t\t\tconst toEntryPath = path.join(destinationStr, entry.name);\n\n\t\t\tif (entry.isDirectory) {\n\t\t\t\tawait this.copyAll(fromEntryPath, toEntryPath);\n\t\t\t} else {\n\t\t\t\tawait this.copy(fromEntryPath, toEntryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves a file from the source path to the destination path.\n\t * @param {string|URL} source The location of the file to move.\n\t * @param {string|URL} destination The destination of the file to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file paths are not strings.\n\t * @throws {Error} If the file cannot be moved.\n\t */\n\tmove(source, destination) {\n\t\treturn this.#fsp.stat(source).then(stat => {\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`EISDIR: illegal operation on a directory, move '${source}' -> '${destination}'`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.#fsp.rename(source, destination);\n\t\t});\n\t}\n\n\t/**\n\t * Moves a file or directory from the source path to the destination path.\n\t * @param {string|URL} source The location of the file or directory to move.\n\t * @param {string|URL} destination The destination of the file or directory to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file paths are not strings.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync moveAll(source, destination) {\n\t\treturn this.#fsp.rename(source, destination);\n\t}\n}\n\n/**\n * A class representing a file system utility library.\n * @implements {HfsImpl}\n */\nexport class NodeHfs extends Hfs {\n\t/**\n\t * Creates a new instance.\n\t * @param {object} [options] The options for the instance.\n\t * @param {Fsp} [options.fsp] The file system module to use.\n\t */\n\tconstructor({ fsp } = {}) {\n\t\tsuper({ impl: new NodeHfsImpl({ fsp }) });\n\t}\n}\n\nexport const hfs = new NodeHfs();\n","/**\n * @fileoverview This file exports everything for this package.\n * @author Nicholas C. Zakas\n */\n\nexport * from \"./node-hfs.js\";\nexport { Hfs } from \"@humanfs/core\";\n"],"x_google_ignoreList":[0,1,2,3,4,5],"mappings":";;;;;;;;;;;;AAoEA,SAAS,yBAAyB,eAAe;AAChD,KACC,CAAC,iBACA,EAAE,yBAAyB,QAAQ,OAAO,kBAAkB,SAE7D,OAAM,IAAI,UAAU,0CAA0C;;;;;;;;AAUhE,SAAS,wBAAwB,UAAU;AAC1C,KACC,OAAO,aAAa,YACpB,EAAE,oBAAoB,gBACtB,CAAC,YAAY,OAAO,SAAS,CAE7B,OAAM,IAAI,UACT,oEACA;;;;;;;;AAUH,SAAS,aAAa,UAAU;AAC/B,KAAI,oBAAoB,WACvB,QAAO;AAGR,KAAI,OAAO,aAAa,SACvB,QAAO,QAAQ,OAAO,SAAS;AAGhC,KAAI,oBAAoB,YACvB,QAAO,IAAI,WAAW,SAAS;AAGhC,KAAI,YAAY,OAAO,SAAS,EAAE;EACjC,MAAM,QAAQ,SAAS,OAAO,MAC7B,SAAS,YACT,SAAS,aAAa,SAAS,WAC/B;AACD,SAAO,IAAI,WAAW,MAAM;;AAE7B,OAAM,IAAI,UACT,yDACA;;;;CAxGI,UAAU,IAAI,aAAa;CAC3B,UAAU,IAAI,aAAa;CAKpB,oBAAb,cAAuC,MAAM;;;;;EAK5C,YAAY,YAAY;AACvB,SAAM,WAAW,WAAW,2BAA2B;;;CAS5C,0BAAb,cAA6C,MAAM;;;;;EAKlD,YAAY,YAAY;AACvB,SAAM,WAAW,WAAW,kCAAkC;;;CAOnD,sBAAb,cAAyC,MAAM;;;;EAI9C,cAAc;AACb,SAAM,8BAA8B;;;CA2EzB,WAAb,MAAsB;;;;;EAKrB;;;;;EAMA;;;;;EAMA,YAAY,KA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H,MAAM,QAAQ,QAAQ,aAAa;AAClC,UAAO,MAAKA,IAAK,OAAO,QAAQ,YAAY;;;CAQjC,UAAb,cAA6B,IAAI;;;;;;EAMhC,YAAY,EAAE,QAAQ,EAAE,EAAE;AACzB,SAAM,EAAE,MAAM,IAAI,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;;;CAI9B,MAAM,IAAI,SAAS;;;;;;;aC7bI"}
|
|
1
|
+
{"version":3,"file":"src-QNTCsO6J.mjs","names":["#baseImpl","#impl","#logs","#log","#assertImplMethod","#assertImplMethodAlt","#callImplMethodAlt","#callImplMethod","#callImplMethodWithoutLog","dirPath","entryFilter","directoryFilter","#check","#timeout","#maxDelay","#queue","#processQueue","#timerId","#fsp","#retrier"],"sources":["../../../node_modules/@humanfs/core/src/hfs.js","../../../node_modules/@humanfs/core/src/errors.js","../../../node_modules/@humanfs/core/src/index.js","../../../node_modules/@humanwhocodes/retry/dist/retrier.js","../../../node_modules/@humanfs/node/src/node-hfs.js","../../../node_modules/@humanfs/node/src/index.js"],"sourcesContent":["/**\n * @fileoverview The main file for the humanfs package.\n * @author Nicholas C. Zakas\n */\n\n/* global URL, TextDecoder, TextEncoder */\n\n//-----------------------------------------------------------------------------\n// Types\n//-----------------------------------------------------------------------------\n\n/** @typedef {import(\"@humanfs/types\").HfsImpl} HfsImpl */\n/** @typedef {import(\"@humanfs/types\").HfsDirectoryEntry} HfsDirectoryEntry */\n/** @typedef {import(\"@humanfs/types\").HfsWalkEntry} HfsWalkEntry */\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\nconst decoder = new TextDecoder();\nconst encoder = new TextEncoder();\n\n/**\n * Error to represent when a method is missing on an impl.\n */\nexport class NoSuchMethodError extends Error {\n\t/**\n\t * Creates a new instance.\n\t * @param {string} methodName The name of the method that was missing.\n\t */\n\tconstructor(methodName) {\n\t\tsuper(`Method \"${methodName}\" does not exist on impl.`);\n\t}\n}\n\n/**\n * Error to represent when a method is not supported on an impl. This happens\n * when a method on `Hfs` is called with one name and the corresponding method\n * on the impl has a different name. (Example: `text()` and `bytes()`.)\n */\nexport class MethodNotSupportedError extends Error {\n\t/**\n\t * Creates a new instance.\n\t * @param {string} methodName The name of the method that was missing.\n\t */\n\tconstructor(methodName) {\n\t\tsuper(`Method \"${methodName}\" is not supported on this impl.`);\n\t}\n}\n\n/**\n * Error to represent when an impl is already set.\n */\nexport class ImplAlreadySetError extends Error {\n\t/**\n\t * Creates a new instance.\n\t */\n\tconstructor() {\n\t\tsuper(`Implementation already set.`);\n\t}\n}\n\n/**\n * Asserts that the given path is a valid file path.\n * @param {any} fileOrDirPath The path to check.\n * @returns {void}\n * @throws {TypeError} When the path is not a non-empty string.\n */\nfunction assertValidFileOrDirPath(fileOrDirPath) {\n\tif (\n\t\t!fileOrDirPath ||\n\t\t(!(fileOrDirPath instanceof URL) && typeof fileOrDirPath !== \"string\")\n\t) {\n\t\tthrow new TypeError(\"Path must be a non-empty string or URL.\");\n\t}\n}\n\n/**\n * Asserts that the given file contents are valid.\n * @param {any} contents The contents to check.\n * @returns {void}\n * @throws {TypeError} When the contents are not a string or ArrayBuffer.\n */\nfunction assertValidFileContents(contents) {\n\tif (\n\t\ttypeof contents !== \"string\" &&\n\t\t!(contents instanceof ArrayBuffer) &&\n\t\t!ArrayBuffer.isView(contents)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t\"File contents must be a string, ArrayBuffer, or ArrayBuffer view.\",\n\t\t);\n\t}\n}\n\n/**\n * Converts the given contents to Uint8Array.\n * @param {any} contents The data to convert.\n * @returns {Uint8Array} The converted Uint8Array.\n * @throws {TypeError} When the contents are not a string or ArrayBuffer.\n */\nfunction toUint8Array(contents) {\n\tif (contents instanceof Uint8Array) {\n\t\treturn contents;\n\t}\n\n\tif (typeof contents === \"string\") {\n\t\treturn encoder.encode(contents);\n\t}\n\n\tif (contents instanceof ArrayBuffer) {\n\t\treturn new Uint8Array(contents);\n\t}\n\n\tif (ArrayBuffer.isView(contents)) {\n\t\tconst bytes = contents.buffer.slice(\n\t\t\tcontents.byteOffset,\n\t\t\tcontents.byteOffset + contents.byteLength,\n\t\t);\n\t\treturn new Uint8Array(bytes);\n\t}\n\tthrow new TypeError(\n\t\t\"Invalid contents type. Expected string or ArrayBuffer.\",\n\t);\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing a log entry.\n */\nexport class LogEntry {\n\t/**\n\t * The type of log entry.\n\t * @type {string}\n\t */\n\ttype;\n\n\t/**\n\t * The data associated with the log entry.\n\t * @type {any}\n\t */\n\tdata;\n\n\t/**\n\t * The time at which the log entry was created.\n\t * @type {number}\n\t */\n\ttimestamp = Date.now();\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} type The type of log entry.\n\t * @param {any} [data] The data associated with the log entry.\n\t */\n\tconstructor(type, data) {\n\t\tthis.type = type;\n\t\tthis.data = data;\n\t}\n}\n\n/**\n * A class representing a file system utility library.\n * @implements {HfsImpl}\n */\nexport class Hfs {\n\t/**\n\t * The base implementation for this instance.\n\t * @type {HfsImpl}\n\t */\n\t#baseImpl;\n\n\t/**\n\t * The current implementation for this instance.\n\t * @type {HfsImpl}\n\t */\n\t#impl;\n\n\t/**\n\t * A map of log names to their corresponding entries.\n\t * @type {Map<string,Array<LogEntry>>}\n\t */\n\t#logs = new Map();\n\n\t/**\n\t * Creates a new instance.\n\t * @param {object} options The options for the instance.\n\t * @param {HfsImpl} options.impl The implementation to use.\n\t */\n\tconstructor({ impl }) {\n\t\tthis.#baseImpl = impl;\n\t\tthis.#impl = impl;\n\t}\n\n\t/**\n\t * Logs an entry onto all currently open logs.\n\t * @param {string} methodName The name of the method being called.\n\t * @param {...*} args The arguments to the method.\n\t * @returns {void}\n\t */\n\t#log(methodName, ...args) {\n\t\tfor (const logs of this.#logs.values()) {\n\t\t\tlogs.push(new LogEntry(\"call\", { methodName, args }));\n\t\t}\n\t}\n\n\t/**\n\t * Starts a new log with the given name.\n\t * @param {string} name The name of the log to start;\n\t * @returns {void}\n\t * @throws {Error} When the log already exists.\n\t * @throws {TypeError} When the name is not a non-empty string.\n\t */\n\tlogStart(name) {\n\t\tif (!name || typeof name !== \"string\") {\n\t\t\tthrow new TypeError(\"Log name must be a non-empty string.\");\n\t\t}\n\n\t\tif (this.#logs.has(name)) {\n\t\t\tthrow new Error(`Log \"${name}\" already exists.`);\n\t\t}\n\n\t\tthis.#logs.set(name, []);\n\t}\n\n\t/**\n\t * Ends a log with the given name and returns the entries.\n\t * @param {string} name The name of the log to end.\n\t * @returns {Array<LogEntry>} The entries in the log.\n\t * @throws {Error} When the log does not exist.\n\t */\n\tlogEnd(name) {\n\t\tif (this.#logs.has(name)) {\n\t\t\tconst logs = this.#logs.get(name);\n\t\t\tthis.#logs.delete(name);\n\t\t\treturn logs;\n\t\t}\n\n\t\tthrow new Error(`Log \"${name}\" does not exist.`);\n\t}\n\n\t/**\n\t * Determines if the current implementation is the base implementation.\n\t * @returns {boolean} True if the current implementation is the base implementation.\n\t */\n\tisBaseImpl() {\n\t\treturn this.#impl === this.#baseImpl;\n\t}\n\n\t/**\n\t * Sets the implementation for this instance.\n\t * @param {object} impl The implementation to use.\n\t * @returns {void}\n\t */\n\tsetImpl(impl) {\n\t\tthis.#log(\"implSet\", impl);\n\n\t\tif (this.#impl !== this.#baseImpl) {\n\t\t\tthrow new ImplAlreadySetError();\n\t\t}\n\n\t\tthis.#impl = impl;\n\t}\n\n\t/**\n\t * Resets the implementation for this instance back to its original.\n\t * @returns {void}\n\t */\n\tresetImpl() {\n\t\tthis.#log(\"implReset\");\n\t\tthis.#impl = this.#baseImpl;\n\t}\n\n\t/**\n\t * Asserts that the given method exists on the current implementation.\n\t * @param {string} methodName The name of the method to check.\n\t * @returns {void}\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#assertImplMethod(methodName) {\n\t\tif (typeof this.#impl[methodName] !== \"function\") {\n\t\t\tthrow new NoSuchMethodError(methodName);\n\t\t}\n\t}\n\n\t/**\n\t * Asserts that the given method exists on the current implementation, and if not,\n\t * throws an error with a different method name.\n\t * @param {string} methodName The name of the method to check.\n\t * @param {string} targetMethodName The name of the method that should be reported\n\t * as an error when methodName does not exist.\n\t * @returns {void}\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#assertImplMethodAlt(methodName, targetMethodName) {\n\t\tif (typeof this.#impl[methodName] !== \"function\") {\n\t\t\tthrow new MethodNotSupportedError(targetMethodName);\n\t\t}\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethod(methodName, ...args) {\n\t\tthis.#log(methodName, ...args);\n\t\tthis.#assertImplMethod(methodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation and doesn't log the call.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethodWithoutLog(methodName, ...args) {\n\t\tthis.#assertImplMethod(methodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Calls the given method on the current implementation but logs a different method name.\n\t * @param {string} methodName The name of the method to call.\n\t * @param {string} targetMethodName The name of the method to log.\n\t * @param {...any} args The arguments to the method.\n\t * @returns {any} The return value from the method.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t */\n\t#callImplMethodAlt(methodName, targetMethodName, ...args) {\n\t\tthis.#log(targetMethodName, ...args);\n\t\tthis.#assertImplMethodAlt(methodName, targetMethodName);\n\t\treturn this.#impl[methodName](...args);\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as text. Assumes UTF-8 encoding.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<string|undefined>} The contents of the file.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync text(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\"bytes\", \"text\", filePath);\n\t\treturn result ? decoder.decode(result) : undefined;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as JSON. Assumes UTF-8 encoding.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<any|undefined>} The contents of the file as JSON.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {SyntaxError} When the file contents are not valid JSON.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync json(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\"bytes\", \"json\", filePath);\n\t\treturn result ? JSON.parse(decoder.decode(result)) : undefined;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as an ArrayBuffer.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<ArrayBuffer|undefined>} The contents of the file as an ArrayBuffer.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t * @deprecated Use bytes() instead.\n\t */\n\tasync arrayBuffer(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\n\t\tconst result = await this.#callImplMethodAlt(\n\t\t\t\"bytes\",\n\t\t\t\"arrayBuffer\",\n\t\t\tfilePath,\n\t\t);\n\t\treturn result?.buffer;\n\t}\n\n\t/**\n\t * Reads the given file and returns the contents as an Uint8Array.\n\t * @param {string|URL} filePath The file to read.\n\t * @returns {Promise<Uint8Array|undefined>} The contents of the file as an Uint8Array.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync bytes(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"bytes\", filePath);\n\t}\n\n\t/**\n\t * Writes the given data to the given file. Creates any necessary directories along the way.\n\t * If the data is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The file to write.\n\t * @param {string|ArrayBuffer|ArrayBufferView} contents The data to write.\n\t * @returns {Promise<void>} A promise that resolves when the file is written.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync write(filePath, contents) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\tassertValidFileContents(contents);\n\t\tthis.#log(\"write\", filePath, contents);\n\n\t\tlet value = toUint8Array(contents);\n\t\treturn this.#callImplMethodWithoutLog(\"write\", filePath, value);\n\t}\n\n\t/**\n\t * Appends the given data to the given file. Creates any necessary directories along the way.\n\t * If the data is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The file to append to.\n\t * @param {string|ArrayBuffer|ArrayBufferView} contents The data to append.\n\t * @returns {Promise<void>} A promise that resolves when the file is appended to.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t * @throws {TypeError} When the file contents are not a string or ArrayBuffer.\n\t * @throws {Error} When the file cannot be appended to.\n\t */\n\tasync append(filePath, contents) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\tassertValidFileContents(contents);\n\t\tthis.#log(\"append\", filePath, contents);\n\n\t\tlet value = toUint8Array(contents);\n\t\treturn this.#callImplMethodWithoutLog(\"append\", filePath, value);\n\t}\n\n\t/**\n\t * Determines if the given file exists.\n\t * @param {string|URL} filePath The file to check.\n\t * @returns {Promise<boolean>} True if the file exists.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync isFile(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"isFile\", filePath);\n\t}\n\n\t/**\n\t * Determines if the given directory exists.\n\t * @param {string|URL} dirPath The directory to check.\n\t * @returns {Promise<boolean>} True if the directory exists.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync isDirectory(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"isDirectory\", dirPath);\n\t}\n\n\t/**\n\t * Creates the given directory.\n\t * @param {string|URL} dirPath The directory to create.\n\t * @returns {Promise<void>} A promise that resolves when the directory is created.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync createDirectory(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"createDirectory\", dirPath);\n\t}\n\n\t/**\n\t * Deletes the given file or empty directory.\n\t * @param {string|URL} filePath The file to delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the file path is not a non-empty string.\n\t */\n\tasync delete(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"delete\", filePath);\n\t}\n\n\t/**\n\t * Deletes the given file or directory recursively.\n\t * @param {string|URL} dirPath The directory to delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {NoSuchMethodError} When the method does not exist on the current implementation.\n\t * @throws {TypeError} When the directory path is not a non-empty string.\n\t */\n\tasync deleteAll(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\treturn this.#callImplMethod(\"deleteAll\", dirPath);\n\t}\n\n\t/**\n\t * Returns a list of directory entries for the given path.\n\t * @param {string|URL} dirPath The path to the directory to read.\n\t * @returns {AsyncIterable<HfsDirectoryEntry>} A promise that resolves with the\n\t * directory entries.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *list(dirPath) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\tyield* await this.#callImplMethod(\"list\", dirPath);\n\t}\n\n\t/**\n\t * Walks a directory using a depth-first traversal and returns the entries\n\t * from the traversal.\n\t * @param {string|URL} dirPath The path to the directory to walk.\n\t * @param {Object} [options] The options for the walk.\n\t * @param {(entry:HfsWalkEntry) => Promise<boolean>|boolean} [options.directoryFilter] A filter function to determine\n\t * \tif a directory's entries should be included in the walk.\n\t * @param {(entry:HfsWalkEntry) => Promise<boolean>|boolean} [options.entryFilter] A filter function to determine if\n\t * \tan entry should be included in the walk.\n\t * @returns {AsyncIterable<HfsWalkEntry>} A promise that resolves with the\n\t * \tdirectory entries.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *walk(\n\t\tdirPath,\n\t\t{ directoryFilter = () => true, entryFilter = () => true } = {},\n\t) {\n\t\tassertValidFileOrDirPath(dirPath);\n\t\tthis.#log(\"walk\", dirPath, { directoryFilter, entryFilter });\n\n\t\t// inner function for recursion without additional logging\n\t\tconst walk = async function* (\n\t\t\tdirPath,\n\t\t\t{ directoryFilter, entryFilter, parentPath = \"\", depth = 1 },\n\t\t) {\n\t\t\tlet dirEntries;\n\n\t\t\ttry {\n\t\t\t\tdirEntries = await this.#callImplMethodWithoutLog(\n\t\t\t\t\t\"list\",\n\t\t\t\t\tdirPath,\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\t// if the directory does not exist then return an empty array\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// otherwise, rethrow the error\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tfor await (const listEntry of dirEntries) {\n\t\t\t\tconst walkEntry = {\n\t\t\t\t\tpath: listEntry.name,\n\t\t\t\t\tdepth,\n\t\t\t\t\t...listEntry,\n\t\t\t\t};\n\n\t\t\t\tif (parentPath) {\n\t\t\t\t\twalkEntry.path = `${parentPath}/${walkEntry.path}`;\n\t\t\t\t}\n\n\t\t\t\t// first emit the entry but only if the entry filter returns true\n\t\t\t\tlet shouldEmitEntry = entryFilter(walkEntry);\n\t\t\t\tif (shouldEmitEntry.then) {\n\t\t\t\t\tshouldEmitEntry = await shouldEmitEntry;\n\t\t\t\t}\n\n\t\t\t\tif (shouldEmitEntry) {\n\t\t\t\t\tyield walkEntry;\n\t\t\t\t}\n\n\t\t\t\t// if it's a directory then yield the entry and walk the directory\n\t\t\t\tif (listEntry.isDirectory) {\n\t\t\t\t\t// if the directory filter returns false, skip the directory\n\t\t\t\t\tlet shouldWalkDirectory = directoryFilter(walkEntry);\n\t\t\t\t\tif (shouldWalkDirectory.then) {\n\t\t\t\t\t\tshouldWalkDirectory = await shouldWalkDirectory;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!shouldWalkDirectory) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// make sure there's a trailing slash on the directory path before appending\n\t\t\t\t\tconst directoryPath =\n\t\t\t\t\t\tdirPath instanceof URL\n\t\t\t\t\t\t\t? new URL(\n\t\t\t\t\t\t\t\t\tlistEntry.name,\n\t\t\t\t\t\t\t\t\tdirPath.href.endsWith(\"/\")\n\t\t\t\t\t\t\t\t\t\t? dirPath.href\n\t\t\t\t\t\t\t\t\t\t: `${dirPath.href}/`,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: `${dirPath.endsWith(\"/\") ? dirPath : `${dirPath}/`}${listEntry.name}`;\n\n\t\t\t\t\tyield* walk(directoryPath, {\n\t\t\t\t\t\tdirectoryFilter,\n\t\t\t\t\t\tentryFilter,\n\t\t\t\t\t\tparentPath: walkEntry.path,\n\t\t\t\t\t\tdepth: depth + 1,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}.bind(this);\n\n\t\tyield* walk(dirPath, { directoryFilter, entryFilter });\n\t}\n\n\t/**\n\t * Returns the size of the given file.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<number>} A promise that resolves with the size of the file.\n\t * @throws {TypeError} If the file path is not a string or URL.\n\t * @throws {Error} If the file cannot be read.\n\t */\n\tasync size(filePath) {\n\t\tassertValidFileOrDirPath(filePath);\n\t\treturn this.#callImplMethod(\"size\", filePath);\n\t}\n\n\t/**\n\t * Returns the last modified timestamp of the given file or directory.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory.\n\t * @returns {Promise<Date|undefined>} A promise that resolves with the last modified date\n\t * or undefined if the file or directory does not exist.\n\t * @throws {TypeError} If the path is not a string or URL.\n\t */\n\tasync lastModified(fileOrDirPath) {\n\t\tassertValidFileOrDirPath(fileOrDirPath);\n\t\treturn this.#callImplMethod(\"lastModified\", fileOrDirPath);\n\t}\n\n\t/**\n\t * Copys a file from one location to another.\n\t * @param {string|URL} source The path to the file to copy.\n\t * @param {string|URL} destination The path to the new file.\n\t * @returns {Promise<void>} A promise that resolves when the file is copied.\n\t * @throws {TypeError} If the file path is not a string or URL.\n\t * @throws {Error} If the file cannot be copied.\n\t */\n\tasync copy(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"copy\", source, destination);\n\t}\n\n\t/**\n\t * Copies a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to copy.\n\t * @param {string|URL} destination The path to copy the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * copied.\n\t * @throws {TypeError} If the directory path is not a string or URL.\n\t * @throws {Error} If the directory cannot be copied.\n\t */\n\tasync copyAll(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"copyAll\", source, destination);\n\t}\n\n\t/**\n\t * Moves a file from the source path to the destination path.\n\t * @param {string|URL} source The location of the file to move.\n\t * @param {string|URL} destination The destination of the file to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file or directory paths are not strings.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync move(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"move\", source, destination);\n\t}\n\n\t/**\n\t * Moves a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to move.\n\t * @param {string|URL} destination The path to move the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * moved.\n\t * @throws {TypeError} If the source is not a string or URL.\n\t * @throws {TypeError} If the destination is not a string or URL.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync moveAll(source, destination) {\n\t\tassertValidFileOrDirPath(source);\n\t\tassertValidFileOrDirPath(destination);\n\t\treturn this.#callImplMethod(\"moveAll\", source, destination);\n\t}\n}\n","/**\n * @fileoverview Common error classes\n * @author Nicholas C. Zakas\n */\n\n/**\n * Error thrown when a file or directory is not found.\n */\nexport class NotFoundError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"NotFoundError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"ENOENT\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`ENOENT: No such file or directory, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when an operation is not permitted.\n */\nexport class PermissionError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"PermissionError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"EPERM\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`EPERM: Operation not permitted, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when an operation is not allowed on a directory.\n */\n\nexport class DirectoryError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"DirectoryError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"EISDIR\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`EISDIR: Illegal operation on a directory, ${message}`);\n\t}\n}\n\n/**\n * Error thrown when a directory is not empty.\n */\nexport class NotEmptyError extends Error {\n\t/**\n\t * Name of the error class.\n\t * @type {string}\n\t */\n\tname = \"NotEmptyError\";\n\n\t/**\n\t * Error code.\n\t * @type {string}\n\t */\n\tcode = \"ENOTEMPTY\";\n\n\t/**\n\t * Creates a new instance.\n\t * @param {string} message The error message.\n\t */\n\tconstructor(message) {\n\t\tsuper(`ENOTEMPTY: Directory not empty, ${message}`);\n\t}\n}\n","/**\n * @fileoverview API entrypoint for hfs/core\n * @author Nicholas C. Zakas\n */\n\nexport { Hfs } from \"./hfs.js\";\nexport { Path } from \"./path.js\";\nexport * from \"./errors.js\";\n","// @ts-self-types=\"./retrier.d.ts\"\n/**\n * @fileoverview A utility for retrying failed async method calls.\n */\n\n/* global setTimeout, clearTimeout */\n\n//-----------------------------------------------------------------------------\n// Constants\n//-----------------------------------------------------------------------------\n\nconst MAX_TASK_TIMEOUT = 60000;\nconst MAX_TASK_DELAY = 100;\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\n/*\n * The following logic has been extracted from graceful-fs.\n *\n * The ISC License\n *\n * Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR\n * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Checks if it is time to retry a task based on the timestamp and last attempt time.\n * @param {RetryTask} task The task to check.\n * @param {number} maxDelay The maximum delay for the queue.\n * @returns {boolean} true if it is time to retry, false otherwise.\n */\nfunction isTimeToRetry(task, maxDelay) {\n const timeSinceLastAttempt = Date.now() - task.lastAttempt;\n const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1);\n const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay);\n\n return timeSinceLastAttempt >= desiredDelay;\n}\n\n/**\n * Checks if it is time to bail out based on the given timestamp.\n * @param {RetryTask} task The task to check.\n * @param {number} timeout The timeout for the queue.\n * @returns {boolean} true if it is time to bail, false otherwise.\n */\nfunction isTimeToBail(task, timeout) {\n return task.age > timeout;\n}\n\n\n/**\n * A class to represent a task in the retry queue.\n */\nclass RetryTask {\n\n /**\n * The unique ID for the task.\n * @type {string}\n */\n id = Math.random().toString(36).slice(2);\n\n /**\n * The function to call.\n * @type {Function}\n */\n fn;\n\n /**\n * The error that was thrown.\n * @type {Error}\n */\n error;\n \n /**\n * The timestamp of the task.\n * @type {number}\n */\n timestamp = Date.now();\n\n /**\n * The timestamp of the last attempt.\n * @type {number}\n */\n lastAttempt = this.timestamp;\n\n /**\n * The resolve function for the promise.\n * @type {Function}\n */\n resolve;\n\n /**\n * The reject function for the promise.\n * @type {Function}\n */\n reject;\n\n /**\n * The AbortSignal to monitor for cancellation.\n * @type {AbortSignal|undefined}\n */\n signal;\n\n /**\n * Creates a new instance.\n * @param {Function} fn The function to call.\n * @param {Error} error The error that was thrown.\n * @param {Function} resolve The resolve function for the promise.\n * @param {Function} reject The reject function for the promise.\n * @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation.\n */\n constructor(fn, error, resolve, reject, signal) {\n this.fn = fn;\n this.error = error;\n this.timestamp = Date.now();\n this.lastAttempt = Date.now();\n this.resolve = resolve;\n this.reject = reject;\n this.signal = signal;\n }\n \n /**\n * Gets the age of the task.\n * @returns {number} The age of the task in milliseconds.\n * @readonly\n */\n get age() {\n return Date.now() - this.timestamp;\n }\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class that manages a queue of retry jobs.\n */\nclass Retrier {\n\n /**\n * Represents the queue for processing tasks.\n * @type {Array<RetryTask>}\n */\n #queue = [];\n\n /**\n * The timeout for the queue.\n * @type {number}\n */\n #timeout;\n\n /**\n * The maximum delay for the queue.\n * @type {number}\n */\n #maxDelay;\n\n /**\n * The setTimeout() timer ID.\n * @type {NodeJS.Timeout|undefined}\n */\n #timerId;\n\n /**\n * The function to call.\n * @type {Function}\n */\n #check;\n\n /**\n * Creates a new instance.\n * @param {Function} check The function to call.\n * @param {object} [options] The options for the instance.\n * @param {number} [options.timeout] The timeout for the queue.\n * @param {number} [options.maxDelay] The maximum delay for the queue.\n */\n constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY } = {}) {\n\n if (typeof check !== \"function\") {\n throw new Error(\"Missing function to check errors\");\n }\n\n this.#check = check;\n this.#timeout = timeout;\n this.#maxDelay = maxDelay;\n }\n\n /**\n * Adds a new retry job to the queue.\n * @param {Function} fn The function to call.\n * @param {object} [options] The options for the job.\n * @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation.\n * @returns {Promise<any>} A promise that resolves when the queue is\n * processed.\n */\n retry(fn, { signal } = {}) {\n\n signal?.throwIfAborted();\n\n let result;\n\n try {\n result = fn();\n } catch (/** @type {any} */ error) {\n return Promise.reject(new Error(`Synchronous error: ${error.message}`, { cause: error }));\n }\n\n // if the result is not a promise then reject an error\n if (!result || typeof result.then !== \"function\") {\n return Promise.reject(new Error(\"Result is not a promise.\"));\n }\n\n // call the original function and catch any ENFILE or EMFILE errors\n // @ts-ignore because we know it's any\n return Promise.resolve(result).catch(error => {\n if (!this.#check(error)) {\n throw error;\n }\n\n return new Promise((resolve, reject) => {\n this.#queue.push(new RetryTask(fn, error, resolve, reject, signal));\n\n signal?.addEventListener(\"abort\", () => {\n reject(signal.reason);\n });\n\n this.#processQueue();\n });\n });\n }\n\n /**\n * Processes the queue.\n * @returns {void}\n */\n #processQueue() {\n // clear any timer because we're going to check right now\n clearTimeout(this.#timerId);\n this.#timerId = undefined;\n\n // if there's nothing in the queue, we're done\n const task = this.#queue.shift();\n if (!task) {\n return;\n }\n const processAgain = () => {\n this.#timerId = setTimeout(() => this.#processQueue(), 0);\n };\n\n // if it's time to bail, then bail\n if (isTimeToBail(task, this.#timeout)) {\n task.reject(task.error);\n processAgain();\n return;\n }\n\n // if it's not time to retry, then wait and try again\n if (!isTimeToRetry(task, this.#maxDelay)) {\n this.#queue.push(task);\n processAgain();\n return;\n }\n\n // otherwise, try again\n task.lastAttempt = Date.now();\n \n // Promise.resolve needed in case it's a thenable but not a Promise\n Promise.resolve(task.fn())\n // @ts-ignore because we know it's any\n .then(result => task.resolve(result))\n\n // @ts-ignore because we know it's any\n .catch(error => {\n if (!this.#check(error)) {\n task.reject(error);\n return;\n }\n\n // update the task timestamp and push to back of queue to try again\n task.lastAttempt = Date.now();\n this.#queue.push(task);\n\n })\n .finally(() => this.#processQueue());\n }\n}\n\nexport { Retrier };\n","/**\n * @fileoverview The main file for the hfs package.\n * @author Nicholas C. Zakas\n */\n/* global Buffer:readonly, URL */\n\n//-----------------------------------------------------------------------------\n// Types\n//-----------------------------------------------------------------------------\n\n/** @typedef {import(\"@humanfs/types\").HfsImpl} HfsImpl */\n/** @typedef {import(\"@humanfs/types\").HfsDirectoryEntry} HfsDirectoryEntry */\n/** @typedef {import(\"node:fs/promises\")} Fsp */\n/** @typedef {import(\"fs\").Dirent} Dirent */\n\n//-----------------------------------------------------------------------------\n// Imports\n//-----------------------------------------------------------------------------\n\nimport { Hfs } from \"@humanfs/core\";\nimport path from \"node:path\";\nimport { Retrier } from \"@humanwhocodes/retry\";\nimport nativeFsp from \"node:fs/promises\";\nimport { fileURLToPath } from \"node:url\";\n\n//-----------------------------------------------------------------------------\n// Constants\n//-----------------------------------------------------------------------------\n\nconst RETRY_ERROR_CODES = new Set([\"ENFILE\", \"EMFILE\"]);\n\n//-----------------------------------------------------------------------------\n// Helpers\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing a directory entry.\n * @implements {HfsDirectoryEntry}\n */\nclass NodeHfsDirectoryEntry {\n\t/**\n\t * The name of the directory entry.\n\t * @type {string}\n\t */\n\tname;\n\n\t/**\n\t * True if the entry is a file.\n\t * @type {boolean}\n\t */\n\tisFile;\n\n\t/**\n\t * True if the entry is a directory.\n\t * @type {boolean}\n\t */\n\tisDirectory;\n\n\t/**\n\t * True if the entry is a symbolic link.\n\t * @type {boolean}\n\t */\n\tisSymlink;\n\n\t/**\n\t * Creates a new instance.\n\t * @param {Dirent} dirent The directory entry to wrap.\n\t */\n\tconstructor(dirent) {\n\t\tthis.name = dirent.name;\n\t\tthis.isFile = dirent.isFile();\n\t\tthis.isDirectory = dirent.isDirectory();\n\t\tthis.isSymlink = dirent.isSymbolicLink();\n\t}\n}\n\n//-----------------------------------------------------------------------------\n// Exports\n//-----------------------------------------------------------------------------\n\n/**\n * A class representing the Node.js implementation of Hfs.\n * @implements {HfsImpl}\n */\nexport class NodeHfsImpl {\n\t/**\n\t * The file system module to use.\n\t * @type {Fsp}\n\t */\n\t#fsp;\n\n\t/**\n\t * The retryer object used for retrying operations.\n\t * @type {Retrier}\n\t */\n\t#retrier;\n\n\t/**\n\t * Creates a new instance.\n\t * @param {object} [options] The options for the instance.\n\t * @param {Fsp} [options.fsp] The file system module to use.\n\t */\n\tconstructor({ fsp = nativeFsp } = {}) {\n\t\tthis.#fsp = fsp;\n\t\tthis.#retrier = new Retrier(error => RETRY_ERROR_CODES.has(error.code));\n\t}\n\n\t/**\n\t * Reads a file and returns the contents as an Uint8Array.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<Uint8Array|undefined>} A promise that resolves with the contents\n\t * of the file or undefined if the file doesn't exist.\n\t * @throws {Error} If the file cannot be read.\n\t * @throws {TypeError} If the file path is not a string.\n\t */\n\tbytes(filePath) {\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.readFile(filePath))\n\t\t\t.then(buffer => new Uint8Array(buffer.buffer))\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Writes a value to a file. If the value is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The path to the file to write.\n\t * @param {Uint8Array} contents The contents to write to the\n\t * file.\n\t * @returns {Promise<void>} A promise that resolves when the file is\n\t * written.\n\t * @throws {TypeError} If the file path is not a string.\n\t * @throws {Error} If the file cannot be written.\n\t */\n\tasync write(filePath, contents) {\n\t\tconst value = Buffer.from(contents);\n\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.writeFile(filePath, value))\n\t\t\t.catch(error => {\n\t\t\t\t// the directory may not exist, so create it\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\tconst dirPath = path.dirname(\n\t\t\t\t\t\tfilePath instanceof URL\n\t\t\t\t\t\t\t? fileURLToPath(filePath)\n\t\t\t\t\t\t\t: filePath,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn this.#fsp\n\t\t\t\t\t\t.mkdir(dirPath, { recursive: true })\n\t\t\t\t\t\t.then(() => this.#fsp.writeFile(filePath, value));\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Appends a value to a file. If the value is a string, UTF-8 encoding is used.\n\t * @param {string|URL} filePath The path to the file to append to.\n\t * @param {Uint8Array} contents The contents to append to the\n\t * file.\n\t * @returns {Promise<void>} A promise that resolves when the file is\n\t * written.\n\t * @throws {TypeError} If the file path is not a string.\n\t * @throws {Error} If the file cannot be appended to.\n\t */\n\tasync append(filePath, contents) {\n\t\tconst value = Buffer.from(contents);\n\n\t\treturn this.#retrier\n\t\t\t.retry(() => this.#fsp.appendFile(filePath, value))\n\t\t\t.catch(error => {\n\t\t\t\t// the directory may not exist, so create it\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\tconst dirPath = path.dirname(\n\t\t\t\t\t\tfilePath instanceof URL\n\t\t\t\t\t\t\t? fileURLToPath(filePath)\n\t\t\t\t\t\t\t: filePath,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn this.#fsp\n\t\t\t\t\t\t.mkdir(dirPath, { recursive: true })\n\t\t\t\t\t\t.then(() => this.#fsp.appendFile(filePath, value));\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Checks if a file exists.\n\t * @param {string|URL} filePath The path to the file to check.\n\t * @returns {Promise<boolean>} A promise that resolves with true if the\n\t * file exists or false if it does not.\n\t * @throws {Error} If the operation fails with a code other than ENOENT.\n\t */\n\tisFile(filePath) {\n\t\treturn this.#fsp\n\t\t\t.stat(filePath)\n\t\t\t.then(stat => stat.isFile())\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Checks if a directory exists.\n\t * @param {string|URL} dirPath The path to the directory to check.\n\t * @returns {Promise<boolean>} A promise that resolves with true if the\n\t * directory exists or false if it does not.\n\t * @throws {Error} If the operation fails with a code other than ENOENT.\n\t */\n\tisDirectory(dirPath) {\n\t\treturn this.#fsp\n\t\t\t.stat(dirPath)\n\t\t\t.then(stat => stat.isDirectory())\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Creates a directory recursively.\n\t * @param {string|URL} dirPath The path to the directory to create.\n\t * @returns {Promise<void>} A promise that resolves when the directory is\n\t * created.\n\t */\n\tasync createDirectory(dirPath) {\n\t\tawait this.#fsp.mkdir(dirPath, { recursive: true });\n\t}\n\n\t/**\n\t * Deletes a file or empty directory.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory to\n\t * delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {TypeError} If the file or directory path is not a string.\n\t * @throws {Error} If the file or directory cannot be deleted.\n\t */\n\tdelete(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.rm(fileOrDirPath)\n\t\t\t.then(() => true)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ERR_FS_EISDIR\") {\n\t\t\t\t\treturn this.#fsp.rmdir(fileOrDirPath).then(() => true);\n\t\t\t\t}\n\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Deletes a file or directory recursively.\n\t * @param {string|URL} fileOrDirPath The path to the file or directory to\n\t * delete.\n\t * @returns {Promise<boolean>} A promise that resolves when the file or\n\t * directory is deleted, true if the file or directory is deleted, false\n\t * if the file or directory does not exist.\n\t * @throws {TypeError} If the file or directory path is not a string.\n\t * @throws {Error} If the file or directory cannot be deleted.\n\t */\n\tdeleteAll(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.rm(fileOrDirPath, { recursive: true })\n\t\t\t.then(() => true)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Returns a list of directory entries for the given path.\n\t * @param {string|URL} dirPath The path to the directory to read.\n\t * @returns {AsyncIterable<HfsDirectoryEntry>} A promise that resolves with the\n\t * directory entries.\n\t * @throws {TypeError} If the directory path is not a string.\n\t * @throws {Error} If the directory cannot be read.\n\t */\n\tasync *list(dirPath) {\n\t\tconst entries = await this.#fsp.readdir(dirPath, {\n\t\t\twithFileTypes: true,\n\t\t});\n\n\t\tfor (const entry of entries) {\n\t\t\tyield new NodeHfsDirectoryEntry(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the size of a file. This method handles ENOENT errors\n\t * and returns undefined in that case.\n\t * @param {string|URL} filePath The path to the file to read.\n\t * @returns {Promise<number|undefined>} A promise that resolves with the size of the\n\t * file in bytes or undefined if the file doesn't exist.\n\t */\n\tsize(filePath) {\n\t\treturn this.#fsp\n\t\t\t.stat(filePath)\n\t\t\t.then(stat => stat.size)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Returns the last modified date of a file or directory. This method handles ENOENT errors\n\t * and returns undefined in that case.\n\t * @param {string|URL} fileOrDirPath The path to the file to read.\n\t * @returns {Promise<Date|undefined>} A promise that resolves with the last modified\n\t * date of the file or directory, or undefined if the file doesn't exist.\n\t */\n\tlastModified(fileOrDirPath) {\n\t\treturn this.#fsp\n\t\t\t.stat(fileOrDirPath)\n\t\t\t.then(stat => stat.mtime)\n\t\t\t.catch(error => {\n\t\t\t\tif (error.code === \"ENOENT\") {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * Copies a file from one location to another.\n\t * @param {string|URL} source The path to the file to copy.\n\t * @param {string|URL} destination The path to copy the file to.\n\t * @returns {Promise<void>} A promise that resolves when the file is copied.\n\t * @throws {Error} If the source file does not exist.\n\t * @throws {Error} If the source file is a directory.\n\t * @throws {Error} If the destination file is a directory.\n\t */\n\tcopy(source, destination) {\n\t\treturn this.#fsp.copyFile(source, destination);\n\t}\n\n\t/**\n\t * Copies a file or directory from one location to another.\n\t * @param {string|URL} source The path to the file or directory to copy.\n\t * @param {string|URL} destination The path to copy the file or directory to.\n\t * @returns {Promise<void>} A promise that resolves when the file or directory is\n\t * copied.\n\t * @throws {Error} If the source file or directory does not exist.\n\t * @throws {Error} If the destination file or directory is a directory.\n\t */\n\tasync copyAll(source, destination) {\n\t\t// for files use copy() and exit\n\t\tif (await this.isFile(source)) {\n\t\t\treturn this.copy(source, destination);\n\t\t}\n\n\t\tconst sourceStr =\n\t\t\tsource instanceof URL ? fileURLToPath(source) : source;\n\n\t\tconst destinationStr =\n\t\t\tdestination instanceof URL\n\t\t\t\t? fileURLToPath(destination)\n\t\t\t\t: destination;\n\n\t\t// for directories, create the destination directory and copy each entry\n\t\tawait this.createDirectory(destination);\n\n\t\tfor await (const entry of this.list(source)) {\n\t\t\tconst fromEntryPath = path.join(sourceStr, entry.name);\n\t\t\tconst toEntryPath = path.join(destinationStr, entry.name);\n\n\t\t\tif (entry.isDirectory) {\n\t\t\t\tawait this.copyAll(fromEntryPath, toEntryPath);\n\t\t\t} else {\n\t\t\t\tawait this.copy(fromEntryPath, toEntryPath);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves a file from the source path to the destination path.\n\t * @param {string|URL} source The location of the file to move.\n\t * @param {string|URL} destination The destination of the file to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file paths are not strings.\n\t * @throws {Error} If the file cannot be moved.\n\t */\n\tmove(source, destination) {\n\t\treturn this.#fsp.stat(source).then(stat => {\n\t\t\tif (stat.isDirectory()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`EISDIR: illegal operation on a directory, move '${source}' -> '${destination}'`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn this.#fsp.rename(source, destination);\n\t\t});\n\t}\n\n\t/**\n\t * Moves a file or directory from the source path to the destination path.\n\t * @param {string|URL} source The location of the file or directory to move.\n\t * @param {string|URL} destination The destination of the file or directory to move.\n\t * @returns {Promise<void>} A promise that resolves when the move is complete.\n\t * @throws {TypeError} If the file paths are not strings.\n\t * @throws {Error} If the file or directory cannot be moved.\n\t */\n\tasync moveAll(source, destination) {\n\t\treturn this.#fsp.rename(source, destination);\n\t}\n}\n\n/**\n * A class representing a file system utility library.\n * @implements {HfsImpl}\n */\nexport class NodeHfs extends Hfs {\n\t/**\n\t * Creates a new instance.\n\t * @param {object} [options] The options for the instance.\n\t * @param {Fsp} [options.fsp] The file system module to use.\n\t */\n\tconstructor({ fsp } = {}) {\n\t\tsuper({ impl: new NodeHfsImpl({ fsp }) });\n\t}\n}\n\nexport const hfs = new NodeHfs();\n","/**\n * @fileoverview This file exports everything for this package.\n * @author Nicholas C. Zakas\n */\n\nexport * from \"./node-hfs.js\";\nexport { Hfs } from \"@humanfs/core\";\n"],"x_google_ignoreList":[0,1,2,3,4,5],"mappings":";;;;;;;;;;;;AAoEA,SAAS,yBAAyB,eAAe;AAChD,KACC,CAAC,iBACA,EAAE,yBAAyB,QAAQ,OAAO,kBAAkB,SAE7D,OAAM,IAAI,UAAU,0CAA0C;;;;;;;;AAUhE,SAAS,wBAAwB,UAAU;AAC1C,KACC,OAAO,aAAa,YACpB,EAAE,oBAAoB,gBACtB,CAAC,YAAY,OAAO,SAAS,CAE7B,OAAM,IAAI,UACT,oEACA;;;;;;;;AAUH,SAAS,aAAa,UAAU;AAC/B,KAAI,oBAAoB,WACvB,QAAO;AAGR,KAAI,OAAO,aAAa,SACvB,QAAO,QAAQ,OAAO,SAAS;AAGhC,KAAI,oBAAoB,YACvB,QAAO,IAAI,WAAW,SAAS;AAGhC,K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AGJ,SAAM,KAAK,gBAAgB,YAAY;AAEvC,cAAW,MAAM,SAAS,KAAK,KAAK,OAAO,EAAE;IAC5C,MAAM,gBAAgB,KAAK,KAAK,WAAW,MAAM,KAAK;IACtD,MAAM,cAAc,KAAK,KAAK,gBAAgB,MAAM,KAAK;AAEzD,QAAI,MAAM,YACT,OAAM,KAAK,QAAQ,eAAe,YAAY;QAE9C,OAAM,KAAK,KAAK,eAAe,YAAY;;;;;;;;;;;EAa9C,KAAK,QAAQ,aAAa;AACzB,UAAO,MAAKA,IAAK,KAAK,OAAO,CAAC,MAAK,SAAQ;AAC1C,QAAI,KAAK,aAAa,CACrB,OAAM,IAAI,MACT,mDAAmD,OAAO,QAAQ,YAAY,GAC9E;AAGF,WAAO,MAAKA,IAAK,OAAO,QAAQ,YAAY;KAC3C;;;;;;;;;;EAWH,MAAM,QAAQ,QAAQ,aAAa;AAClC,UAAO,MAAKA,IAAK,OAAO,QAAQ,YAAY;;;CAQjC,UAAb,cAA6B,IAAI;;;;;;EAMhC,YAAY,EAAE,QAAQ,EAAE,EAAE;AACzB,SAAM,EAAE,MAAM,IAAI,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;;;CAI9B,MAAM,IAAI,SAAS;;;;;;;aC7bI"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/parser/service/tailordb/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if source is plugin-generated
|
|
4
|
+
* @param source - Type source info to check
|
|
5
|
+
* @returns True if source is plugin-generated
|
|
6
|
+
*/
|
|
7
|
+
function isPluginGeneratedType(source) {
|
|
8
|
+
return source.pluginId !== void 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { isPluginGeneratedType as t };
|
|
13
|
+
//# sourceMappingURL=types-r-ZratAg.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-r-ZratAg.mjs","names":[],"sources":["../src/parser/service/tailordb/types.ts"],"sourcesContent":["import type { RelationType } from \"./relation\";\nimport type {\n DBFieldMetadataSchema,\n RawRelationConfigSchema,\n TailorDBTypeSchema,\n TailorDBServiceConfig as TailorDBServiceConfigType,\n TailorDBTypeSettingsSchema,\n} from \"./schema\";\nimport type {\n GqlOperations,\n GqlOperationsConfig,\n TailorTypeGqlPermission,\n TailorTypePermission,\n} from \"@/configure/services/tailordb\";\nimport type { ValueOperand } from \"@/parser/service/auth/types\";\nimport type { z } from \"zod\";\n\nexport type { RelationType } from \"./relation\";\nexport type { TypeSourceInfo } from \"./type-parser\";\n\n// ========================================\n// Source info type for TailorDB types\n// ========================================\n\n/**\n * Source information for a user-defined TailorDB type.\n */\nexport interface UserDefinedTypeSource {\n /** File path to import from */\n filePath: string;\n /** Export name in the source file */\n exportName: string;\n /** Not present for user-defined types */\n pluginId?: never;\n}\n\n/**\n * Source information for a plugin-generated TailorDB type.\n */\nexport interface PluginGeneratedTypeSource {\n /** Not present for plugin-generated types */\n filePath?: never;\n /** Export name of the generated type */\n exportName: string;\n /** Plugin ID that generated this type */\n pluginId: string;\n /** Plugin import path for code generators */\n pluginImportPath: string;\n /** Original type's file path */\n originalFilePath: string;\n /** Original type's export name */\n originalExportName: string;\n /** Generated type kind for getGeneratedType() API (e.g., \"request\", \"step\") */\n generatedTypeKind?: string;\n /** Plugin config used to generate this type */\n pluginConfig?: unknown;\n}\n\n/**\n * Source information for a TailorDB type.\n * Discriminated union: use `pluginId` to distinguish between user-defined and plugin-generated types.\n */\nexport type TypeSourceInfoEntry = UserDefinedTypeSource | PluginGeneratedTypeSource;\n\n/**\n * Type guard to check if source is plugin-generated\n * @param source - Type source info to check\n * @returns True if source is plugin-generated\n */\nexport function isPluginGeneratedType(\n source: TypeSourceInfoEntry,\n): source is PluginGeneratedTypeSource {\n return source.pluginId !== undefined;\n}\n\nexport type {\n TailorAnyDBField,\n TailorAnyDBType,\n TailorDBField,\n DBFieldMetadata,\n Hook,\n TailorTypePermission,\n TailorTypeGqlPermission,\n GqlOperationsConfig,\n GqlOperations,\n} from \"@/configure/services/tailordb\";\nexport type {\n TailorDBServiceConfigInput,\n TailorDBServiceConfig,\n TailorDBExternalConfig,\n TailorDBServiceInput,\n} from \"./schema\";\n\n/**\n * Parsed and normalized settings for TailorDB type.\n * gqlOperations is normalized from alias to object format.\n * @public\n */\nexport type TailorDBTypeParsedSettings = z.output<typeof TailorDBTypeSettingsSchema>;\n\n/**\n * Migration configuration for TailorDB\n * @public\n */\nexport type TailorDBMigrationConfig = NonNullable<TailorDBServiceConfigType[\"migration\"]>;\n\nexport type TailorDBTypeSchemaOutput = z.output<typeof TailorDBTypeSchema>;\n\nexport type DBFieldMetadataOutput = z.output<typeof DBFieldMetadataSchema>;\nexport type RawRelationConfigOutput = z.output<typeof RawRelationConfigSchema>;\n\nexport type TailorDBFieldOutput = {\n type: string;\n fields?: Record<string, TailorDBFieldOutput>;\n metadata: DBFieldMetadataOutput;\n rawRelation?: RawRelationConfigOutput;\n};\n\nexport interface Script {\n expr: string;\n}\n\nexport interface EnumValue {\n value: string;\n description?: string;\n}\n\ninterface OperatorValidateConfig {\n script: Script;\n errorMessage: string;\n}\n\ninterface OperatorFieldHook {\n create?: Script;\n update?: Script;\n}\n\n/**\n * Raw relation config stored in configure layer, processed in parser layer.\n * This is the serialized form of RelationConfig from schema.ts where\n * the TailorDBType reference is replaced with the type name string.\n */\nexport interface RawRelationConfig {\n type: RelationType;\n toward: {\n type: string;\n as?: string;\n key?: string;\n };\n backward?: string;\n}\n\nexport interface OperatorFieldConfig {\n type: string;\n required?: boolean;\n description?: string;\n allowedValues?: EnumValue[];\n array?: boolean;\n index?: boolean;\n unique?: boolean;\n vector?: boolean;\n foreignKey?: boolean;\n foreignKeyType?: string;\n foreignKeyField?: string;\n rawRelation?: RawRelationConfig;\n validate?: OperatorValidateConfig[];\n hooks?: OperatorFieldHook;\n serial?: {\n start: number;\n maxValue?: number;\n format?: string;\n };\n fields?: Record<string, OperatorFieldConfig>;\n}\n\ntype GqlPermissionAction = \"read\" | \"create\" | \"update\" | \"delete\" | \"aggregate\" | \"bulkUpsert\";\n\ntype StandardPermissionOperator = \"eq\" | \"ne\" | \"in\" | \"nin\";\n\ntype UserOperand = {\n user: string;\n};\n\ntype RecordOperand<Update extends boolean = false> = Update extends true\n ? { oldRecord: string } | { newRecord: string }\n : { record: string };\n\nexport type PermissionOperand<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = UserOperand | ValueOperand | (Level extends \"record\" ? RecordOperand<Update> : never);\n\nexport type StandardPermissionCondition<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = readonly [\n PermissionOperand<Level, Update>,\n StandardPermissionOperator,\n PermissionOperand<Level, Update>,\n];\n\nexport type StandardActionPermission<\n Level extends \"record\" | \"gql\" = \"record\" | \"gql\",\n Update extends boolean = boolean,\n> = {\n conditions: readonly StandardPermissionCondition<Level, Update>[];\n description?: string;\n permit: \"allow\" | \"deny\";\n};\n\nexport type StandardTailorTypePermission = {\n create: readonly StandardActionPermission<\"record\", false>[];\n read: readonly StandardActionPermission<\"record\", false>[];\n update: readonly StandardActionPermission<\"record\", true>[];\n delete: readonly StandardActionPermission<\"record\", false>[];\n};\n\nexport type StandardGqlPermissionPolicy = {\n conditions: readonly StandardPermissionCondition<\"gql\">[];\n actions: readonly [\"all\"] | readonly GqlPermissionAction[];\n permit: \"allow\" | \"deny\";\n description?: string;\n};\n\nexport type StandardTailorTypeGqlPermission = readonly StandardGqlPermissionPolicy[];\n\nexport interface Permissions {\n record?: StandardTailorTypePermission;\n gql?: StandardTailorTypeGqlPermission;\n}\n\nexport interface RawPermissions {\n // Raw permissions are user-provided\n // oxlint-disable-next-line no-explicit-any\n record?: TailorTypePermission<any, any>;\n // Raw permissions are user-provided\n // oxlint-disable-next-line no-explicit-any\n gql?: TailorTypeGqlPermission<any, any>;\n}\n\nexport interface TailorDBTypeMetadata {\n name: string;\n description?: string;\n settings?: {\n pluralForm?: string;\n aggregation?: boolean;\n bulkUpsert?: boolean;\n gqlOperations?: GqlOperationsConfig;\n };\n permissions: RawPermissions;\n files: Record<string, string>;\n indexes?: Record<\n string,\n {\n fields: string[];\n unique?: boolean;\n }\n >;\n}\n\n/**\n * Parsed and normalized TailorDB field information\n */\nexport interface ParsedField {\n name: string;\n config: OperatorFieldConfig;\n relation?: {\n targetType: string;\n forwardName: string;\n backwardName: string;\n key: string;\n unique: boolean;\n };\n}\n\n/**\n * Parsed and normalized TailorDB relationship information\n */\nexport interface ParsedRelationship {\n name: string;\n targetType: string;\n targetField: string;\n sourceField: string;\n isArray: boolean;\n description: string;\n}\n\n/**\n * Parsed and normalized TailorDB type information\n */\nexport interface TailorDBType {\n name: string;\n pluralForm: string;\n description?: string;\n fields: Record<string, ParsedField>;\n forwardRelationships: Record<string, ParsedRelationship>;\n backwardRelationships: Record<string, ParsedRelationship>;\n settings: TailorDBTypeParsedSettings;\n permissions: Permissions;\n indexes?: TailorDBTypeMetadata[\"indexes\"];\n files?: TailorDBTypeMetadata[\"files\"];\n}\n"],"mappings":";;;;;;AAqEA,SAAgB,sBACd,QACqC;AACrC,QAAO,OAAO,aAAa"}
|