@plures/praxis 0.2.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/FRAMEWORK.md +420 -0
- package/LICENSE +21 -0
- package/README.md +1310 -0
- package/dist/adapters/cli.d.ts +43 -0
- package/dist/adapters/cli.d.ts.map +1 -0
- package/dist/adapters/cli.js +126 -0
- package/dist/adapters/cli.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +26 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +233 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/cloud.d.ts +27 -0
- package/dist/cli/commands/cloud.d.ts.map +1 -0
- package/dist/cli/commands/cloud.js +232 -0
- package/dist/cli/commands/cloud.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +25 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +168 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +179 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cloud/auth.d.ts +51 -0
- package/dist/cloud/auth.d.ts.map +1 -0
- package/dist/cloud/auth.js +194 -0
- package/dist/cloud/auth.js.map +1 -0
- package/dist/cloud/billing.d.ts +184 -0
- package/dist/cloud/billing.d.ts.map +1 -0
- package/dist/cloud/billing.js +179 -0
- package/dist/cloud/billing.js.map +1 -0
- package/dist/cloud/client.d.ts +39 -0
- package/dist/cloud/client.d.ts.map +1 -0
- package/dist/cloud/client.js +176 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/cloud/index.d.ts +44 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +44 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/cloud/marketplace.d.ts +166 -0
- package/dist/cloud/marketplace.d.ts.map +1 -0
- package/dist/cloud/marketplace.js +159 -0
- package/dist/cloud/marketplace.js.map +1 -0
- package/dist/cloud/provisioning.d.ts +110 -0
- package/dist/cloud/provisioning.d.ts.map +1 -0
- package/dist/cloud/provisioning.js +148 -0
- package/dist/cloud/provisioning.js.map +1 -0
- package/dist/cloud/relay/endpoints.d.ts +62 -0
- package/dist/cloud/relay/endpoints.d.ts.map +1 -0
- package/dist/cloud/relay/endpoints.js +217 -0
- package/dist/cloud/relay/endpoints.js.map +1 -0
- package/dist/cloud/relay/health/index.d.ts +5 -0
- package/dist/cloud/relay/health/index.d.ts.map +1 -0
- package/dist/cloud/relay/health/index.js +9 -0
- package/dist/cloud/relay/health/index.js.map +1 -0
- package/dist/cloud/relay/stats/index.d.ts +5 -0
- package/dist/cloud/relay/stats/index.d.ts.map +1 -0
- package/dist/cloud/relay/stats/index.js +9 -0
- package/dist/cloud/relay/stats/index.js.map +1 -0
- package/dist/cloud/relay/sync/index.d.ts +5 -0
- package/dist/cloud/relay/sync/index.d.ts.map +1 -0
- package/dist/cloud/relay/sync/index.js +9 -0
- package/dist/cloud/relay/sync/index.js.map +1 -0
- package/dist/cloud/relay/usage/index.d.ts +5 -0
- package/dist/cloud/relay/usage/index.d.ts.map +1 -0
- package/dist/cloud/relay/usage/index.js +9 -0
- package/dist/cloud/relay/usage/index.js.map +1 -0
- package/dist/cloud/sponsors.d.ts +81 -0
- package/dist/cloud/sponsors.d.ts.map +1 -0
- package/dist/cloud/sponsors.js +130 -0
- package/dist/cloud/sponsors.js.map +1 -0
- package/dist/cloud/types.d.ts +169 -0
- package/dist/cloud/types.d.ts.map +1 -0
- package/dist/cloud/types.js +7 -0
- package/dist/cloud/types.js.map +1 -0
- package/dist/components/index.d.ts +43 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +17 -0
- package/dist/components/index.js.map +1 -0
- package/dist/core/actors.d.ts +95 -0
- package/dist/core/actors.d.ts.map +1 -0
- package/dist/core/actors.js +158 -0
- package/dist/core/actors.js.map +1 -0
- package/dist/core/component/generator.d.ts +122 -0
- package/dist/core/component/generator.d.ts.map +1 -0
- package/dist/core/component/generator.js +307 -0
- package/dist/core/component/generator.js.map +1 -0
- package/dist/core/engine.d.ts +92 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +199 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/introspection.d.ts +141 -0
- package/dist/core/introspection.d.ts.map +1 -0
- package/dist/core/introspection.js +208 -0
- package/dist/core/introspection.js.map +1 -0
- package/dist/core/logic/generator.d.ts +76 -0
- package/dist/core/logic/generator.d.ts.map +1 -0
- package/dist/core/logic/generator.js +339 -0
- package/dist/core/logic/generator.js.map +1 -0
- package/dist/core/pluresdb/generator.d.ts +58 -0
- package/dist/core/pluresdb/generator.d.ts.map +1 -0
- package/dist/core/pluresdb/generator.js +162 -0
- package/dist/core/pluresdb/generator.js.map +1 -0
- package/dist/core/protocol.d.ts +121 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +46 -0
- package/dist/core/protocol.js.map +1 -0
- package/dist/core/rules.d.ts +120 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +81 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/schema/loader.d.ts +47 -0
- package/dist/core/schema/loader.d.ts.map +1 -0
- package/dist/core/schema/loader.js +189 -0
- package/dist/core/schema/loader.js.map +1 -0
- package/dist/core/schema/normalize.d.ts +72 -0
- package/dist/core/schema/normalize.d.ts.map +1 -0
- package/dist/core/schema/normalize.js +190 -0
- package/dist/core/schema/normalize.js.map +1 -0
- package/dist/core/schema/types.d.ts +370 -0
- package/dist/core/schema/types.d.ts.map +1 -0
- package/dist/core/schema/types.js +161 -0
- package/dist/core/schema/types.js.map +1 -0
- package/dist/dsl/index.d.ts +152 -0
- package/dist/dsl/index.d.ts.map +1 -0
- package/dist/dsl/index.js +132 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/dsl.d.ts +124 -0
- package/dist/dsl.d.ts.map +1 -0
- package/dist/dsl.js +130 -0
- package/dist/dsl.js.map +1 -0
- package/dist/examples/advanced-todo/index.d.ts +55 -0
- package/dist/examples/advanced-todo/index.d.ts.map +1 -0
- package/dist/examples/advanced-todo/index.js +222 -0
- package/dist/examples/advanced-todo/index.js.map +1 -0
- package/dist/examples/auth-basic/index.d.ts +17 -0
- package/dist/examples/auth-basic/index.d.ts.map +1 -0
- package/dist/examples/auth-basic/index.js +122 -0
- package/dist/examples/auth-basic/index.js.map +1 -0
- package/dist/examples/cart/index.d.ts +19 -0
- package/dist/examples/cart/index.d.ts.map +1 -0
- package/dist/examples/cart/index.js +202 -0
- package/dist/examples/cart/index.js.map +1 -0
- package/dist/examples/hero-ecommerce/index.d.ts +39 -0
- package/dist/examples/hero-ecommerce/index.d.ts.map +1 -0
- package/dist/examples/hero-ecommerce/index.js +506 -0
- package/dist/examples/hero-ecommerce/index.js.map +1 -0
- package/dist/examples/svelte-counter/index.d.ts +31 -0
- package/dist/examples/svelte-counter/index.d.ts.map +1 -0
- package/dist/examples/svelte-counter/index.js +123 -0
- package/dist/examples/svelte-counter/index.js.map +1 -0
- package/dist/flows.d.ts +125 -0
- package/dist/flows.d.ts.map +1 -0
- package/dist/flows.js +160 -0
- package/dist/flows.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/pluresdb.d.ts +56 -0
- package/dist/integrations/pluresdb.d.ts.map +1 -0
- package/dist/integrations/pluresdb.js +46 -0
- package/dist/integrations/pluresdb.js.map +1 -0
- package/dist/integrations/svelte.d.ts +306 -0
- package/dist/integrations/svelte.d.ts.map +1 -0
- package/dist/integrations/svelte.js +447 -0
- package/dist/integrations/svelte.js.map +1 -0
- package/dist/registry.d.ts +94 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +181 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime/terminal-adapter.d.ts +105 -0
- package/dist/runtime/terminal-adapter.d.ts.map +1 -0
- package/dist/runtime/terminal-adapter.js +113 -0
- package/dist/runtime/terminal-adapter.js.map +1 -0
- package/dist/step.d.ts +34 -0
- package/dist/step.d.ts.map +1 -0
- package/dist/step.js +111 -0
- package/dist/step.js.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/docs/MONETIZATION.md +394 -0
- package/docs/TERMINAL_NODE.md +588 -0
- package/docs/guides/canvas.md +389 -0
- package/docs/guides/getting-started.md +347 -0
- package/docs/guides/history-state-pattern.md +618 -0
- package/docs/guides/orchestration.md +617 -0
- package/docs/guides/parallel-state-pattern.md +767 -0
- package/docs/guides/svelte-integration.md +691 -0
- package/package.json +96 -0
- package/src/__tests__/actors.test.ts +270 -0
- package/src/__tests__/billing.test.ts +175 -0
- package/src/__tests__/cloud.test.ts +247 -0
- package/src/__tests__/dsl.test.ts +154 -0
- package/src/__tests__/edge-cases.test.ts +475 -0
- package/src/__tests__/engine.test.ts +137 -0
- package/src/__tests__/generators.test.ts +270 -0
- package/src/__tests__/introspection.test.ts +321 -0
- package/src/__tests__/protocol.test.ts +40 -0
- package/src/__tests__/provisioning.test.ts +162 -0
- package/src/__tests__/schema.test.ts +241 -0
- package/src/__tests__/svelte-integration.test.ts +431 -0
- package/src/__tests__/terminal-node.test.ts +352 -0
- package/src/adapters/cli.ts +175 -0
- package/src/cli/commands/auth.ts +271 -0
- package/src/cli/commands/cloud.ts +281 -0
- package/src/cli/commands/generate.ts +225 -0
- package/src/cli/index.ts +190 -0
- package/src/cloud/README.md +383 -0
- package/src/cloud/auth.ts +245 -0
- package/src/cloud/billing.ts +336 -0
- package/src/cloud/client.ts +221 -0
- package/src/cloud/index.ts +121 -0
- package/src/cloud/marketplace.ts +303 -0
- package/src/cloud/provisioning.ts +254 -0
- package/src/cloud/relay/endpoints.ts +307 -0
- package/src/cloud/relay/health/function.json +17 -0
- package/src/cloud/relay/health/index.ts +10 -0
- package/src/cloud/relay/host.json +15 -0
- package/src/cloud/relay/local.settings.json +8 -0
- package/src/cloud/relay/stats/function.json +17 -0
- package/src/cloud/relay/stats/index.ts +10 -0
- package/src/cloud/relay/sync/function.json +17 -0
- package/src/cloud/relay/sync/index.ts +10 -0
- package/src/cloud/relay/usage/function.json +17 -0
- package/src/cloud/relay/usage/index.ts +10 -0
- package/src/cloud/sponsors.ts +213 -0
- package/src/cloud/types.ts +198 -0
- package/src/components/README.md +125 -0
- package/src/components/TerminalNode.svelte +457 -0
- package/src/components/index.ts +46 -0
- package/src/core/actors.ts +205 -0
- package/src/core/component/generator.ts +432 -0
- package/src/core/engine.ts +243 -0
- package/src/core/introspection.ts +329 -0
- package/src/core/logic/generator.ts +420 -0
- package/src/core/pluresdb/generator.ts +229 -0
- package/src/core/protocol.ts +132 -0
- package/src/core/rules.ts +167 -0
- package/src/core/schema/loader.ts +247 -0
- package/src/core/schema/normalize.ts +322 -0
- package/src/core/schema/types.ts +557 -0
- package/src/dsl/index.ts +218 -0
- package/src/dsl.ts +214 -0
- package/src/examples/advanced-todo/App.svelte +506 -0
- package/src/examples/advanced-todo/README.md +371 -0
- package/src/examples/advanced-todo/index.ts +309 -0
- package/src/examples/auth-basic/index.ts +163 -0
- package/src/examples/cart/index.ts +259 -0
- package/src/examples/hero-ecommerce/index.ts +657 -0
- package/src/examples/svelte-counter/index.ts +168 -0
- package/src/flows.ts +268 -0
- package/src/index.ts +154 -0
- package/src/integrations/pluresdb.ts +93 -0
- package/src/integrations/svelte.ts +617 -0
- package/src/registry.ts +223 -0
- package/src/runtime/terminal-adapter.ts +175 -0
- package/src/step.ts +151 -0
- package/src/types.ts +70 -0
- package/templates/basic-app/README.md +147 -0
- package/templates/fullstack-app/README.md +279 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Relay Client
|
|
3
|
+
*
|
|
4
|
+
* Client for connecting to Praxis Cloud Relay service (Azure-based).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create a cloud relay client
|
|
8
|
+
*/
|
|
9
|
+
export function createCloudRelay(config) {
|
|
10
|
+
let status = {
|
|
11
|
+
connected: false,
|
|
12
|
+
endpoint: config.endpoint,
|
|
13
|
+
appId: config.appId,
|
|
14
|
+
};
|
|
15
|
+
let syncTimer = null;
|
|
16
|
+
const vectorClock = {};
|
|
17
|
+
return {
|
|
18
|
+
async connect() {
|
|
19
|
+
// Validate endpoint
|
|
20
|
+
if (!config.endpoint) {
|
|
21
|
+
throw new Error("Cloud relay endpoint is required");
|
|
22
|
+
}
|
|
23
|
+
// Test connection
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetch(`${config.endpoint}/health`, {
|
|
26
|
+
method: "GET",
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
...(config.authToken && {
|
|
30
|
+
Authorization: `Bearer ${config.authToken}`,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`Health check failed: ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
status.connected = true;
|
|
38
|
+
status.lastSync = Date.now();
|
|
39
|
+
// Start auto-sync if enabled
|
|
40
|
+
if (config.autoSync) {
|
|
41
|
+
const interval = config.syncInterval || 5000;
|
|
42
|
+
syncTimer = setInterval(() => {
|
|
43
|
+
// Auto-sync logic would go here
|
|
44
|
+
// For now, just update lastSync
|
|
45
|
+
status.lastSync = Date.now();
|
|
46
|
+
}, interval);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
status.connected = false;
|
|
51
|
+
throw new Error(`Failed to connect to cloud relay: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
async disconnect() {
|
|
55
|
+
if (syncTimer) {
|
|
56
|
+
clearInterval(syncTimer);
|
|
57
|
+
syncTimer = null;
|
|
58
|
+
}
|
|
59
|
+
status.connected = false;
|
|
60
|
+
},
|
|
61
|
+
async sync(message) {
|
|
62
|
+
if (!status.connected) {
|
|
63
|
+
throw new Error("Not connected to cloud relay");
|
|
64
|
+
}
|
|
65
|
+
// Update vector clock
|
|
66
|
+
vectorClock[config.appId] = (vectorClock[config.appId] || 0) + 1;
|
|
67
|
+
message.clock = { ...vectorClock };
|
|
68
|
+
try {
|
|
69
|
+
const response = await fetch(`${config.endpoint}/sync`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
...(config.authToken && {
|
|
74
|
+
Authorization: `Bearer ${config.authToken}`,
|
|
75
|
+
}),
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify(message),
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
throw new Error(`Sync failed: ${response.statusText}`);
|
|
81
|
+
}
|
|
82
|
+
status.lastSync = Date.now();
|
|
83
|
+
// Merge received vector clock
|
|
84
|
+
const result = await response.json();
|
|
85
|
+
if (result.clock) {
|
|
86
|
+
Object.entries(result.clock).forEach(([key, value]) => {
|
|
87
|
+
vectorClock[key] = Math.max(vectorClock[key] || 0, value);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to sync: ${error instanceof Error ? error.message : String(error)}`);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async getUsage() {
|
|
96
|
+
if (!status.connected) {
|
|
97
|
+
throw new Error("Not connected to cloud relay");
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const response = await fetch(`${config.endpoint}/usage?appId=${config.appId}`, {
|
|
101
|
+
method: "GET",
|
|
102
|
+
headers: {
|
|
103
|
+
"Content-Type": "application/json",
|
|
104
|
+
...(config.authToken && {
|
|
105
|
+
Authorization: `Bearer ${config.authToken}`,
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`Failed to get usage: ${response.statusText}`);
|
|
111
|
+
}
|
|
112
|
+
return await response.json();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
throw new Error(`Failed to get usage metrics: ${error instanceof Error ? error.message : String(error)}`);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
async getHealth() {
|
|
119
|
+
try {
|
|
120
|
+
const response = await fetch(`${config.endpoint}/health`, {
|
|
121
|
+
method: "GET",
|
|
122
|
+
headers: {
|
|
123
|
+
"Content-Type": "application/json",
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
throw new Error(`Health check failed: ${response.statusText}`);
|
|
128
|
+
}
|
|
129
|
+
return await response.json();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
throw new Error(`Failed to get health status: ${error instanceof Error ? error.message : String(error)}`);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
getStatus() {
|
|
136
|
+
return { ...status };
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Connect to Praxis Cloud Relay
|
|
142
|
+
*
|
|
143
|
+
* @param endpoint - Azure Function App endpoint URL
|
|
144
|
+
* @param options - Additional configuration options
|
|
145
|
+
* @returns Cloud relay client instance
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* import { connectRelay } from "@plures/praxis/cloud";
|
|
150
|
+
*
|
|
151
|
+
* const relay = await connectRelay("https://my-app.azurewebsites.net", {
|
|
152
|
+
* appId: "my-app",
|
|
153
|
+
* authToken: "github-token",
|
|
154
|
+
* autoSync: true
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* // Sync data
|
|
158
|
+
* await relay.sync({
|
|
159
|
+
* type: "delta",
|
|
160
|
+
* appId: "my-app",
|
|
161
|
+
* clock: {},
|
|
162
|
+
* facts: [...],
|
|
163
|
+
* timestamp: Date.now()
|
|
164
|
+
* });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export async function connectRelay(endpoint, options = { appId: "default" }) {
|
|
168
|
+
const config = {
|
|
169
|
+
endpoint,
|
|
170
|
+
...options,
|
|
171
|
+
};
|
|
172
|
+
const client = createCloudRelay(config);
|
|
173
|
+
await client.connect();
|
|
174
|
+
return client;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,IAAI,MAAM,GAAgB;QACxB,SAAS,EAAE,KAAK;QAChB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;IAEF,IAAI,SAAS,GAA0B,IAAI,CAAC;IAC5C,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,OAAO;QACL,KAAK,CAAC,OAAO;YACX,oBAAoB;YACpB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACtD,CAAC;YAED,kBAAkB;YAClB,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,QAAQ,SAAS,EAAE;oBACxD,MAAM,EAAE,KAAK;oBACb,OAAO,EAAE;wBACP,cAAc,EAAE,kBAAkB;wBAClC,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI;4BACtB,aAAa,EAAE,UAAU,MAAM,CAAC,SAAS,EAAE;yBAC5C,CAAC;qBACH;iBACF,CAAC,CAAC;gBAEH,IAAI,CAAC,QAAQ,CAAC,EAAE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E,CAAC,CAAC;gBACjE,CAAC;gBAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAyB,CAAC;YACtD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACzF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,SAAS;YACP,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,UAA8C,EAAE,KAAK,EAAE,SAAS,EAAE;IAElE,MAAM,MAAM,GAAqB;QAC/B,QAAQ;QACR,GAAG,OAAO;KACX,CAAC;IAEF,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Praxis Cloud
|
|
3
|
+
*
|
|
4
|
+
* Cloud relay and synchronization for Praxis applications.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { connectRelay } from "@plures/praxis/cloud";
|
|
9
|
+
*
|
|
10
|
+
* const relay = await connectRelay("https://my-app.azurewebsites.net", {
|
|
11
|
+
* appId: "my-app",
|
|
12
|
+
* authToken: "github-token",
|
|
13
|
+
* autoSync: true
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Sync data
|
|
17
|
+
* await relay.sync({
|
|
18
|
+
* type: "delta",
|
|
19
|
+
* appId: "my-app",
|
|
20
|
+
* clock: {},
|
|
21
|
+
* facts: [...],
|
|
22
|
+
* timestamp: Date.now()
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Get usage metrics
|
|
26
|
+
* const usage = await relay.getUsage();
|
|
27
|
+
* console.log(`Syncs: ${usage.syncCount}, Events: ${usage.eventCount}`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export { createCloudRelay, connectRelay } from "./client.js";
|
|
31
|
+
export type { CloudRelayConfig, CloudRelayClient, RelayStatus, CRDTSyncMessage, UsageMetrics, HealthCheckResponse, GitHubUser, AuthResult, } from "./types.js";
|
|
32
|
+
export { GitHubOAuth, createGitHubOAuth, authenticateWithDeviceFlow, } from "./auth.js";
|
|
33
|
+
export type { GitHubOAuthConfig } from "./auth.js";
|
|
34
|
+
export { SubscriptionTier, BillingProvider, SubscriptionStatus, TIER_LIMITS, hasAccessToTier, checkUsageLimits, createFreeSubscription, createSponsorSubscription, } from "./billing.js";
|
|
35
|
+
export type { TierLimits, Subscription, BillingEvent, } from "./billing.js";
|
|
36
|
+
export { GitHubSponsorsClient, createSponsorsClient, } from "./sponsors.js";
|
|
37
|
+
export type { SponsorTier, Sponsorship, } from "./sponsors.js";
|
|
38
|
+
export { GitHubMarketplaceClient, createMarketplaceClient, MARKETPLACE_PLANS, } from "./marketplace.js";
|
|
39
|
+
export type { MarketplacePlan, MarketplaceAccount, MarketplaceWebhookEvent, } from "./marketplace.js";
|
|
40
|
+
export { generateStorageNamespace, generateTenantId, createTenant, validateStorageNamespace, getAppStorageContainer, provisionTenant, getOrCreateTenant, } from "./provisioning.js";
|
|
41
|
+
export type { Tenant, ProvisioningResult, } from "./provisioning.js";
|
|
42
|
+
export { healthEndpoint, syncEndpoint, usageEndpoint, statsEndpoint, eventsEndpoint, schemaEndpoint, } from "./relay/endpoints.js";
|
|
43
|
+
export type { AzureContext, AzureHttpRequest, AzureHttpResponse, } from "./relay/endpoints.js";
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG7D,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,WAAW,GACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,MAAM,EACN,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Praxis Cloud
|
|
3
|
+
*
|
|
4
|
+
* Cloud relay and synchronization for Praxis applications.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { connectRelay } from "@plures/praxis/cloud";
|
|
9
|
+
*
|
|
10
|
+
* const relay = await connectRelay("https://my-app.azurewebsites.net", {
|
|
11
|
+
* appId: "my-app",
|
|
12
|
+
* authToken: "github-token",
|
|
13
|
+
* autoSync: true
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Sync data
|
|
17
|
+
* await relay.sync({
|
|
18
|
+
* type: "delta",
|
|
19
|
+
* appId: "my-app",
|
|
20
|
+
* clock: {},
|
|
21
|
+
* facts: [...],
|
|
22
|
+
* timestamp: Date.now()
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // Get usage metrics
|
|
26
|
+
* const usage = await relay.getUsage();
|
|
27
|
+
* console.log(`Syncs: ${usage.syncCount}, Events: ${usage.eventCount}`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
// Client
|
|
31
|
+
export { createCloudRelay, connectRelay } from "./client.js";
|
|
32
|
+
// Authentication
|
|
33
|
+
export { GitHubOAuth, createGitHubOAuth, authenticateWithDeviceFlow, } from "./auth.js";
|
|
34
|
+
// Billing and Subscriptions
|
|
35
|
+
export { SubscriptionTier, BillingProvider, SubscriptionStatus, TIER_LIMITS, hasAccessToTier, checkUsageLimits, createFreeSubscription, createSponsorSubscription, } from "./billing.js";
|
|
36
|
+
// GitHub Sponsors
|
|
37
|
+
export { GitHubSponsorsClient, createSponsorsClient, } from "./sponsors.js";
|
|
38
|
+
// GitHub Marketplace
|
|
39
|
+
export { GitHubMarketplaceClient, createMarketplaceClient, MARKETPLACE_PLANS, } from "./marketplace.js";
|
|
40
|
+
// Auto-Provisioning
|
|
41
|
+
export { generateStorageNamespace, generateTenantId, createTenant, validateStorageNamespace, getAppStorageContainer, provisionTenant, getOrCreateTenant, } from "./provisioning.js";
|
|
42
|
+
// Relay endpoints (for Azure Functions deployment)
|
|
43
|
+
export { healthEndpoint, syncEndpoint, usageEndpoint, statsEndpoint, eventsEndpoint, schemaEndpoint, } from "./relay/endpoints.js";
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cloud/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,SAAS;AACT,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAc7D,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,WAAW,CAAC;AAGnB,4BAA4B;AAC5B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAOtB,kBAAkB;AAClB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAMvB,qBAAqB;AACrB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAO1B,oBAAoB;AACpB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAM3B,mDAAmD;AACnD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Marketplace API Client
|
|
3
|
+
*
|
|
4
|
+
* Client for GitHub Marketplace SaaS integration (preparatory).
|
|
5
|
+
*/
|
|
6
|
+
import type { Subscription } from "./billing.js";
|
|
7
|
+
/**
|
|
8
|
+
* GitHub Marketplace plan
|
|
9
|
+
*/
|
|
10
|
+
export interface MarketplacePlan {
|
|
11
|
+
/**
|
|
12
|
+
* Plan ID
|
|
13
|
+
*/
|
|
14
|
+
id: number;
|
|
15
|
+
/**
|
|
16
|
+
* Plan name
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
/**
|
|
20
|
+
* Plan description
|
|
21
|
+
*/
|
|
22
|
+
description: string;
|
|
23
|
+
/**
|
|
24
|
+
* Monthly price in cents
|
|
25
|
+
*/
|
|
26
|
+
monthlyPriceInCents: number;
|
|
27
|
+
/**
|
|
28
|
+
* Yearly price in cents
|
|
29
|
+
*/
|
|
30
|
+
yearlyPriceInCents: number;
|
|
31
|
+
/**
|
|
32
|
+
* Price model
|
|
33
|
+
*/
|
|
34
|
+
priceModel: "FLAT_RATE" | "PER_UNIT";
|
|
35
|
+
/**
|
|
36
|
+
* Whether this plan has a free trial
|
|
37
|
+
*/
|
|
38
|
+
hasFreeTrial: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Unit name (for per-unit pricing)
|
|
41
|
+
*/
|
|
42
|
+
unitName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Bullets (features list)
|
|
45
|
+
*/
|
|
46
|
+
bullets: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Marketplace account
|
|
50
|
+
*/
|
|
51
|
+
export interface MarketplaceAccount {
|
|
52
|
+
/**
|
|
53
|
+
* Account ID
|
|
54
|
+
*/
|
|
55
|
+
id: number;
|
|
56
|
+
/**
|
|
57
|
+
* Account login
|
|
58
|
+
*/
|
|
59
|
+
login: string;
|
|
60
|
+
/**
|
|
61
|
+
* Account type
|
|
62
|
+
*/
|
|
63
|
+
type: "User" | "Organization";
|
|
64
|
+
/**
|
|
65
|
+
* Plan
|
|
66
|
+
*/
|
|
67
|
+
plan: MarketplacePlan;
|
|
68
|
+
/**
|
|
69
|
+
* Whether account is on free trial
|
|
70
|
+
*/
|
|
71
|
+
onFreeTrial: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Free trial ends on (if applicable)
|
|
74
|
+
*/
|
|
75
|
+
freeTrialEndsOn?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Next billing date
|
|
78
|
+
*/
|
|
79
|
+
nextBillingDate?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Marketplace webhook event
|
|
83
|
+
*/
|
|
84
|
+
export interface MarketplaceWebhookEvent {
|
|
85
|
+
/**
|
|
86
|
+
* Action type
|
|
87
|
+
*/
|
|
88
|
+
action: "purchased" | "cancelled" | "changed" | "pending_change" | "pending_change_cancelled";
|
|
89
|
+
/**
|
|
90
|
+
* Effective date
|
|
91
|
+
*/
|
|
92
|
+
effectiveDate?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Marketplace purchase
|
|
95
|
+
*/
|
|
96
|
+
marketplacePurchase: {
|
|
97
|
+
account: MarketplaceAccount;
|
|
98
|
+
billingCycle: "monthly" | "yearly";
|
|
99
|
+
unitCount?: number;
|
|
100
|
+
onFreeTrial: boolean;
|
|
101
|
+
freeTrialEndsOn?: string;
|
|
102
|
+
nextBillingDate?: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Previous plan (for changes)
|
|
106
|
+
*/
|
|
107
|
+
previousMarketplacePurchase?: {
|
|
108
|
+
account: MarketplaceAccount;
|
|
109
|
+
billingCycle: "monthly" | "yearly";
|
|
110
|
+
unitCount?: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Praxis Cloud Marketplace plans configuration
|
|
115
|
+
*/
|
|
116
|
+
export declare const MARKETPLACE_PLANS: {
|
|
117
|
+
solo: {
|
|
118
|
+
name: string;
|
|
119
|
+
description: string;
|
|
120
|
+
monthlyPriceInCents: number;
|
|
121
|
+
yearlyPriceInCents: number;
|
|
122
|
+
features: string[];
|
|
123
|
+
};
|
|
124
|
+
team: {
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
monthlyPriceInCents: number;
|
|
128
|
+
yearlyPriceInCents: number;
|
|
129
|
+
features: string[];
|
|
130
|
+
};
|
|
131
|
+
enterprise: {
|
|
132
|
+
name: string;
|
|
133
|
+
description: string;
|
|
134
|
+
monthlyPriceInCents: number;
|
|
135
|
+
yearlyPriceInCents: number;
|
|
136
|
+
features: string[];
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* GitHub Marketplace API client
|
|
141
|
+
*/
|
|
142
|
+
export declare class GitHubMarketplaceClient {
|
|
143
|
+
private token;
|
|
144
|
+
constructor(token: string);
|
|
145
|
+
/**
|
|
146
|
+
* Get accounts for the authenticated user
|
|
147
|
+
*/
|
|
148
|
+
getAccounts(): Promise<MarketplaceAccount[]>;
|
|
149
|
+
/**
|
|
150
|
+
* Get subscription from marketplace account
|
|
151
|
+
*/
|
|
152
|
+
getSubscription(accountId: number): Promise<Subscription | null>;
|
|
153
|
+
/**
|
|
154
|
+
* Handle marketplace webhook event
|
|
155
|
+
*/
|
|
156
|
+
handleWebhookEvent(event: MarketplaceWebhookEvent): {
|
|
157
|
+
userId: number;
|
|
158
|
+
userLogin: string;
|
|
159
|
+
subscription: Subscription;
|
|
160
|
+
} | null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create a GitHub Marketplace client
|
|
164
|
+
*/
|
|
165
|
+
export declare function createMarketplaceClient(token: string): GitHubMarketplaceClient;
|
|
166
|
+
//# sourceMappingURL=marketplace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../../src/cloud/marketplace.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M,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IAEF;;OAEG;IACH,2BAA2B,CAAC,EAAE;QAC5B,OAAO,EAAE,kBAAkB,CAAC;QAC5B,YAAY,EAAE,SAAS,GAAG,QAAQ,CAAC;QACnC,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;CAwC7B,CAAC;AAEF;;GAEG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,KAAK,CAAS;gBAEV,KAAK,EAAE,MAAM;IAIzB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAuBlD;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAkCtE;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG;QAClD,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,YAAY,CAAC;KAC5B,GAAG,IAAI;CAmCT;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,uBAAuB,CAE9E"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub Marketplace API Client
|
|
3
|
+
*
|
|
4
|
+
* Client for GitHub Marketplace SaaS integration (preparatory).
|
|
5
|
+
*/
|
|
6
|
+
import { SubscriptionTier, SubscriptionStatus, BillingProvider, TIER_LIMITS } from "./billing.js";
|
|
7
|
+
/**
|
|
8
|
+
* Praxis Cloud Marketplace plans configuration
|
|
9
|
+
*/
|
|
10
|
+
export const MARKETPLACE_PLANS = {
|
|
11
|
+
solo: {
|
|
12
|
+
name: "Praxis Cloud Solo",
|
|
13
|
+
description: "For individual developers",
|
|
14
|
+
monthlyPriceInCents: 500, // $5/month
|
|
15
|
+
yearlyPriceInCents: 5000, // $50/year (2 months free)
|
|
16
|
+
features: [
|
|
17
|
+
"50,000 syncs/month",
|
|
18
|
+
"1 GB storage",
|
|
19
|
+
"10 apps/projects",
|
|
20
|
+
"Standard support",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
team: {
|
|
24
|
+
name: "Praxis Cloud Team",
|
|
25
|
+
description: "For small teams",
|
|
26
|
+
monthlyPriceInCents: 2000, // $20/month
|
|
27
|
+
yearlyPriceInCents: 20000, // $200/year (2 months free)
|
|
28
|
+
features: [
|
|
29
|
+
"500,000 syncs/month",
|
|
30
|
+
"10 GB storage",
|
|
31
|
+
"50 apps/projects",
|
|
32
|
+
"Up to 10 team members",
|
|
33
|
+
"Standard support",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
enterprise: {
|
|
37
|
+
name: "Praxis Cloud Enterprise",
|
|
38
|
+
description: "For large teams and organizations",
|
|
39
|
+
monthlyPriceInCents: 5000, // $50/month
|
|
40
|
+
yearlyPriceInCents: 50000, // $500/year (2 months free)
|
|
41
|
+
features: [
|
|
42
|
+
"5,000,000 syncs/month",
|
|
43
|
+
"100 GB storage",
|
|
44
|
+
"1,000 apps/projects",
|
|
45
|
+
"Unlimited team members",
|
|
46
|
+
"Priority support",
|
|
47
|
+
"SLA guarantees",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* GitHub Marketplace API client
|
|
53
|
+
*/
|
|
54
|
+
export class GitHubMarketplaceClient {
|
|
55
|
+
token;
|
|
56
|
+
constructor(token) {
|
|
57
|
+
this.token = token;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get accounts for the authenticated user
|
|
61
|
+
*/
|
|
62
|
+
async getAccounts() {
|
|
63
|
+
try {
|
|
64
|
+
const response = await fetch("https://api.github.com/marketplace_listing/accounts", {
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: `Bearer ${this.token}`,
|
|
67
|
+
Accept: "application/vnd.github.v3+json",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
throw new Error(`GitHub API error: ${response.statusText}`);
|
|
72
|
+
}
|
|
73
|
+
return await response.json();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error("Failed to get marketplace accounts:", error);
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get subscription from marketplace account
|
|
82
|
+
*/
|
|
83
|
+
async getSubscription(accountId) {
|
|
84
|
+
const accounts = await this.getAccounts();
|
|
85
|
+
const account = accounts.find((a) => a.id === accountId);
|
|
86
|
+
if (!account) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
// Map plan to tier
|
|
90
|
+
let tier = SubscriptionTier.FREE;
|
|
91
|
+
if (account.plan.monthlyPriceInCents >= 5000) {
|
|
92
|
+
tier = SubscriptionTier.ENTERPRISE;
|
|
93
|
+
}
|
|
94
|
+
else if (account.plan.monthlyPriceInCents >= 2000) {
|
|
95
|
+
tier = SubscriptionTier.TEAM;
|
|
96
|
+
}
|
|
97
|
+
else if (account.plan.monthlyPriceInCents >= 500) {
|
|
98
|
+
tier = SubscriptionTier.SOLO;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
tier,
|
|
102
|
+
status: SubscriptionStatus.ACTIVE,
|
|
103
|
+
provider: BillingProvider.MARKETPLACE,
|
|
104
|
+
marketplacePlanId: account.plan.id,
|
|
105
|
+
startDate: account.onFreeTrial && account.freeTrialEndsOn
|
|
106
|
+
? new Date(account.freeTrialEndsOn).getTime()
|
|
107
|
+
: Date.now(),
|
|
108
|
+
periodEnd: account.nextBillingDate
|
|
109
|
+
? new Date(account.nextBillingDate).getTime()
|
|
110
|
+
: undefined,
|
|
111
|
+
autoRenew: true,
|
|
112
|
+
limits: TIER_LIMITS[tier],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Handle marketplace webhook event
|
|
117
|
+
*/
|
|
118
|
+
handleWebhookEvent(event) {
|
|
119
|
+
const account = event.marketplacePurchase.account;
|
|
120
|
+
if (event.action === "cancelled") {
|
|
121
|
+
// Handle cancellation
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
// Map plan to tier
|
|
125
|
+
let tier = SubscriptionTier.FREE;
|
|
126
|
+
if (account.plan.monthlyPriceInCents >= 5000) {
|
|
127
|
+
tier = SubscriptionTier.ENTERPRISE;
|
|
128
|
+
}
|
|
129
|
+
else if (account.plan.monthlyPriceInCents >= 2000) {
|
|
130
|
+
tier = SubscriptionTier.TEAM;
|
|
131
|
+
}
|
|
132
|
+
else if (account.plan.monthlyPriceInCents >= 500) {
|
|
133
|
+
tier = SubscriptionTier.SOLO;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
userId: account.id,
|
|
137
|
+
userLogin: account.login,
|
|
138
|
+
subscription: {
|
|
139
|
+
tier,
|
|
140
|
+
status: SubscriptionStatus.ACTIVE,
|
|
141
|
+
provider: BillingProvider.MARKETPLACE,
|
|
142
|
+
marketplacePlanId: account.plan.id,
|
|
143
|
+
startDate: Date.now(),
|
|
144
|
+
periodEnd: event.marketplacePurchase.nextBillingDate
|
|
145
|
+
? new Date(event.marketplacePurchase.nextBillingDate).getTime()
|
|
146
|
+
: undefined,
|
|
147
|
+
autoRenew: true,
|
|
148
|
+
limits: TIER_LIMITS[tier],
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Create a GitHub Marketplace client
|
|
155
|
+
*/
|
|
156
|
+
export function createMarketplaceClient(token) {
|
|
157
|
+
return new GitHubMarketplaceClient(token);
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=marketplace.js.map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