@auth-gate/core 0.10.0 → 0.11.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/dist/index.d.cts +77 -16
- package/dist/index.d.ts +77 -16
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -690,6 +690,10 @@ declare class ConfigurationError extends AuthGateError {
|
|
|
690
690
|
|
|
691
691
|
/**
|
|
692
692
|
* Connection details for the AuthGate API.
|
|
693
|
+
*
|
|
694
|
+
* Both fields are optional at the type level because they can be provided
|
|
695
|
+
* via environment variables (`AUTHGATE_URL`, `AUTHGATE_API_KEY`). The CLI
|
|
696
|
+
* auto-loads `.env` and `.env.local` before importing the config file.
|
|
693
697
|
*/
|
|
694
698
|
type AuthGateConnection = {
|
|
695
699
|
baseUrl?: string;
|
|
@@ -697,13 +701,57 @@ type AuthGateConnection = {
|
|
|
697
701
|
};
|
|
698
702
|
/**
|
|
699
703
|
* Project-level config shape for `authgate.config.ts`.
|
|
700
|
-
*
|
|
704
|
+
*
|
|
705
|
+
* Used by both the `@auth-gate/rbac` and `@auth-gate/billing` CLIs to
|
|
706
|
+
* connect to the AuthGate API when syncing roles, permissions, plans, and
|
|
707
|
+
* features. The config file is auto-discovered in the project root.
|
|
701
708
|
*
|
|
702
709
|
* The CLI auto-loads `.env` and `.env.local` before importing this file,
|
|
703
|
-
* so you can reference `process.env`
|
|
710
|
+
* so you can reference `process.env` directly.
|
|
711
|
+
*/
|
|
712
|
+
interface AuthGateProjectConfig {
|
|
713
|
+
/**
|
|
714
|
+
* Connection details for the AuthGate API.
|
|
715
|
+
*
|
|
716
|
+
* If omitted, the CLI falls back to `AUTHGATE_URL` and `AUTHGATE_API_KEY`
|
|
717
|
+
* environment variables.
|
|
718
|
+
*/
|
|
719
|
+
connection?: AuthGateConnection;
|
|
720
|
+
/**
|
|
721
|
+
* Path to the RBAC config file (`authgate.rbac.ts`).
|
|
722
|
+
*
|
|
723
|
+
* Overrides auto-discovery. Useful in monorepos where the RBAC config
|
|
724
|
+
* lives in a different directory than the project root.
|
|
725
|
+
*
|
|
726
|
+
* @example `"./packages/api/authgate.rbac.ts"`
|
|
727
|
+
*/
|
|
728
|
+
rbacConfig?: string;
|
|
729
|
+
/**
|
|
730
|
+
* Path to the Billing config file (`authgate.billing.ts`).
|
|
731
|
+
*
|
|
732
|
+
* Overrides auto-discovery. Useful in monorepos where the billing config
|
|
733
|
+
* lives in a different directory than the project root.
|
|
734
|
+
*
|
|
735
|
+
* @example `"./packages/api/authgate.billing.ts"`
|
|
736
|
+
*/
|
|
737
|
+
billingConfig?: string;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Define your project-level AuthGate configuration.
|
|
704
741
|
*
|
|
705
|
-
*
|
|
742
|
+
* Create an `authgate.config.ts` file in your project root and export
|
|
743
|
+
* the result of this function as the default export. This gives you
|
|
744
|
+
* type safety and IDE autocomplete for the config.
|
|
745
|
+
*
|
|
746
|
+
* The CLI auto-loads `.env` and `.env.local` before importing the
|
|
747
|
+
* config, so `process.env` values are available.
|
|
748
|
+
*
|
|
749
|
+
* @param config - The project configuration object.
|
|
750
|
+
* @returns The same config object (identity function for type inference).
|
|
751
|
+
*
|
|
752
|
+
* @example Minimal setup (env vars provide connection details)
|
|
706
753
|
* ```ts
|
|
754
|
+
* // authgate.config.ts
|
|
707
755
|
* import { defineConfig } from "@auth-gate/core";
|
|
708
756
|
*
|
|
709
757
|
* export default defineConfig({
|
|
@@ -713,20 +761,33 @@ type AuthGateConnection = {
|
|
|
713
761
|
* },
|
|
714
762
|
* });
|
|
715
763
|
* ```
|
|
716
|
-
*/
|
|
717
|
-
interface AuthGateProjectConfig {
|
|
718
|
-
/** Connection details for the AuthGate API. */
|
|
719
|
-
connection?: AuthGateConnection;
|
|
720
|
-
/** Path to the RBAC config file (overrides auto-discovery). */
|
|
721
|
-
rbacConfig?: string;
|
|
722
|
-
/** Path to the Billing config file (overrides auto-discovery). */
|
|
723
|
-
billingConfig?: string;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Define your project-level AuthGate config. Use this in `authgate.config.ts`.
|
|
727
764
|
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
765
|
+
* @example Monorepo with custom config paths
|
|
766
|
+
* ```ts
|
|
767
|
+
* // authgate.config.ts
|
|
768
|
+
* import { defineConfig } from "@auth-gate/core";
|
|
769
|
+
*
|
|
770
|
+
* export default defineConfig({
|
|
771
|
+
* connection: {
|
|
772
|
+
* baseUrl: process.env.AUTHGATE_URL,
|
|
773
|
+
* apiKey: process.env.AUTHGATE_API_KEY,
|
|
774
|
+
* },
|
|
775
|
+
* rbacConfig: "./packages/api/authgate.rbac.ts",
|
|
776
|
+
* billingConfig: "./packages/api/authgate.billing.ts",
|
|
777
|
+
* });
|
|
778
|
+
* ```
|
|
779
|
+
*
|
|
780
|
+
* @example Then sync with the CLI
|
|
781
|
+
* ```sh
|
|
782
|
+
* # Scaffold the config file
|
|
783
|
+
* npx @auth-gate/rbac init --config
|
|
784
|
+
*
|
|
785
|
+
* # Sync RBAC roles & permissions
|
|
786
|
+
* npx @auth-gate/rbac sync --apply
|
|
787
|
+
*
|
|
788
|
+
* # Sync billing plans & features
|
|
789
|
+
* npx @auth-gate/billing sync --apply
|
|
790
|
+
* ```
|
|
730
791
|
*/
|
|
731
792
|
declare function defineConfig(config: AuthGateProjectConfig): AuthGateProjectConfig;
|
|
732
793
|
|
package/dist/index.d.ts
CHANGED
|
@@ -690,6 +690,10 @@ declare class ConfigurationError extends AuthGateError {
|
|
|
690
690
|
|
|
691
691
|
/**
|
|
692
692
|
* Connection details for the AuthGate API.
|
|
693
|
+
*
|
|
694
|
+
* Both fields are optional at the type level because they can be provided
|
|
695
|
+
* via environment variables (`AUTHGATE_URL`, `AUTHGATE_API_KEY`). The CLI
|
|
696
|
+
* auto-loads `.env` and `.env.local` before importing the config file.
|
|
693
697
|
*/
|
|
694
698
|
type AuthGateConnection = {
|
|
695
699
|
baseUrl?: string;
|
|
@@ -697,13 +701,57 @@ type AuthGateConnection = {
|
|
|
697
701
|
};
|
|
698
702
|
/**
|
|
699
703
|
* Project-level config shape for `authgate.config.ts`.
|
|
700
|
-
*
|
|
704
|
+
*
|
|
705
|
+
* Used by both the `@auth-gate/rbac` and `@auth-gate/billing` CLIs to
|
|
706
|
+
* connect to the AuthGate API when syncing roles, permissions, plans, and
|
|
707
|
+
* features. The config file is auto-discovered in the project root.
|
|
701
708
|
*
|
|
702
709
|
* The CLI auto-loads `.env` and `.env.local` before importing this file,
|
|
703
|
-
* so you can reference `process.env`
|
|
710
|
+
* so you can reference `process.env` directly.
|
|
711
|
+
*/
|
|
712
|
+
interface AuthGateProjectConfig {
|
|
713
|
+
/**
|
|
714
|
+
* Connection details for the AuthGate API.
|
|
715
|
+
*
|
|
716
|
+
* If omitted, the CLI falls back to `AUTHGATE_URL` and `AUTHGATE_API_KEY`
|
|
717
|
+
* environment variables.
|
|
718
|
+
*/
|
|
719
|
+
connection?: AuthGateConnection;
|
|
720
|
+
/**
|
|
721
|
+
* Path to the RBAC config file (`authgate.rbac.ts`).
|
|
722
|
+
*
|
|
723
|
+
* Overrides auto-discovery. Useful in monorepos where the RBAC config
|
|
724
|
+
* lives in a different directory than the project root.
|
|
725
|
+
*
|
|
726
|
+
* @example `"./packages/api/authgate.rbac.ts"`
|
|
727
|
+
*/
|
|
728
|
+
rbacConfig?: string;
|
|
729
|
+
/**
|
|
730
|
+
* Path to the Billing config file (`authgate.billing.ts`).
|
|
731
|
+
*
|
|
732
|
+
* Overrides auto-discovery. Useful in monorepos where the billing config
|
|
733
|
+
* lives in a different directory than the project root.
|
|
734
|
+
*
|
|
735
|
+
* @example `"./packages/api/authgate.billing.ts"`
|
|
736
|
+
*/
|
|
737
|
+
billingConfig?: string;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Define your project-level AuthGate configuration.
|
|
704
741
|
*
|
|
705
|
-
*
|
|
742
|
+
* Create an `authgate.config.ts` file in your project root and export
|
|
743
|
+
* the result of this function as the default export. This gives you
|
|
744
|
+
* type safety and IDE autocomplete for the config.
|
|
745
|
+
*
|
|
746
|
+
* The CLI auto-loads `.env` and `.env.local` before importing the
|
|
747
|
+
* config, so `process.env` values are available.
|
|
748
|
+
*
|
|
749
|
+
* @param config - The project configuration object.
|
|
750
|
+
* @returns The same config object (identity function for type inference).
|
|
751
|
+
*
|
|
752
|
+
* @example Minimal setup (env vars provide connection details)
|
|
706
753
|
* ```ts
|
|
754
|
+
* // authgate.config.ts
|
|
707
755
|
* import { defineConfig } from "@auth-gate/core";
|
|
708
756
|
*
|
|
709
757
|
* export default defineConfig({
|
|
@@ -713,20 +761,33 @@ type AuthGateConnection = {
|
|
|
713
761
|
* },
|
|
714
762
|
* });
|
|
715
763
|
* ```
|
|
716
|
-
*/
|
|
717
|
-
interface AuthGateProjectConfig {
|
|
718
|
-
/** Connection details for the AuthGate API. */
|
|
719
|
-
connection?: AuthGateConnection;
|
|
720
|
-
/** Path to the RBAC config file (overrides auto-discovery). */
|
|
721
|
-
rbacConfig?: string;
|
|
722
|
-
/** Path to the Billing config file (overrides auto-discovery). */
|
|
723
|
-
billingConfig?: string;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Define your project-level AuthGate config. Use this in `authgate.config.ts`.
|
|
727
764
|
*
|
|
728
|
-
*
|
|
729
|
-
*
|
|
765
|
+
* @example Monorepo with custom config paths
|
|
766
|
+
* ```ts
|
|
767
|
+
* // authgate.config.ts
|
|
768
|
+
* import { defineConfig } from "@auth-gate/core";
|
|
769
|
+
*
|
|
770
|
+
* export default defineConfig({
|
|
771
|
+
* connection: {
|
|
772
|
+
* baseUrl: process.env.AUTHGATE_URL,
|
|
773
|
+
* apiKey: process.env.AUTHGATE_API_KEY,
|
|
774
|
+
* },
|
|
775
|
+
* rbacConfig: "./packages/api/authgate.rbac.ts",
|
|
776
|
+
* billingConfig: "./packages/api/authgate.billing.ts",
|
|
777
|
+
* });
|
|
778
|
+
* ```
|
|
779
|
+
*
|
|
780
|
+
* @example Then sync with the CLI
|
|
781
|
+
* ```sh
|
|
782
|
+
* # Scaffold the config file
|
|
783
|
+
* npx @auth-gate/rbac init --config
|
|
784
|
+
*
|
|
785
|
+
* # Sync RBAC roles & permissions
|
|
786
|
+
* npx @auth-gate/rbac sync --apply
|
|
787
|
+
*
|
|
788
|
+
* # Sync billing plans & features
|
|
789
|
+
* npx @auth-gate/billing sync --apply
|
|
790
|
+
* ```
|
|
730
791
|
*/
|
|
731
792
|
declare function defineConfig(config: AuthGateProjectConfig): AuthGateProjectConfig;
|
|
732
793
|
|