@nmakarov/cli-toolkit 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2108,7 +2108,37 @@ var FileDatabase = class {
2108
2108
  // Synopsis calculation functions
2109
2109
  fileSynopsisFunction = null;
2110
2110
  versionSynopsisFunction = null;
2111
- constructor(config2) {
2111
+ /**
2112
+ * Constructor - accepts context as first parameter (new pattern)
2113
+ * or config object (legacy pattern for backward compatibility)
2114
+ */
2115
+ constructor(contextOrConfig, options) {
2116
+ let config2;
2117
+ if (contextOrConfig && typeof contextOrConfig === "object" && "params" in contextOrConfig) {
2118
+ const context = contextOrConfig;
2119
+ const opts = options || {};
2120
+ const defs = {
2121
+ basePath: "string default ./data",
2122
+ namespace: "string default default",
2123
+ tableName: "string",
2124
+ maxVersions: "number default 5",
2125
+ pageSize: "number default 5000"
2126
+ };
2127
+ const paramsConfig = context.params.getAll(defs);
2128
+ config2 = {
2129
+ basePath: opts.basePath ?? paramsConfig.basePath,
2130
+ namespace: opts.namespace ?? paramsConfig.namespace,
2131
+ tableName: opts.tableName ?? paramsConfig.tableName ?? null,
2132
+ versioned: opts.versioned ?? true,
2133
+ maxVersions: opts.maxVersions ?? paramsConfig.maxVersions,
2134
+ pageSize: opts.pageSize ?? paramsConfig.pageSize,
2135
+ useMetadata: opts.useMetadata ?? true,
2136
+ freeSpaceThreshold: opts.freeSpaceThreshold ?? 100 * 1024 * 1024,
2137
+ logger: context.logger
2138
+ };
2139
+ } else {
2140
+ config2 = contextOrConfig;
2141
+ }
2112
2142
  if (!config2.basePath) {
2113
2143
  throw new ParamError("[FileDatabase] basePath is required");
2114
2144
  }
@@ -2791,6 +2821,9 @@ var FileDatabase = class {
2791
2821
  return { ...this.metadata };
2792
2822
  }
2793
2823
  };
2824
+ function fileDatabaseInit(context, options = {}) {
2825
+ return new FileDatabase(context, options);
2826
+ }
2794
2827
 
2795
2828
  // src/db/index.ts
2796
2829
  import knex from "knex";
@@ -3482,6 +3515,7 @@ export {
3482
3515
  buildFooter,
3483
3516
  defaultFileSynopsisFunction,
3484
3517
  defaultVersionSynopsisFunction,
3518
+ fileDatabaseInit,
3485
3519
  getArgsInstance,
3486
3520
  createElement2 as h,
3487
3521
  joiEdateType,