@revstackhq/providers-registry 0.0.0-20260207005540

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/LICENSE ADDED
@@ -0,0 +1,38 @@
1
+ BUSINESS SOURCE LICENSE 1.1
2
+
3
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make use of the Licensed Work for any purpose, except as limited by the Additional Use Grant below.
4
+
5
+ Redistribution is allowed only if this License is included with the Licensed Work and any derivative works.
6
+
7
+ ADDITIONAL USE GRANT:
8
+
9
+ You may make use of the Licensed Work, provided that you do not use the Licensed Work to provide a "Managed Payment Orchestration Service".
10
+
11
+ A "Managed Payment Orchestration Service" is defined as a commercial service, product, or offering where the Licensed Work is used to provide payment routing, checkout orchestration, or connection management to third parties as a service (SaaS, PaaS, or IaaS), whether for a fee or free of charge.
12
+
13
+ For clarity:
14
+ 1. You MAY use the Licensed Work internally to process payments for your own business or merchandise.
15
+ 2. You MAY NOT use the Licensed Work to build a competitor service to Revstack that allows your customers to orchestrate their own payments.
16
+
17
+ CHANGE DATE:
18
+
19
+ January 1, 2031
20
+
21
+ CHANGE LICENSE:
22
+
23
+ Apache License, Version 2.0
24
+
25
+ ERROR CORRECTIONS AND SECURITY UPDATES:
26
+
27
+ The Licensor may, at its option, provide error corrections and security updates to the Licensed Work. If the Licensor provides such error corrections and security updates, they are considered part of the Licensed Work and are subject to this License.
28
+
29
+ MANAGED SERVICE EXCEPTION:
30
+
31
+ If you have a separate written agreement with the Licensor (e.g., an Enterprise License) that specifically grants you the right to provide a Managed Payment Orchestration Service, that agreement supersedes the limitations of the Additional Use Grant.
32
+
33
+ *****************************************************************************
34
+
35
+ LICENSOR: Revstack Inc.
36
+ LICENSED WORK: The Revstack OS software and associated documentation.
37
+
38
+ *****************************************************************************
@@ -0,0 +1,43 @@
1
+ import { IProvider, ProviderManifest } from '@revstackhq/providers-core';
2
+
3
+ /**
4
+ * Factory class responsible for instantiating Provider SDKs.
5
+ * It acts as the bridge between the Registry (loading mechanism) and the Core (execution).
6
+ */
7
+ declare class ProviderFactory {
8
+ /**
9
+ * Instantiates a Provider SDK by its slug.
10
+ * * @param slug - The unique identifier of the provider (e.g., "stripe", "polar").
11
+ * @returns An instance of the provider class implementing the IProvider contract.
12
+ * @throws Error if the provider is not registered or fails to load.
13
+ */
14
+ static create(slug: string): Promise<IProvider>;
15
+ }
16
+
17
+ /**
18
+ * Defines the shape of the module exported by a Provider Package.
19
+ * Example: import * as stripeModule from '@revstack/provider-stripe';
20
+ */
21
+ interface ProviderModule {
22
+ /**
23
+ * The main class exported by the provider.
24
+ * Must implement the IProvider interface and have a constructor.
25
+ */
26
+ DefaultProvider: new () => IProvider;
27
+ manifest: ProviderManifest;
28
+ }
29
+ /**
30
+ * A function that loads a provider module dynamically.
31
+ * Used for lazy loading via import().
32
+ */
33
+ type ProviderLoader = () => Promise<ProviderModule>;
34
+
35
+ declare function registerProvider(slug: string, loader: ProviderLoader): void;
36
+ declare function getProviderLoader(slug: string): ProviderLoader | undefined;
37
+ declare function listRegisteredProviders(): string[];
38
+ declare function listAvailableProviders(): string[];
39
+ declare function registerBuiltInProviders(): void;
40
+ declare function getProviderManifest(slug: string): Promise<ProviderManifest | null>;
41
+ declare function getCatalog(): Promise<ProviderManifest[]>;
42
+
43
+ export { ProviderFactory, type ProviderLoader, type ProviderModule, getCatalog, getProviderLoader, getProviderManifest, listAvailableProviders, listRegisteredProviders, registerBuiltInProviders, registerProvider };
package/dist/index.js ADDED
@@ -0,0 +1,104 @@
1
+ // src/registry.ts
2
+ var loaders = {};
3
+ var builtInProviders = {
4
+ stripe: () => import("@revstackhq/provider-stripe")
5
+ };
6
+ function registerProvider(slug, loader) {
7
+ loaders[slug] = loader;
8
+ }
9
+ function getProviderLoader(slug) {
10
+ return loaders[slug];
11
+ }
12
+ function listRegisteredProviders() {
13
+ return Object.keys(loaders).sort();
14
+ }
15
+ function listAvailableProviders() {
16
+ return Object.keys(builtInProviders).sort();
17
+ }
18
+ function registerBuiltInProviders() {
19
+ for (const [slug, loader] of Object.entries(builtInProviders)) {
20
+ registerProvider(slug, loader);
21
+ }
22
+ }
23
+ async function getProviderManifest(slug) {
24
+ const loader = getProviderLoader(slug);
25
+ if (!loader) return null;
26
+ try {
27
+ const module = await loader();
28
+ if (module.manifest) {
29
+ return module.manifest;
30
+ }
31
+ const rawModule = module;
32
+ for (const key of Object.keys(rawModule)) {
33
+ const exportItem = rawModule[key];
34
+ if (exportItem && typeof exportItem === "function" && "manifest" in exportItem) {
35
+ console.log(`\u2705 Manifest found in static property ${key}`);
36
+ return exportItem.manifest;
37
+ }
38
+ }
39
+ if (rawModule.default && rawModule.default.manifest) {
40
+ return rawModule.default.manifest;
41
+ }
42
+ if (rawModule.default && typeof rawModule.default === "function" && "manifest" in rawModule.default) {
43
+ return rawModule.default.manifest;
44
+ }
45
+ console.warn(
46
+ `\u26A0\uFE0F Manifest not found for ${slug}. Available keys:`,
47
+ Object.keys(rawModule)
48
+ );
49
+ return null;
50
+ } catch (e) {
51
+ console.error(`\u274C Error loading manifest for provider: ${slug}`);
52
+ console.error(e);
53
+ return null;
54
+ }
55
+ }
56
+ async function getCatalog() {
57
+ const slugs = listRegisteredProviders();
58
+ const manifests = await Promise.all(
59
+ slugs.map((slug) => getProviderManifest(slug))
60
+ );
61
+ return manifests.filter((m) => !!m);
62
+ }
63
+
64
+ // src/factory.ts
65
+ var ProviderFactory = class {
66
+ /**
67
+ * Instantiates a Provider SDK by its slug.
68
+ * * @param slug - The unique identifier of the provider (e.g., "stripe", "polar").
69
+ * @returns An instance of the provider class implementing the IProvider contract.
70
+ * @throws Error if the provider is not registered or fails to load.
71
+ */
72
+ static async create(slug) {
73
+ const loader = getProviderLoader(slug);
74
+ if (!loader) {
75
+ const knownProviders = listRegisteredProviders();
76
+ throw new Error(
77
+ `Provider '${slug}' is not registered in Revstack. Available providers: [${knownProviders.join(", ")}]`
78
+ );
79
+ }
80
+ try {
81
+ const module = await loader();
82
+ if (!module.DefaultProvider) {
83
+ throw new Error(
84
+ `The package for '${slug}' does not export a 'DefaultProvider' class.`
85
+ );
86
+ }
87
+ return new module.DefaultProvider();
88
+ } catch (error) {
89
+ throw new Error(
90
+ `Failed to initialize provider '${slug}'. Details: ${error.message || error}`
91
+ );
92
+ }
93
+ }
94
+ };
95
+ export {
96
+ ProviderFactory,
97
+ getCatalog,
98
+ getProviderLoader,
99
+ getProviderManifest,
100
+ listAvailableProviders,
101
+ listRegisteredProviders,
102
+ registerBuiltInProviders,
103
+ registerProvider
104
+ };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@revstackhq/providers-registry",
3
+ "version": "0.0.0-20260207005540",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "dependencies": {
12
+ "@revstackhq/providers-core": "0.2.0",
13
+ "@revstackhq/provider-stripe": "0.2.1"
14
+ },
15
+ "devDependencies": {
16
+ "@eslint/js": "^9.39.1",
17
+ "@types/node": "^20.11.30",
18
+ "eslint": "^9.39.1",
19
+ "eslint-config-prettier": "^10.1.1",
20
+ "eslint-plugin-turbo": "^2.7.1",
21
+ "tsup": "^8.1.0",
22
+ "typescript": "5.9.2",
23
+ "typescript-eslint": "^8.50.0",
24
+ "@revstackhq/eslint-config": "0.0.0"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "tsup src/index.ts --format esm --dts --clean --splitting",
31
+ "check-types": "tsc -p tsconfig.json --noEmit",
32
+ "lint": "eslint \"src/**/*.{ts,tsx}\""
33
+ }
34
+ }