@dotsec/core 5.0.0-feat-init-kms-validation.8b08ffb → 5.0.0-feat-local-encryption.bae90e1

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/README.md CHANGED
@@ -37,6 +37,32 @@ const formatted = format('FOO=bar\n');
37
37
  // 'FOO=bar\n'
38
38
  ```
39
39
 
40
+ ### Schema operations
41
+
42
+ ```js
43
+ import {
44
+ validateAgainstSchema, formatBySchema, discoverSchema,
45
+ loadSchema, parseSchema, schemaToJsonSchema, schemaToTypescript
46
+ } from '@dotsec/core';
47
+ import { readFileSync } from 'node:fs';
48
+
49
+ // Discover and load a schema file
50
+ const schemaPath = discoverSchema('.sec'); // finds dotsec.schema or null
51
+ const schemaEntries = loadSchema(); // parses discovered schema or null
52
+
53
+ // Validate .env against a schema
54
+ const source = readFileSync('.env', 'utf8');
55
+ const schemaSource = readFileSync('dotsec.schema', 'utf8');
56
+ const errors = validateAgainstSchema(source, schemaSource);
57
+
58
+ // Reorder .env to match schema key ordering
59
+ const reordered = formatBySchema(source, schemaSource);
60
+
61
+ // Code generation from schema
62
+ const jsonSchema = schemaToJsonSchema(schemaSource); // JSON Schema (draft-07) string
63
+ const typescript = schemaToTypescript(schemaSource); // TypeScript declarations
64
+ ```
65
+
40
66
  ## Supported directives
41
67
 
42
68
  - `@encrypt` / `@plaintext` — mark variables for encryption
@@ -45,7 +71,7 @@ const formatted = format('FOO=bar\n');
45
71
  - `@push=aws-ssm|aws-secrets-manager` — push targets with options
46
72
  - `@provider`, `@key-id`, `@region` — file-level encryption config
47
73
 
48
- See the [full documentation](https://jpwesselink.github.io/dotsec-rs/beta/guide/directives.html) for details.
74
+ See the [full documentation](https://jpwesselink.github.io/dotsec-rs/guide/directives.html) for details.
49
75
 
50
76
  ## Platforms
51
77
 
package/index.d.ts CHANGED
@@ -13,6 +13,12 @@ export interface ParsedEntry {
13
13
  export interface ParsedValidationError {
14
14
  key: string;
15
15
  message: string;
16
+ severity: string;
17
+ }
18
+
19
+ export interface ParsedSchemaEntry {
20
+ key: string;
21
+ directives: DirectiveItem[];
16
22
  }
17
23
 
18
24
  /** Parse a .env file string and return entries with their directives. */
@@ -26,3 +32,24 @@ export declare function toJson(source: string): string;
26
32
 
27
33
  /** Roundtrip: parse a .env file string and serialize it back. */
28
34
  export declare function format(source: string): string;
35
+
36
+ /** Validate a .env file against a schema string. Returns validation errors. */
37
+ export declare function validateAgainstSchema(source: string, schemaSource: string): ParsedValidationError[];
38
+
39
+ /** Format a .env file to match schema key ordering. */
40
+ export declare function formatBySchema(source: string, schemaSource: string): string;
41
+
42
+ /** Discover the schema file path for a given .sec file. Returns null if no schema found. */
43
+ export declare function discoverSchema(secFilePath: string, explicitSchema?: string | undefined | null): string | null;
44
+
45
+ /** Load and parse a schema file from disk. Uses discovery if no path given. Returns null if no schema found. */
46
+ export declare function loadSchema(secFilePath?: string | undefined | null, explicitSchema?: string | undefined | null): ParsedSchemaEntry[] | null;
47
+
48
+ /** Parse a schema file string and return entries with their directives. */
49
+ export declare function parseSchema(source: string): ParsedSchemaEntry[];
50
+
51
+ /** Convert a schema file to JSON Schema (draft-07). */
52
+ export declare function schemaToJsonSchema(schemaSource: string): string;
53
+
54
+ /** Generate TypeScript code from a schema file. */
55
+ export declare function schemaToTypescript(schemaSource: string): string;
package/index.js CHANGED
@@ -44,5 +44,5 @@ try {
44
44
  }
45
45
  }
46
46
 
47
- export const { parse, validate, toJson, format } = nativeModule;
47
+ export const { parse, validate, toJson, format, validateAgainstSchema, formatBySchema, discoverSchema, loadSchema, parseSchema, schemaToJsonSchema, schemaToTypescript } = nativeModule;
48
48
  export default nativeModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotsec/core",
3
- "version": "5.0.0-feat-init-kms-validation.8b08ffb",
3
+ "version": "5.0.0-feat-local-encryption.bae90e1",
4
4
  "description": "Native Node.js bindings for dotsec — parse, validate, and format .env files",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -26,12 +26,12 @@
26
26
  "url": "https://github.com/jpwesselink/dotsec-rs"
27
27
  },
28
28
  "optionalDependencies": {
29
- "@dotsec/core-darwin-arm64": "5.0.0-feat-init-kms-validation.8b08ffb",
30
- "@dotsec/core-darwin-x64": "5.0.0-feat-init-kms-validation.8b08ffb",
31
- "@dotsec/core-linux-x64-gnu": "5.0.0-feat-init-kms-validation.8b08ffb",
32
- "@dotsec/core-linux-arm64-gnu": "5.0.0-feat-init-kms-validation.8b08ffb",
33
- "@dotsec/core-win32-x64-msvc": "5.0.0-feat-init-kms-validation.8b08ffb",
34
- "@dotsec/core-win32-arm64-msvc": "5.0.0-feat-init-kms-validation.8b08ffb"
29
+ "@dotsec/core-darwin-arm64": "5.0.0-feat-local-encryption.bae90e1",
30
+ "@dotsec/core-darwin-x64": "5.0.0-feat-local-encryption.bae90e1",
31
+ "@dotsec/core-linux-x64-gnu": "5.0.0-feat-local-encryption.bae90e1",
32
+ "@dotsec/core-linux-arm64-gnu": "5.0.0-feat-local-encryption.bae90e1",
33
+ "@dotsec/core-win32-x64-msvc": "5.0.0-feat-local-encryption.bae90e1",
34
+ "@dotsec/core-win32-arm64-msvc": "5.0.0-feat-local-encryption.bae90e1"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"