tauri-plugin-configurate-api 0.2.0 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist-js/index.d.ts +34 -43
  2. package/package.json +1 -1
@@ -166,17 +166,14 @@ export declare class LazyConfigEntry<S extends SchemaObject> {
166
166
  */
167
167
  unlock(opts: KeyringOptions): Promise<UnlockedConfig<S>>;
168
168
  }
169
- /** Options passed to the `Configurate` constructor. */
170
- export interface ConfigurateOptions {
171
- /**
172
- * Full filename for the configuration file, including extension.
173
- *
174
- * Examples: `"app.json"`, `"data.yaml"`, `"settings.binc"`, `".env"`.
175
- *
176
- * Must be a single path component — path separators (`/`, `\`) are rejected
177
- * by the Rust side. Use the `path` option to store files in a sub-directory.
178
- */
179
- name: string;
169
+ /**
170
+ * Base options shared across all configs created by a `ConfigurateFactory`.
171
+ * `name` is omitted because each config provides its own filename.
172
+ *
173
+ * `dirName` replaces the app identifier component of the base path.
174
+ * `path` adds a sub-directory within the root (after `dirName` / identifier).
175
+ */
176
+ export interface ConfigurateBaseOptions {
180
177
  /** Base directory in which the configuration file will be stored. */
181
178
  dir: BaseDirectory;
182
179
  /**
@@ -193,17 +190,6 @@ export interface ConfigurateOptions {
193
190
  *
194
191
  * Each segment is validated on the Rust side; `..` and Windows-forbidden
195
192
  * characters are rejected.
196
- *
197
- * @example
198
- * ```ts
199
- * // → %APPDATA%/my-app/app.json (identifier replaced)
200
- * new Configurate(schema, {
201
- * name: "app.json",
202
- * dir: BaseDirectory.AppConfig,
203
- * format: "json",
204
- * dirName: "my-app",
205
- * });
206
- * ```
207
193
  */
208
194
  dirName?: string;
209
195
  /**
@@ -221,17 +207,6 @@ export interface ConfigurateOptions {
221
207
  * | `"my-app"` | _(omitted)_ | `%APPDATA%/my-app/<name>` |
222
208
  * | _(omitted)_ | `"cfg/v2"` | `%APPDATA%/com.example.app/cfg/v2/<name>` |
223
209
  * | `"my-app"` | `"cfg/v2"` | `%APPDATA%/my-app/cfg/v2/<name>` |
224
- *
225
- * @example
226
- * ```ts
227
- * // → %APPDATA%/com.example.app/profiles/settings.json
228
- * new Configurate(schema, {
229
- * name: "settings.json",
230
- * dir: BaseDirectory.AppConfig,
231
- * format: "json",
232
- * path: "profiles",
233
- * });
234
- * ```
235
210
  */
236
211
  path?: string;
237
212
  /** On-disk storage format. */
@@ -249,6 +224,18 @@ export interface ConfigurateOptions {
249
224
  */
250
225
  encryptionKey?: string;
251
226
  }
227
+ /** Options passed to the `Configurate` constructor. */
228
+ export interface ConfigurateOptions extends ConfigurateBaseOptions {
229
+ /**
230
+ * Full filename for the configuration file, including extension.
231
+ *
232
+ * Examples: `"app.json"`, `"data.yaml"`, `"settings.binc"`, `".env"`.
233
+ *
234
+ * Must be a single path component — path separators (`/`, `\`) are rejected
235
+ * by the Rust side. Use the `path` option to store files in a sub-directory.
236
+ */
237
+ name: string;
238
+ }
252
239
  /**
253
240
  * Main entry point for managing application configuration.
254
241
  *
@@ -333,13 +320,20 @@ export declare class Configurate<S extends SchemaObject> {
333
320
  _buildPayload(op: "create" | "load" | "save", data: InferUnlocked<S> | undefined, keyringOpts: KeyringOptions | null, withUnlock: boolean): Record<string, unknown>;
334
321
  }
335
322
  /**
336
- * Base options shared across all configs created by a `ConfigurateFactory`.
337
- * `name` is omitted because each config provides its own.
323
+ * Object form accepted by `ConfigurateFactory.build()` as the second argument.
338
324
  *
339
- * `dirName` replaces the app identifier component of the base path.
340
- * `path` adds a sub-directory within the root (after `dirName` / identifier).
325
+ * - `name` filename (may include a relative path, e.g. `"config/state.bin"`)
326
+ * - `path` sub-directory appended after the root / `dirName`; `null` disables the factory-level value
327
+ * - `dirName` — replaces the app identifier segment; `null` disables the factory-level value
341
328
  */
342
- export type ConfigurateBaseOptions = Omit<ConfigurateOptions, "name">;
329
+ export interface BuildConfig {
330
+ /** Filename including extension. May contain `/`-separated path segments (e.g. `"config/state.bin"`). */
331
+ name: string;
332
+ /** Optional sub-directory within the root. Pass `null` to disable the factory-level value. */
333
+ path?: string | null;
334
+ /** Optional replacement for the app identifier directory. Pass `null` to disable the factory-level value. */
335
+ dirName?: string | null;
336
+ }
343
337
  /**
344
338
  * A factory that creates `Configurate` instances with pre-set shared options
345
339
  * (`dir`, `format`, and optionally `dirName`, `path`, `encryptionKey`).
@@ -408,12 +402,9 @@ export declare class ConfigurateFactory {
408
402
  * factory.build(schema, { name: "cfg.json", dirName: "my-app", path: "a/b" }) // → %APPDATA%/my-app/a/b/cfg.json
409
403
  * ```
410
404
  */
405
+ build<S extends SchemaObject>(schema: S & (true extends HasDuplicateKeyringIds<S> ? never : unknown), nameOrConfig: string | BuildConfig, dirName?: string): Configurate<S>;
406
+ build<S extends SchemaObject>(schema: S & (true extends HasDuplicateKeyringIds<S> ? never : unknown), config: BuildConfig): Configurate<S>;
411
407
  build<S extends SchemaObject>(schema: S & (true extends HasDuplicateKeyringIds<S> ? never : unknown), name: string, dirName?: string): Configurate<S>;
412
- build<S extends SchemaObject>(schema: S & (true extends HasDuplicateKeyringIds<S> ? never : unknown), config: {
413
- name: string;
414
- path?: string | null;
415
- dirName?: string | null;
416
- }): Configurate<S>;
417
408
  }
418
409
  /**
419
410
  * Defines a configuration schema. Provides a convenient declaration site and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-configurate-api",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A Tauri v2 plugin for type-safe application configuration management.",
5
5
  "keywords": [
6
6
  "config",