anhedral 0.15.0 → 0.16.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/README.md +29 -38
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/UPSTREAM.json +7 -1
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +2 -1
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +16 -5
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +14 -74
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +2 -1
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -66
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +39 -322
- package/dist/dependencies.d.ts +29 -6
- package/dist/dependencies.js +61 -14
- package/dist/index.d.ts +1 -42
- package/dist/index.js +1 -27
- package/dist/platforms/mobile.js +1 -20
- package/dist/platforms/web.d.ts +1 -1
- package/dist/platforms/web.js +27 -75
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -82
- package/dist/registry/options.js +1 -5
- package/dist/registry/resolve.d.ts +1 -1
- package/dist/registry/resolve.js +2 -10
- package/dist/registry/usage.js +3 -9
- package/dist/scaffold/backend.js +0 -3
- package/dist/scaffold/database.js +2 -1
- package/dist/scaffold/documentation.js +82 -20
- package/dist/scaffold/expo-runtime.js +3 -4
- package/dist/scaffold/native-ui.js +12 -7
- package/dist/scaffold/stack-documentation.js +1 -1
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/workspace.js +26 -21
- package/dist/stack-registry.d.ts +2 -8
- package/dist/stack-registry.js +11 -87
- package/dist/standard.js +1 -11
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -20
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -44
- package/docs/stack-standard.md +11 -60
- package/docs/ui.md +33 -0
- package/docs/verification.md +191 -0
- package/package.json +19 -18
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -129
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -112
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -157
- package/dist/delivery.d.ts +0 -82
- package/dist/delivery.js +0 -489
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -12
- package/dist/integration-service-readers.js +0 -92
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -370
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -671
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -47
- package/dist/project-state.js +0 -480
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -180
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -85
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -103
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -136
- package/dist/providers/definitions.d.ts +0 -115
- package/dist/providers/definitions.js +0 -42
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -56
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -52
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -234
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -283
- package/dist/provision.d.ts +0 -47
- package/dist/provision.js +0 -208
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -117
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -210
- package/dist/registry/bootstrap.d.ts +0 -3
- package/dist/registry/bootstrap.js +0 -5
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -83
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -2
- package/dist/scaffold/auth.js +0 -76
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -208
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -203
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -257
- package/dist/scaffold/integrations.d.ts +0 -2
- package/dist/scaffold/integrations.js +0 -11
- package/dist/scaffold/managed-email.d.ts +0 -3
- package/dist/scaffold/managed-email.js +0 -47
- package/dist/scaffold/password-reset.d.ts +0 -1
- package/dist/scaffold/password-reset.js +0 -99
- package/dist/scaffold/private-files.d.ts +0 -2
- package/dist/scaffold/private-files.js +0 -78
- package/dist/scaffold/web-billing.d.ts +0 -2
- package/dist/scaffold/web-billing.js +0 -48
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -71
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -48
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -216
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -96
- package/dist/ship.d.ts +0 -35
- package/dist/ship.js +0 -107
- package/docs/assets/anhedral-stack-light.png +0 -0
- package/docs/assets/anhedral-stack.png +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type ApiObject } from './api.js';
|
|
2
|
-
import type { IntegrationProvider } from './config.js';
|
|
3
|
-
export type CredentialField = 'token' | 'secret' | 'api_key';
|
|
4
|
-
export type OperationCredentials = Partial<Record<CredentialField, string>>;
|
|
5
|
-
export interface MinimalReceipt {
|
|
6
|
-
id?: string | number;
|
|
7
|
-
application_id?: string | number;
|
|
8
|
-
project?: {
|
|
9
|
-
id: string | number;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
/** Keep only identities required for adapter retries and separately retain supported
|
|
13
|
-
* one-time credentials. Provider responses often include unrelated secrets or metadata. */
|
|
14
|
-
export declare function splitReceipt(id: IntegrationProvider, value: unknown): {
|
|
15
|
-
receipt: MinimalReceipt;
|
|
16
|
-
credentials: Partial<Record<CredentialField, string>>;
|
|
17
|
-
};
|
|
18
|
-
export declare function validReceipt(id: IntegrationProvider, value: unknown): value is MinimalReceipt;
|
|
19
|
-
export declare function validCredentials(id: IntegrationProvider, value: unknown): value is OperationCredentials;
|
|
20
|
-
export declare function restoreReceipt(receipt: MinimalReceipt, credentials: OperationCredentials): ApiObject;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { object, resourceId, text } from './api.js';
|
|
2
|
-
const allowedCredentials = {
|
|
3
|
-
stripe: 'secret',
|
|
4
|
-
};
|
|
5
|
-
function identity(value) {
|
|
6
|
-
resourceId(value);
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
/** Keep only identities required for adapter retries and separately retain supported
|
|
10
|
-
* one-time credentials. Provider responses often include unrelated secrets or metadata. */
|
|
11
|
-
export function splitReceipt(id, value) {
|
|
12
|
-
const response = object(value);
|
|
13
|
-
const receipt = {};
|
|
14
|
-
if (Object.hasOwn(response, 'id'))
|
|
15
|
-
receipt.id = identity(response.id);
|
|
16
|
-
if (!Object.keys(receipt).length)
|
|
17
|
-
throw new Error('Provider returned no creation identity.');
|
|
18
|
-
const credentials = {};
|
|
19
|
-
const field = allowedCredentials[id];
|
|
20
|
-
if (field && Object.hasOwn(response, field))
|
|
21
|
-
credentials[field] = text(field === 'api_key' ? object(response.api_key).value : response[field]);
|
|
22
|
-
return { receipt, credentials };
|
|
23
|
-
}
|
|
24
|
-
export function validReceipt(id, value) {
|
|
25
|
-
try {
|
|
26
|
-
const response = object(value);
|
|
27
|
-
const allowed = ['id'];
|
|
28
|
-
if (Object.keys(response).some((key) => !allowed.includes(key)))
|
|
29
|
-
return false;
|
|
30
|
-
if (response.project && Object.keys(object(response.project)).some((key) => key !== 'id'))
|
|
31
|
-
return false;
|
|
32
|
-
splitReceipt(id, response);
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export function validCredentials(id, value) {
|
|
40
|
-
try {
|
|
41
|
-
const credentials = object(value);
|
|
42
|
-
const allowed = allowedCredentials[id];
|
|
43
|
-
return Object.entries(credentials).every(([field, value]) => field === allowed && text(value) === value);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export function restoreReceipt(receipt, credentials) {
|
|
50
|
-
return {
|
|
51
|
-
...receipt,
|
|
52
|
-
...(credentials.token ? { token: credentials.token } : {}),
|
|
53
|
-
...(credentials.secret ? { secret: credentials.secret } : {}),
|
|
54
|
-
...(credentials.api_key ? { api_key: { value: credentials.api_key } } : {}),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ApiRequest } from './api.js';
|
|
2
|
-
import { type IntegrationProvider, type ProviderSettings } from './config.js';
|
|
3
|
-
import type { OperationDescriptor } from './state.js';
|
|
4
|
-
import type { MinimalReceipt } from './receipts.js';
|
|
5
|
-
/** Only verified identities may finish a pending journal operation. Every request is
|
|
6
|
-
* GET; key creation cannot be recovered by inventing a one-time credential. */
|
|
7
|
-
export declare function verifyRecoveredResource(provider: IntegrationProvider, descriptor: OperationDescriptor, requested: string, settings: ProviderSettings, api: ApiRequest): Promise<MinimalReceipt>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { object, resourceId } from './api.js';
|
|
2
|
-
import { setting } from './config.js';
|
|
3
|
-
function same(actual, expected, label) {
|
|
4
|
-
if (!expected || actual !== expected)
|
|
5
|
-
throw new Error(`Recovered provider ${label} does not match the desired configuration.`);
|
|
6
|
-
}
|
|
7
|
-
function route(descriptor, key, expected) {
|
|
8
|
-
if (descriptor.key !== key || descriptor.route !== expected)
|
|
9
|
-
throw new Error('Pending provider operation does not match the supported recovery route.');
|
|
10
|
-
}
|
|
11
|
-
/** Only verified identities may finish a pending journal operation. Every request is
|
|
12
|
-
* GET; key creation cannot be recovered by inventing a one-time credential. */
|
|
13
|
-
export async function verifyRecoveredResource(provider, descriptor, requested, settings, api) {
|
|
14
|
-
const id = resourceId(requested);
|
|
15
|
-
if (['sending-key', 'webhook', 'service-account'].includes(descriptor.key))
|
|
16
|
-
throw new Error('This operation creates a one-time credential. Restore its securely retained credential and verify it with the provider; resource-only recovery is unavailable.');
|
|
17
|
-
if (provider === 'revenuecat') {
|
|
18
|
-
if (descriptor.key === 'project') {
|
|
19
|
-
route(descriptor, 'project', '/v2/projects');
|
|
20
|
-
const project = object(await api(`/v2/projects/${id}`));
|
|
21
|
-
same(project.id, id, 'RevenueCat project identity');
|
|
22
|
-
same(project.name, setting(settings, 'name'), 'RevenueCat project name');
|
|
23
|
-
return { id };
|
|
24
|
-
}
|
|
25
|
-
// Recovery of an app requires an explicit parent project choice. Never infer
|
|
26
|
-
// that parent from whichever project the current credential most recently used.
|
|
27
|
-
const project = resourceId(setting(settings, 'projectId'));
|
|
28
|
-
if (!['ios-app', 'android-app', 'web-app'].includes(descriptor.key))
|
|
29
|
-
throw new Error('Unsupported RevenueCat recovery operation.');
|
|
30
|
-
route(descriptor, descriptor.key, `/v2/projects/${project}/apps`);
|
|
31
|
-
const app = object(await api(`/v2/projects/${project}/apps/${id}`));
|
|
32
|
-
same(app.id, id, 'RevenueCat app identity');
|
|
33
|
-
const type = descriptor.key === 'ios-app'
|
|
34
|
-
? 'app_store'
|
|
35
|
-
: descriptor.key === 'android-app'
|
|
36
|
-
? 'play_store'
|
|
37
|
-
: 'stripe';
|
|
38
|
-
same(app.type, type, 'RevenueCat app platform');
|
|
39
|
-
const field = type === 'app_store'
|
|
40
|
-
? 'bundle_id'
|
|
41
|
-
: type === 'play_store'
|
|
42
|
-
? 'package_name'
|
|
43
|
-
: 'stripe_account_id';
|
|
44
|
-
same(object(app[type])[field], setting(settings, type === 'app_store'
|
|
45
|
-
? 'bundleId'
|
|
46
|
-
: type === 'play_store'
|
|
47
|
-
? 'packageName'
|
|
48
|
-
: 'stripeAccountId'), 'RevenueCat app identifier');
|
|
49
|
-
return { id };
|
|
50
|
-
}
|
|
51
|
-
throw new Error('Resource-only recovery is unsupported for this provider operation.');
|
|
52
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type DeliveryRunner } from '../project-state.js';
|
|
2
|
-
import { type IntegrationProvider } from './config.js';
|
|
3
|
-
export declare function integrationStatus(root: string): {
|
|
4
|
-
mutation: boolean;
|
|
5
|
-
schemaVersion: number;
|
|
6
|
-
providers: {
|
|
7
|
-
provider: string;
|
|
8
|
-
operations: {
|
|
9
|
-
descriptor: import("./state.js").OperationDescriptor;
|
|
10
|
-
recovery: string;
|
|
11
|
-
resources?: import("./receipts.js").MinimalReceipt | undefined;
|
|
12
|
-
operation: string;
|
|
13
|
-
status: "pending" | "complete";
|
|
14
|
-
}[];
|
|
15
|
-
}[];
|
|
16
|
-
};
|
|
17
|
-
export interface IntegrationRecoveryRequest {
|
|
18
|
-
provider: IntegrationProvider;
|
|
19
|
-
operation: string;
|
|
20
|
-
resourceId: string;
|
|
21
|
-
}
|
|
22
|
-
/** Explicitly reconcile a verified resource; never recreate or delete it. Local
|
|
23
|
-
* receipt writes are authorized by this action, provider calls remain read-only. */
|
|
24
|
-
export declare function recoverIntegrationResource(root: string, request: IntegrationRecoveryRequest, run?: DeliveryRunner, send?: typeof fetch, environment?: NodeJS.ProcessEnv): Promise<{
|
|
25
|
-
provider: keyof import("./definitions.js").ProviderSettingsById;
|
|
26
|
-
operation: string;
|
|
27
|
-
status: string;
|
|
28
|
-
resources: import("./receipts.js").MinimalReceipt;
|
|
29
|
-
mutation: string;
|
|
30
|
-
}>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
-
import { defaultRunner, withApplicationLock } from '../project-state.js';
|
|
4
|
-
import { providerApi, resourceId, digest } from './api.js';
|
|
5
|
-
import { providerConfiguration, selectedIntegrations, INTEGRATION_PROVIDERS, } from './config.js';
|
|
6
|
-
import { privateStateDirectory, ProvisioningState, readProviderStateStatus } from './state.js';
|
|
7
|
-
export function integrationStatus(root) {
|
|
8
|
-
root = realpathSync(root);
|
|
9
|
-
return { ...readProviderStateStatus(path.join(root, '.anhedral')), mutation: false };
|
|
10
|
-
}
|
|
11
|
-
/** Explicitly reconcile a verified resource; never recreate or delete it. Local
|
|
12
|
-
* receipt writes are authorized by this action, provider calls remain read-only. */
|
|
13
|
-
export async function recoverIntegrationResource(root, request, run = defaultRunner, send = fetch, environment = process.env) {
|
|
14
|
-
root = realpathSync(root);
|
|
15
|
-
if (!INTEGRATION_PROVIDERS.includes(request.provider) ||
|
|
16
|
-
!/^[a-f0-9]{64}$/.test(request.operation))
|
|
17
|
-
throw new Error('Select a supported provider and an exact pending operation hash.');
|
|
18
|
-
const id = resourceId(request.resourceId);
|
|
19
|
-
if (!selectedIntegrations(root).includes(request.provider))
|
|
20
|
-
throw new Error('Recovery requires a selected provider.');
|
|
21
|
-
const configuration = providerConfiguration(root);
|
|
22
|
-
const settings = configuration.providers[request.provider] ?? {};
|
|
23
|
-
const fingerprint = digest(configuration);
|
|
24
|
-
if (!existsSync(path.join(root, '.anhedral/providers.json')))
|
|
25
|
-
throw new Error('There is no pending provider journal to reconcile.');
|
|
26
|
-
const directory = await privateStateDirectory(root, run);
|
|
27
|
-
return withApplicationLock(root, async () => {
|
|
28
|
-
const state = new ProvisioningState(directory);
|
|
29
|
-
return state.recoverResource(request.provider, request.operation, id, settings, providerApi(request.provider, settings, environment, send), () => {
|
|
30
|
-
if (digest(providerConfiguration(root)) !== fingerprint)
|
|
31
|
-
throw new Error('Provider configuration changed during recovery; no completion receipt was written.');
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type DeliveryRunner } from '../project-state.js';
|
|
2
|
-
export type RuntimeValues = Record<string, string>;
|
|
3
|
-
export declare const RUNTIME_KEYS: string[];
|
|
4
|
-
export declare function runtimeTargets(root: string, values: RuntimeValues): Record<string, RuntimeValues>;
|
|
5
|
-
/** Preflight every destination before writing any file; preserve unrelated configuration verbatim. */
|
|
6
|
-
export declare function configureRuntime(root: string, values: RuntimeValues, run: DeliveryRunner): Promise<string[]>;
|
|
7
|
-
export declare function configuredRuntime(root: string): RuntimeValues;
|
|
8
|
-
/** Read application-owned credentials separately from integration receipts. Never write,
|
|
9
|
-
* return unrelated environment keys, or copy server secrets to other targets. */
|
|
10
|
-
export declare function applicationRuntime(root: string, run: DeliveryRunner): Promise<Record<string, RuntimeValues>>;
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import { existsSync, lstatSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from '../bounded-file.js';
|
|
5
|
-
import { readProjectSection } from '../project-config.js';
|
|
6
|
-
import { atomicJson, readConfig } from '../project-state.js';
|
|
7
|
-
import { digest } from './api.js';
|
|
8
|
-
import { validateSetupPlan } from '../readiness.js';
|
|
9
|
-
import { isIP } from 'node:net';
|
|
10
|
-
import { providerConfiguration } from './config.js';
|
|
11
|
-
function serverRuntimeFile(_root, runtime, _hosting) {
|
|
12
|
-
const directory = `apps/${runtime}`;
|
|
13
|
-
return `${directory}/.dev.vars`;
|
|
14
|
-
}
|
|
15
|
-
export const RUNTIME_KEYS = [
|
|
16
|
-
'BETTER_AUTH_SECRET',
|
|
17
|
-
'BETTER_AUTH_URL',
|
|
18
|
-
'STRIPE_SECRET_KEY',
|
|
19
|
-
'STRIPE_WEBHOOK_SECRET',
|
|
20
|
-
'BILLING_ORIGIN',
|
|
21
|
-
'BILLING_ENVIRONMENT',
|
|
22
|
-
'BILLING_PLANS_JSON',
|
|
23
|
-
'BILLING_ENTITLEMENTS_JSON',
|
|
24
|
-
'BILLING_PREMIUM_ENTITLEMENT',
|
|
25
|
-
'REVENUECAT_SECRET_KEY',
|
|
26
|
-
'REVENUECAT_WEBHOOK_AUTHORIZATION',
|
|
27
|
-
'REVENUECAT_WEBHOOK_SIGNING_SECRET',
|
|
28
|
-
'REVENUECAT_APP_IDS_JSON',
|
|
29
|
-
'REVENUECAT_PROJECT_ID',
|
|
30
|
-
'EXPO_PUBLIC_API_URL',
|
|
31
|
-
'EXPO_PUBLIC_REVENUECAT_IOS_API_KEY',
|
|
32
|
-
'EXPO_PUBLIC_REVENUECAT_ANDROID_API_KEY',
|
|
33
|
-
];
|
|
34
|
-
function validateValues(values) {
|
|
35
|
-
if (!values ||
|
|
36
|
-
typeof values !== 'object' ||
|
|
37
|
-
Array.isArray(values) ||
|
|
38
|
-
Object.entries(values).some(([key, value]) => !RUNTIME_KEYS.includes(key) ||
|
|
39
|
-
typeof value !== 'string' ||
|
|
40
|
-
!value ||
|
|
41
|
-
value.length > 16384 ||
|
|
42
|
-
/[\r\n\x00]/.test(value)))
|
|
43
|
-
throw new Error('Invalid provider runtime configuration.');
|
|
44
|
-
}
|
|
45
|
-
export function runtimeTargets(root, values) {
|
|
46
|
-
validateValues(values);
|
|
47
|
-
const setup = readProjectSection(root, 'setup');
|
|
48
|
-
validateSetupPlan(setup);
|
|
49
|
-
const targets = {};
|
|
50
|
-
const runtime = setup.products.includes('hono') ? 'api' : 'web';
|
|
51
|
-
const server = Object.fromEntries(Object.entries(values).filter(([key]) => !key.startsWith('EXPO_PUBLIC_')));
|
|
52
|
-
if (existsSync(path.join(root, `apps/${runtime}`)))
|
|
53
|
-
targets[serverRuntimeFile(root, runtime, setup.hosting)] = server;
|
|
54
|
-
if (setup.products.includes('expo')) {
|
|
55
|
-
const mobile = Object.fromEntries(Object.entries(values).filter(([key]) => key.startsWith('EXPO_PUBLIC_')));
|
|
56
|
-
if (Object.keys(mobile).length)
|
|
57
|
-
targets['apps/mobile/.env.local'] = mobile;
|
|
58
|
-
}
|
|
59
|
-
return targets;
|
|
60
|
-
}
|
|
61
|
-
/** Preflight every destination before writing any file; preserve unrelated configuration verbatim. */
|
|
62
|
-
export async function configureRuntime(root, values, run) {
|
|
63
|
-
root = realpathSync(root);
|
|
64
|
-
const writes = [];
|
|
65
|
-
for (const [relative, entries] of Object.entries(runtimeTargets(root, values))) {
|
|
66
|
-
if (!Object.keys(entries).length)
|
|
67
|
-
continue;
|
|
68
|
-
const file = path.join(root, relative);
|
|
69
|
-
if (realpathSync(path.dirname(file)) !== path.dirname(file) ||
|
|
70
|
-
(existsSync(file) && lstatSync(file).isSymbolicLink()))
|
|
71
|
-
throw new Error('Runtime environment destination must not contain symbolic links.');
|
|
72
|
-
if ((await run('git', ['ls-files', '--', relative], root, process.env)).trim())
|
|
73
|
-
throw new Error('Runtime environment files must not be tracked.');
|
|
74
|
-
if ((await run('git', ['check-ignore', '--no-index', '--', relative], root, process.env)).trim() !== relative)
|
|
75
|
-
throw new Error('Ignore runtime environment files before provisioning.');
|
|
76
|
-
let content = existsSync(file)
|
|
77
|
-
? readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8')
|
|
78
|
-
: '';
|
|
79
|
-
for (const [key, value] of Object.entries(entries)) {
|
|
80
|
-
const existing = content
|
|
81
|
-
.split(/\r?\n/)
|
|
82
|
-
.filter((line) => new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`).test(line));
|
|
83
|
-
if (existing.length > 1)
|
|
84
|
-
throw new Error(`Duplicate runtime value for ${key}; reconcile before configuring.`);
|
|
85
|
-
if (existing.length) {
|
|
86
|
-
let previous = existing[0].slice(existing[0].indexOf('=') + 1).trim();
|
|
87
|
-
if (previous.startsWith('"')) {
|
|
88
|
-
try {
|
|
89
|
-
previous = JSON.parse(previous);
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
/* Conflicting formats require review. */
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else if (previous.startsWith("'") && previous.endsWith("'"))
|
|
96
|
-
previous = previous.slice(1, -1);
|
|
97
|
-
if (previous !== value)
|
|
98
|
-
throw new Error(`Existing runtime value for ${key} differs. Reconcile it before configuring.`);
|
|
99
|
-
}
|
|
100
|
-
else
|
|
101
|
-
content += `${content && !content.endsWith('\n') ? '\n' : ''}${key}=${JSON.stringify(value)}\n`;
|
|
102
|
-
}
|
|
103
|
-
writes.push({ file, content, relative });
|
|
104
|
-
}
|
|
105
|
-
for (const { file, content } of writes) {
|
|
106
|
-
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
107
|
-
try {
|
|
108
|
-
writeFileSync(temporary, content, { mode: 0o600, flag: 'wx' });
|
|
109
|
-
renameSync(temporary, file);
|
|
110
|
-
}
|
|
111
|
-
finally {
|
|
112
|
-
rmSync(temporary, { force: true });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
atomicJson(path.join(root, '.anhedral/runtime.json'), {
|
|
116
|
-
schemaVersion: 1,
|
|
117
|
-
configuration: digest(providerConfiguration(root)),
|
|
118
|
-
values,
|
|
119
|
-
});
|
|
120
|
-
return writes.map((write) => write.relative);
|
|
121
|
-
}
|
|
122
|
-
export function configuredRuntime(root) {
|
|
123
|
-
const file = path.join(root, '.anhedral/runtime.json');
|
|
124
|
-
if (!existsSync(file))
|
|
125
|
-
return {};
|
|
126
|
-
if (realpathSync(path.dirname(file)) !== path.join(realpathSync(root), '.anhedral'))
|
|
127
|
-
throw new Error('Runtime state directory must not be a symbolic link.');
|
|
128
|
-
if (process.platform !== 'win32' && lstatSync(file).mode & 0o077)
|
|
129
|
-
throw new Error('Runtime state permissions must be 0600.');
|
|
130
|
-
const state = JSON.parse(readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8'));
|
|
131
|
-
if (state.schemaVersion !== 1 || state.configuration !== digest(providerConfiguration(root)))
|
|
132
|
-
throw new Error('Runtime configuration does not match the selected provider configuration.');
|
|
133
|
-
validateValues(state.values);
|
|
134
|
-
return state.values;
|
|
135
|
-
}
|
|
136
|
-
function applicationValue(content, key) {
|
|
137
|
-
const matches = content
|
|
138
|
-
.split(/\r?\n/)
|
|
139
|
-
.filter((line) => new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`).test(line));
|
|
140
|
-
if (matches.length !== 1)
|
|
141
|
-
throw new Error(`Configure exactly one ${key} in the application's private runtime file.`);
|
|
142
|
-
const raw = matches[0].slice(matches[0].indexOf('=') + 1).trim();
|
|
143
|
-
let value;
|
|
144
|
-
if (raw.startsWith('"')) {
|
|
145
|
-
try {
|
|
146
|
-
value = JSON.parse(raw);
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
throw new Error(`Use a valid quoted value for ${key}.`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else if (raw.startsWith("'")) {
|
|
153
|
-
if (!raw.endsWith("'") || raw.length < 2)
|
|
154
|
-
throw new Error(`Use a valid quoted value for ${key}.`);
|
|
155
|
-
value = raw.slice(1, -1);
|
|
156
|
-
}
|
|
157
|
-
else
|
|
158
|
-
value = raw.replace(/\s+#.*$/, '').trim();
|
|
159
|
-
if (typeof value !== 'string' || !value || value.length > 16384 || /[\r\n\x00]/.test(value))
|
|
160
|
-
throw new Error(`Configure a valid ${key} in the application's private runtime file.`);
|
|
161
|
-
return value;
|
|
162
|
-
}
|
|
163
|
-
function publicAuthOrigin(value) {
|
|
164
|
-
if (/[\\\s]/.test(value))
|
|
165
|
-
return false;
|
|
166
|
-
let url;
|
|
167
|
-
try {
|
|
168
|
-
url = new URL(value);
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
const hostname = url.hostname.toLowerCase().replace(/\.$/, '');
|
|
174
|
-
// Authentication callbacks must target a public deployment, not local development.
|
|
175
|
-
return (url.protocol === 'https:' &&
|
|
176
|
-
!url.username &&
|
|
177
|
-
!url.password &&
|
|
178
|
-
!url.search &&
|
|
179
|
-
!url.hash &&
|
|
180
|
-
url.pathname === '/' &&
|
|
181
|
-
!isIP(hostname.replace(/^\[|\]$/g, '')) &&
|
|
182
|
-
hostname.includes('.') &&
|
|
183
|
-
!['localhost', 'local', 'internal', 'test', 'invalid', 'example'].some((suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`)));
|
|
184
|
-
}
|
|
185
|
-
/** Read application-owned credentials separately from integration receipts. Never write,
|
|
186
|
-
* return unrelated environment keys, or copy server secrets to other targets. */
|
|
187
|
-
export async function applicationRuntime(root, run) {
|
|
188
|
-
root = realpathSync(root);
|
|
189
|
-
const setup = readProjectSection(root, 'setup');
|
|
190
|
-
validateSetupPlan(setup);
|
|
191
|
-
const betterAuth = setup.products.includes('better-auth');
|
|
192
|
-
const keys = [...(betterAuth ? ['BETTER_AUTH_SECRET', 'BETTER_AUTH_URL'] : [])];
|
|
193
|
-
if (!keys.length)
|
|
194
|
-
return {};
|
|
195
|
-
const runtime = setup.products.includes('hono') ? 'api' : 'web';
|
|
196
|
-
const relative = serverRuntimeFile(root, runtime, setup.hosting);
|
|
197
|
-
const file = path.join(root, relative);
|
|
198
|
-
if (!existsSync(file))
|
|
199
|
-
throw new Error(`Configure ${keys.join(' and ')} in ignored ${relative} before shipping.`);
|
|
200
|
-
if (realpathSync(path.dirname(file)) !== path.dirname(file) ||
|
|
201
|
-
!lstatSync(file).isFile() ||
|
|
202
|
-
lstatSync(file).isSymbolicLink())
|
|
203
|
-
throw new Error('Application runtime files must be regular files without symbolic links.');
|
|
204
|
-
if (process.platform !== 'win32' && lstatSync(file).mode & 0o077)
|
|
205
|
-
throw new Error('Application runtime file permissions must be 0600 before shipping.');
|
|
206
|
-
if ((await run('git', ['ls-files', '--', relative], root, process.env)).trim())
|
|
207
|
-
throw new Error('Application runtime files must not be tracked.');
|
|
208
|
-
if ((await run('git', ['check-ignore', '--no-index', '--', relative], root, process.env)).trim() !==
|
|
209
|
-
relative)
|
|
210
|
-
throw new Error('Ignore application runtime files before shipping.');
|
|
211
|
-
if (!relative.endsWith('/.env.local') &&
|
|
212
|
-
(existsSync(path.join(path.dirname(file), 'wrangler.jsonc')) ||
|
|
213
|
-
existsSync(path.join(path.dirname(file), 'anhedral.cloudflare.json')))) {
|
|
214
|
-
const config = readConfig(path.dirname(file));
|
|
215
|
-
if (config.vars &&
|
|
216
|
-
typeof config.vars === 'object' &&
|
|
217
|
-
keys.some((key) => Object.hasOwn(config.vars, key)))
|
|
218
|
-
throw new Error(`Remove Better Auth values from tracked Wrangler vars, review and commit that change, then configure the private runtime file before shipping.`);
|
|
219
|
-
}
|
|
220
|
-
const content = readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8');
|
|
221
|
-
const values = {};
|
|
222
|
-
if (betterAuth) {
|
|
223
|
-
const secret = applicationValue(content, 'BETTER_AUTH_SECRET');
|
|
224
|
-
if (secret.length < 32 ||
|
|
225
|
-
/change.?me|replace.?me|placeholder|your.?secret|example|generate.?me/i.test(secret) ||
|
|
226
|
-
new Set(secret).size < 8)
|
|
227
|
-
throw new Error('BETTER_AUTH_SECRET requires a generated nonplaceholder secret of at least 32 characters.');
|
|
228
|
-
const origin = applicationValue(content, 'BETTER_AUTH_URL');
|
|
229
|
-
if (!publicAuthOrigin(origin))
|
|
230
|
-
throw new Error('BETTER_AUTH_URL must be an HTTPS public origin without credentials, path, query or fragment.');
|
|
231
|
-
Object.assign(values, { BETTER_AUTH_SECRET: secret, BETTER_AUTH_URL: origin });
|
|
232
|
-
}
|
|
233
|
-
return { [relative]: values };
|
|
234
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/** Editor schema validates syntax; selected-stack and provisioning readiness checks
|
|
2
|
-
* remain application rules, since templates deliberately contain empty choices. */
|
|
3
|
-
export declare const PROVIDER_CONFIGURATION_SCHEMA: {
|
|
4
|
-
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
5
|
-
readonly title: "Anhedral provider configuration";
|
|
6
|
-
readonly description: "Nonsecret resource choices. Supply credentials through the environment.";
|
|
7
|
-
readonly type: "object";
|
|
8
|
-
readonly additionalProperties: false;
|
|
9
|
-
readonly required: readonly ["schemaVersion", "providers"];
|
|
10
|
-
readonly properties: {
|
|
11
|
-
readonly schemaVersion: {
|
|
12
|
-
readonly const: 1;
|
|
13
|
-
};
|
|
14
|
-
readonly providers: {
|
|
15
|
-
readonly type: "object";
|
|
16
|
-
readonly additionalProperties: false;
|
|
17
|
-
readonly properties: {
|
|
18
|
-
[k: string]: {
|
|
19
|
-
type: string;
|
|
20
|
-
additionalProperties: boolean;
|
|
21
|
-
properties: {
|
|
22
|
-
[k: string]: Record<string, unknown>;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
package/dist/providers/schema.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { PROVIDER_DEFINITIONS, PROVIDER_EVENT_PATTERN, PROVIDER_IDENTITY_PATTERN, PROVIDER_TEXT_PATTERN, PROVIDER_WEBHOOK_PATTERN, } from './definitions.js';
|
|
2
|
-
function fieldSchema(field) {
|
|
3
|
-
if (field.kind === 'events')
|
|
4
|
-
return {
|
|
5
|
-
type: 'array',
|
|
6
|
-
minItems: 1,
|
|
7
|
-
maxItems: 100,
|
|
8
|
-
uniqueItems: true,
|
|
9
|
-
items: { type: 'string', pattern: PROVIDER_EVENT_PATTERN },
|
|
10
|
-
};
|
|
11
|
-
return {
|
|
12
|
-
type: 'string',
|
|
13
|
-
maxLength: 255,
|
|
14
|
-
...(field.choices
|
|
15
|
-
? { enum: field.choices }
|
|
16
|
-
: {
|
|
17
|
-
pattern: field.kind === 'identity'
|
|
18
|
-
? PROVIDER_IDENTITY_PATTERN
|
|
19
|
-
: field.kind === 'https-url'
|
|
20
|
-
? PROVIDER_WEBHOOK_PATTERN
|
|
21
|
-
: PROVIDER_TEXT_PATTERN,
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/** Editor schema validates syntax; selected-stack and provisioning readiness checks
|
|
26
|
-
* remain application rules, since templates deliberately contain empty choices. */
|
|
27
|
-
export const PROVIDER_CONFIGURATION_SCHEMA = {
|
|
28
|
-
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
29
|
-
title: 'Anhedral provider configuration',
|
|
30
|
-
description: 'Nonsecret resource choices. Supply credentials through the environment.',
|
|
31
|
-
type: 'object',
|
|
32
|
-
additionalProperties: false,
|
|
33
|
-
required: ['schemaVersion', 'providers'],
|
|
34
|
-
properties: {
|
|
35
|
-
schemaVersion: { const: 1 },
|
|
36
|
-
providers: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
additionalProperties: false,
|
|
39
|
-
properties: Object.fromEntries(Object.entries(PROVIDER_DEFINITIONS).map(([id, definition]) => [
|
|
40
|
-
id,
|
|
41
|
-
{
|
|
42
|
-
type: 'object',
|
|
43
|
-
additionalProperties: false,
|
|
44
|
-
properties: Object.fromEntries(Object.entries(definition.fields).map(([key, field]) => [key, fieldSchema(field)])),
|
|
45
|
-
},
|
|
46
|
-
])),
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { atomicJson, type DeliveryRunner } from '../project-state.js';
|
|
2
|
-
import { type ApiObject, type ApiRequest } from './api.js';
|
|
3
|
-
import { type MinimalReceipt } from './receipts.js';
|
|
4
|
-
import { type IntegrationProvider, type ProviderSettings } from './config.js';
|
|
5
|
-
export interface OperationDescriptor {
|
|
6
|
-
key: string;
|
|
7
|
-
route: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function privateStateDirectory(root: string, run: DeliveryRunner): Promise<string>;
|
|
10
|
-
export declare function readProviderStateStatus(directory: string): {
|
|
11
|
-
schemaVersion: number;
|
|
12
|
-
providers: {
|
|
13
|
-
provider: string;
|
|
14
|
-
operations: {
|
|
15
|
-
descriptor: OperationDescriptor;
|
|
16
|
-
recovery: string;
|
|
17
|
-
resources?: MinimalReceipt | undefined;
|
|
18
|
-
operation: string;
|
|
19
|
-
status: "pending" | "complete";
|
|
20
|
-
}[];
|
|
21
|
-
}[];
|
|
22
|
-
};
|
|
23
|
-
/** Store credentials before completing a minimal receipt. A crash leaves a pending
|
|
24
|
-
* operation, never permission to replay a provider mutation with an unknown outcome. */
|
|
25
|
-
export declare class ProvisioningState {
|
|
26
|
-
private readonly write;
|
|
27
|
-
private readonly file;
|
|
28
|
-
private readonly credentialsFile;
|
|
29
|
-
private readonly state;
|
|
30
|
-
private readonly credentials;
|
|
31
|
-
constructor(directory: string, write?: typeof atomicJson);
|
|
32
|
-
private assertCredentials;
|
|
33
|
-
private retainCredentials;
|
|
34
|
-
/** No configurations, credentials, provider payloads or mutation bodies in status. */
|
|
35
|
-
status(): {
|
|
36
|
-
schemaVersion: number;
|
|
37
|
-
providers: {
|
|
38
|
-
provider: string;
|
|
39
|
-
operations: {
|
|
40
|
-
operation: string;
|
|
41
|
-
status: "pending" | "complete";
|
|
42
|
-
resources: MinimalReceipt;
|
|
43
|
-
}[];
|
|
44
|
-
}[];
|
|
45
|
-
};
|
|
46
|
-
context(id: IntegrationProvider, settings: ProviderSettings): void;
|
|
47
|
-
recoverResource(id: IntegrationProvider, operation: string, resource: string, settings: ProviderSettings, api: ApiRequest, beforeCommit?: () => void): Promise<{
|
|
48
|
-
provider: keyof import("./definitions.js").ProviderSettingsById;
|
|
49
|
-
operation: string;
|
|
50
|
-
status: string;
|
|
51
|
-
resources: MinimalReceipt;
|
|
52
|
-
mutation: string;
|
|
53
|
-
}>;
|
|
54
|
-
create(id: IntegrationProvider, key: string, api: ApiRequest, route: string, body: ApiObject): Promise<ApiObject>;
|
|
55
|
-
}
|