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
package/dist/catalog-snapshot.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { lstatSync, realpathSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { readBoundedFile } from './bounded-file.js';
|
|
4
|
-
import { readProjectConfig, projectConfigPath } from './project-config.js';
|
|
5
|
-
import { inspectApplication } from './project-inspector.js';
|
|
6
|
-
import { STANDARD_PRODUCTS } from './stack-registry.js';
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
/** List views read bounded package and project configuration; detailed evidence is opt-in by ID. */
|
|
9
|
-
export function projectSnapshot(entry, detail = false) {
|
|
10
|
-
const summary = {
|
|
11
|
-
id: entry.id,
|
|
12
|
-
name: entry.name,
|
|
13
|
-
sourceName: '',
|
|
14
|
-
updatedAt: entry.updatedAt,
|
|
15
|
-
products: [],
|
|
16
|
-
status: 'source',
|
|
17
|
-
};
|
|
18
|
-
try {
|
|
19
|
-
if (realpathSync(entry.root) !== entry.root)
|
|
20
|
-
throw new Error();
|
|
21
|
-
const configuration = catalogConfiguration(entry.root);
|
|
22
|
-
if (entry.sourceIdentity !== sourceIdentity(configuration))
|
|
23
|
-
return {
|
|
24
|
-
...summary,
|
|
25
|
-
status: 'unavailable',
|
|
26
|
-
message: 'This directory contains a different app. Select its new catalog entry or restore the registered source.',
|
|
27
|
-
};
|
|
28
|
-
if (realpathSync(entry.root) !== entry.root)
|
|
29
|
-
throw new Error();
|
|
30
|
-
const read = (relative) => {
|
|
31
|
-
const file = path.join(entry.root, relative);
|
|
32
|
-
if (!realpathSync(file).startsWith(entry.root + path.sep))
|
|
33
|
-
throw new Error();
|
|
34
|
-
return JSON.parse(readBoundedFile(file, 256 * 1024).toString('utf8'));
|
|
35
|
-
};
|
|
36
|
-
const manifest = read('package.json');
|
|
37
|
-
if (typeof manifest.name !== 'string' ||
|
|
38
|
-
!/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(manifest.name) ||
|
|
39
|
-
manifest.name.length > 214)
|
|
40
|
-
throw new Error();
|
|
41
|
-
summary.sourceName = manifest.name;
|
|
42
|
-
const rawSetup = configuration?.setup;
|
|
43
|
-
if (rawSetup !== undefined) {
|
|
44
|
-
if (!rawSetup || typeof rawSetup !== 'object' || Array.isArray(rawSetup))
|
|
45
|
-
throw new Error();
|
|
46
|
-
if (Buffer.byteLength(JSON.stringify(rawSetup)) > 256 * 1024)
|
|
47
|
-
throw new Error();
|
|
48
|
-
const setup = rawSetup;
|
|
49
|
-
summary.products = Array.isArray(setup.products)
|
|
50
|
-
? setup.products
|
|
51
|
-
.filter((p) => typeof p === 'string' &&
|
|
52
|
-
STANDARD_PRODUCTS.includes(p))
|
|
53
|
-
.slice(0, 100)
|
|
54
|
-
: [];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
summary.status = 'unavailable';
|
|
59
|
-
summary.message =
|
|
60
|
-
'Source summary is unavailable. Restore or inspect the registered source, then refresh.';
|
|
61
|
-
}
|
|
62
|
-
if (detail) {
|
|
63
|
-
try {
|
|
64
|
-
if (realpathSync(entry.root) !== entry.root)
|
|
65
|
-
throw new Error();
|
|
66
|
-
summary.inspection = inspectApplication(entry.root);
|
|
67
|
-
summary.status =
|
|
68
|
-
summary.status !== 'unavailable' &&
|
|
69
|
-
summary.inspection.targets.data.some((target) => target.latestAttempt || target.lastSuccessful)
|
|
70
|
-
? 'recorded'
|
|
71
|
-
: summary.status;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
summary.status = 'unavailable';
|
|
75
|
-
summary.message = 'Registered source is unavailable. Restore the directory, then refresh.';
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return summary;
|
|
79
|
-
}
|
|
80
|
-
function catalogConfiguration(root) {
|
|
81
|
-
return lstatSync(projectConfigPath(root), { throwIfNoEntry: false })
|
|
82
|
-
? readProjectConfig(root)
|
|
83
|
-
: null;
|
|
84
|
-
}
|
|
85
|
-
function sourceIdentity(configuration) {
|
|
86
|
-
if (configuration?.identity === undefined)
|
|
87
|
-
return undefined;
|
|
88
|
-
if (Buffer.byteLength(JSON.stringify(configuration.identity)) > 4096)
|
|
89
|
-
throw new Error('Project identity exceeds its size limit.');
|
|
90
|
-
return z
|
|
91
|
-
.object({ schemaVersion: z.literal(1), id: z.string().uuid() })
|
|
92
|
-
.strict()
|
|
93
|
-
.parse(configuration.identity).id;
|
|
94
|
-
}
|
|
95
|
-
export function readCatalogSourceIdentity(root) {
|
|
96
|
-
return sourceIdentity(catalogConfiguration(root));
|
|
97
|
-
}
|
package/dist/cli-delivery.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type OutputOptions } from './cli-output.js';
|
|
2
|
-
export declare const DELIVERY_COMMANDS: readonly ["register", "connect", "provision", "ship", "status", "manage", "verify", "rollback", "recover"];
|
|
3
|
-
export declare function runDelivery(command: string, args: string[], output: OutputOptions): Promise<void>;
|
package/dist/cli-delivery.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { commandArguments, commandArgumentError } from './cli-arguments.js';
|
|
3
|
-
import { printResult } from './cli-output.js';
|
|
4
|
-
import { recoverDeliveryLock } from './project-state.js';
|
|
5
|
-
import { readLifecycleOperation } from './lifecycle.js';
|
|
6
|
-
import { buildMobileApplication } from './mobile-delivery.js';
|
|
7
|
-
import { shipCloudflareApplication } from './ship.js';
|
|
8
|
-
import { planProvisioning, provisionApplication } from './provision.js';
|
|
9
|
-
import { writeManagementOverview } from './management.js';
|
|
10
|
-
import { registerApplication, connectApplication, applicationStatus, verifyApplication, rollbackApplication, recoverApplication, } from './delivery.js';
|
|
11
|
-
export const DELIVERY_COMMANDS = [
|
|
12
|
-
'register',
|
|
13
|
-
'connect',
|
|
14
|
-
'provision',
|
|
15
|
-
'ship',
|
|
16
|
-
'status',
|
|
17
|
-
'manage',
|
|
18
|
-
'verify',
|
|
19
|
-
'rollback',
|
|
20
|
-
'recover',
|
|
21
|
-
];
|
|
22
|
-
function deliveryOptions(command, args) {
|
|
23
|
-
const options = commandArguments(command, args);
|
|
24
|
-
const error = (message) => commandArgumentError(command, message);
|
|
25
|
-
if (options.positional.length > 1)
|
|
26
|
-
throw error('Specify at most one application directory.');
|
|
27
|
-
function choice(flag, choices, message) {
|
|
28
|
-
const value = options.value(flag);
|
|
29
|
-
if (value === undefined)
|
|
30
|
-
return undefined;
|
|
31
|
-
if (!choices.includes(value))
|
|
32
|
-
throw error(message);
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
root: path.resolve(options.positional[0] ?? process.cwd()),
|
|
37
|
-
account: options.value('--account'),
|
|
38
|
-
audience: choice('--audience', ['public', 'private'], 'Specify --audience public or private.'),
|
|
39
|
-
emails: options.values('--allow-email'),
|
|
40
|
-
provider: choice('--provider', ['cloudflare'], 'Only Cloudflare hosting is supported.'),
|
|
41
|
-
platform: choice('--platform', ['ios', 'android'], 'Select one mobile platform.'),
|
|
42
|
-
profile: options.value('--profile'),
|
|
43
|
-
releaseId: options.value('--release'),
|
|
44
|
-
dryRun: options.has('--dry-run'),
|
|
45
|
-
refresh: options.has('--refresh'),
|
|
46
|
-
local: options.has('--local'),
|
|
47
|
-
lock: options.has('--lock'),
|
|
48
|
-
dataCompatible: options.has('--data-compatible'),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function releaseId(command, options) {
|
|
52
|
-
if (!options.releaseId)
|
|
53
|
-
throw commandArgumentError(command, 'Rollback requires --release <recorded-id>.');
|
|
54
|
-
return options.releaseId;
|
|
55
|
-
}
|
|
56
|
-
async function cloudflareCommand(command, options) {
|
|
57
|
-
const { root, account, audience, emails, dryRun, refresh, local } = options;
|
|
58
|
-
switch (command) {
|
|
59
|
-
case 'register':
|
|
60
|
-
return registerApplication(root);
|
|
61
|
-
case 'connect':
|
|
62
|
-
return connectApplication(root, account, audience, undefined, emails);
|
|
63
|
-
case 'provision':
|
|
64
|
-
return dryRun ? planProvisioning(root) : provisionApplication(root);
|
|
65
|
-
case 'ship':
|
|
66
|
-
return shipCloudflareApplication(root, dryRun);
|
|
67
|
-
case 'recover':
|
|
68
|
-
return recoverApplication(root);
|
|
69
|
-
case 'verify':
|
|
70
|
-
return verifyApplication(root);
|
|
71
|
-
case 'rollback':
|
|
72
|
-
return rollbackApplication(root, releaseId(command, options), options.dataCompatible);
|
|
73
|
-
case 'manage': {
|
|
74
|
-
const snapshot = await applicationStatus(root, !local);
|
|
75
|
-
return { file: writeManagementOverview(root, snapshot), evidence: snapshot.evidence };
|
|
76
|
-
}
|
|
77
|
-
default:
|
|
78
|
-
return applicationStatus(root, refresh);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
async function executeDelivery(command, options) {
|
|
82
|
-
const { root, provider, platform, profile, dryRun, lock, refresh } = options;
|
|
83
|
-
if (command === 'recover' && lock) {
|
|
84
|
-
if (provider || refresh)
|
|
85
|
-
throw commandArgumentError(command, 'Local lock recovery cannot be combined with provider recovery or --refresh.');
|
|
86
|
-
return { result: recoverDeliveryLock(root), blockedStates: [] };
|
|
87
|
-
}
|
|
88
|
-
if (platform || profile) {
|
|
89
|
-
if (!platform || !profile || provider)
|
|
90
|
-
throw commandArgumentError(command, 'Mobile shipping requires --platform and --profile, without --provider.');
|
|
91
|
-
return {
|
|
92
|
-
result: await buildMobileApplication(root, { platform, profile, dryRun }),
|
|
93
|
-
blockedStates: ['configuration-required', 'provider-configuration-required'],
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
let result = await cloudflareCommand(command, options);
|
|
97
|
-
if (command === 'status')
|
|
98
|
-
result = { ...result, operation: readLifecycleOperation(root) };
|
|
99
|
-
return {
|
|
100
|
-
result,
|
|
101
|
-
blockedStates: ['configuration-required', 'provider-configuration-required'],
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
export async function runDelivery(command, args, output) {
|
|
105
|
-
const { result, blockedStates } = await executeDelivery(command, deliveryOptions(command, args));
|
|
106
|
-
printResult(command, result, output);
|
|
107
|
-
if (result &&
|
|
108
|
-
typeof result === 'object' &&
|
|
109
|
-
'state' in result &&
|
|
110
|
-
blockedStates.includes(String(result.state)))
|
|
111
|
-
process.exitCode = 1;
|
|
112
|
-
}
|
package/dist/cloudflare.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ApplicationProject, DeliveryRunner } from './project-state.js';
|
|
2
|
-
export interface CloudflareResponse {
|
|
3
|
-
result: unknown;
|
|
4
|
-
result_info?: {
|
|
5
|
-
page?: number;
|
|
6
|
-
total_pages?: number;
|
|
7
|
-
count?: number;
|
|
8
|
-
per_page?: number;
|
|
9
|
-
cursor?: string;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export type CloudflareRequest = (method: 'GET' | 'POST' | 'DELETE', endpoint: string, body?: unknown) => Promise<CloudflareResponse>;
|
|
13
|
-
export interface CloudflareRequestOptions {
|
|
14
|
-
send?: typeof fetch;
|
|
15
|
-
timeoutMs?: number;
|
|
16
|
-
analytics?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare class CloudflareRequestError extends Error {
|
|
19
|
-
readonly status: number;
|
|
20
|
-
constructor(message: string, status: number);
|
|
21
|
-
}
|
|
22
|
-
/** Credentials stay in this closure. Fixed account paths, bounded response reads and
|
|
23
|
-
* a whole-request deadline apply to reads and mutations; mutations never retry. */
|
|
24
|
-
export declare function cloudflareRequest(project: ApplicationProject, directory: string, run: DeliveryRunner, env: NodeJS.ProcessEnv, options?: CloudflareRequestOptions): Promise<CloudflareRequest>;
|
|
25
|
-
export declare function listCloudflare(request: CloudflareRequest, endpoint: string): Promise<Record<string, unknown>[]>;
|
package/dist/cloudflare.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
const ORIGIN = 'https://api.cloudflare.com';
|
|
2
|
-
const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
|
|
3
|
-
export class CloudflareRequestError extends Error {
|
|
4
|
-
status;
|
|
5
|
-
constructor(message, status) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.status = status;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function object(value) {
|
|
11
|
-
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
12
|
-
}
|
|
13
|
-
function cancelBody(response) {
|
|
14
|
-
try {
|
|
15
|
-
void response.body?.cancel().catch(() => undefined);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
/* Best effort cancellation never exposes provider diagnostics. */
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
async function boundedJson(response, signal) {
|
|
22
|
-
if (signal.aborted) {
|
|
23
|
-
cancelBody(response);
|
|
24
|
-
throw new Error();
|
|
25
|
-
}
|
|
26
|
-
const reader = response.body?.getReader();
|
|
27
|
-
if (!reader)
|
|
28
|
-
throw new Error();
|
|
29
|
-
const cancel = () => {
|
|
30
|
-
void reader.cancel().catch(() => undefined);
|
|
31
|
-
};
|
|
32
|
-
signal.addEventListener('abort', cancel, { once: true });
|
|
33
|
-
const chunks = [];
|
|
34
|
-
let bytes = 0;
|
|
35
|
-
try {
|
|
36
|
-
for (;;) {
|
|
37
|
-
const chunk = await reader.read();
|
|
38
|
-
if (chunk.done)
|
|
39
|
-
break;
|
|
40
|
-
bytes += chunk.value.length;
|
|
41
|
-
if (bytes > MAX_RESPONSE_BYTES || signal.aborted)
|
|
42
|
-
throw new Error();
|
|
43
|
-
chunks.push(chunk.value);
|
|
44
|
-
}
|
|
45
|
-
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
cancel();
|
|
49
|
-
throw new Error();
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
signal.removeEventListener('abort', cancel);
|
|
53
|
-
reader.releaseLock();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function responseInfo(value) {
|
|
57
|
-
if (value === undefined || value === null)
|
|
58
|
-
return undefined;
|
|
59
|
-
if (!object(value))
|
|
60
|
-
throw new Error('Cloudflare returned unsupported pagination.');
|
|
61
|
-
const info = {};
|
|
62
|
-
if (value.cursor !== undefined) {
|
|
63
|
-
if (typeof value.cursor !== 'string' ||
|
|
64
|
-
value.cursor.length > 4096 ||
|
|
65
|
-
/[\x00-\x1f\x7f]/.test(value.cursor))
|
|
66
|
-
throw new Error('Cloudflare returned an invalid pagination cursor.');
|
|
67
|
-
info.cursor = value.cursor;
|
|
68
|
-
}
|
|
69
|
-
for (const field of ['page', 'total_pages', 'count', 'per_page']) {
|
|
70
|
-
const entry = value[field];
|
|
71
|
-
if (entry !== undefined) {
|
|
72
|
-
if (typeof entry !== 'number' || !Number.isSafeInteger(entry) || entry < 0)
|
|
73
|
-
throw new Error('Cloudflare returned unsupported pagination.');
|
|
74
|
-
info[field] = entry;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return info;
|
|
78
|
-
}
|
|
79
|
-
/** Credentials stay in this closure. Fixed account paths, bounded response reads and
|
|
80
|
-
* a whole-request deadline apply to reads and mutations; mutations never retry. */
|
|
81
|
-
export async function cloudflareRequest(project, directory, run, env, options = {}) {
|
|
82
|
-
const account = project.accountId;
|
|
83
|
-
if (typeof account !== 'string' || !/^[a-f0-9]{32}$/.test(account))
|
|
84
|
-
throw new Error('Select a valid Cloudflare account before provider requests.');
|
|
85
|
-
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
86
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 30_000)
|
|
87
|
-
throw new Error('Invalid bounded Cloudflare request deadline.');
|
|
88
|
-
const send = options.send ?? fetch;
|
|
89
|
-
let credentials;
|
|
90
|
-
try {
|
|
91
|
-
const raw = await run('pnpm', ['exec', 'wrangler', 'auth', 'token', '--json'], directory, env);
|
|
92
|
-
if (Buffer.byteLength(raw) > 64 * 1024)
|
|
93
|
-
throw new Error();
|
|
94
|
-
credentials = JSON.parse(raw);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
throw new Error('Cannot retrieve structured Wrangler credentials; update Wrangler and check authentication.');
|
|
98
|
-
}
|
|
99
|
-
if (!object(credentials) ||
|
|
100
|
-
typeof credentials.type !== 'string' ||
|
|
101
|
-
!['oauth', 'api_token'].includes(credentials.type) ||
|
|
102
|
-
typeof credentials.token !== 'string' ||
|
|
103
|
-
!/^[\x21-\x7e]{1,16384}$/.test(credentials.token))
|
|
104
|
-
throw new Error('Cloudflare operations require scoped API-token or Wrangler OAuth access.');
|
|
105
|
-
const token = credentials.token;
|
|
106
|
-
const prefix = `/client/v4/accounts/${account}`;
|
|
107
|
-
return async (method, endpoint, body) => {
|
|
108
|
-
let url;
|
|
109
|
-
try {
|
|
110
|
-
if (typeof endpoint !== 'string')
|
|
111
|
-
throw new Error();
|
|
112
|
-
const decodedPath = decodeURIComponent(endpoint.split('?')[0]);
|
|
113
|
-
if (!['GET', 'POST', 'DELETE'].includes(method) ||
|
|
114
|
-
endpoint.length > 4096 ||
|
|
115
|
-
!endpoint.startsWith('/') ||
|
|
116
|
-
endpoint.startsWith('//') ||
|
|
117
|
-
/[\x00-\x20\x7f#\\]/.test(endpoint) ||
|
|
118
|
-
decodedPath.includes('..') ||
|
|
119
|
-
/[\x00-\x20\x7f#\\%]/.test(decodedPath))
|
|
120
|
-
throw new Error();
|
|
121
|
-
if (options.analytics) {
|
|
122
|
-
if (endpoint !== '/graphql' ||
|
|
123
|
-
method !== 'POST' ||
|
|
124
|
-
!object(body) ||
|
|
125
|
-
!object(body.variables) ||
|
|
126
|
-
body.variables.accountTag !== account)
|
|
127
|
-
throw new Error();
|
|
128
|
-
url = new URL('/client/v4/graphql', ORIGIN);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
url = new URL(`${prefix}${endpoint}`, ORIGIN);
|
|
132
|
-
if (url.origin !== ORIGIN || !url.pathname.startsWith(`${prefix}/`))
|
|
133
|
-
throw new Error();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
throw new Error('Invalid account-scoped provider request.');
|
|
138
|
-
}
|
|
139
|
-
const controller = new AbortController();
|
|
140
|
-
let timer;
|
|
141
|
-
const timeout = new Promise((_resolve, reject) => {
|
|
142
|
-
timer = setTimeout(() => {
|
|
143
|
-
controller.abort();
|
|
144
|
-
reject(new Error('Cloudflare request deadline exceeded; inspect remote status before retrying.'));
|
|
145
|
-
}, timeoutMs);
|
|
146
|
-
});
|
|
147
|
-
try {
|
|
148
|
-
return await Promise.race([
|
|
149
|
-
(async () => {
|
|
150
|
-
let response;
|
|
151
|
-
try {
|
|
152
|
-
response = await send(url.href, {
|
|
153
|
-
method,
|
|
154
|
-
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
155
|
-
body: body === undefined ? undefined : JSON.stringify(body),
|
|
156
|
-
redirect: 'error',
|
|
157
|
-
signal: controller.signal,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
throw new Error('Cloudflare request failed; check connectivity and account permissions.');
|
|
162
|
-
}
|
|
163
|
-
let data;
|
|
164
|
-
try {
|
|
165
|
-
data = await boundedJson(response, controller.signal);
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
throw new Error(`Cloudflare returned unsupported output (HTTP ${response.status}).`);
|
|
169
|
-
}
|
|
170
|
-
if (!object(data))
|
|
171
|
-
throw new Error(`Cloudflare returned unsupported output (HTTP ${response.status}).`);
|
|
172
|
-
if (!response.ok ||
|
|
173
|
-
(options.analytics
|
|
174
|
-
? data.errors != null && (!Array.isArray(data.errors) || data.errors.length > 0)
|
|
175
|
-
: data.success !== true)) {
|
|
176
|
-
const codes = Array.isArray(data.errors)
|
|
177
|
-
? data.errors
|
|
178
|
-
.slice(0, 20)
|
|
179
|
-
.filter(object)
|
|
180
|
-
.map((item) => item.code)
|
|
181
|
-
.filter((code) => typeof code === 'number' &&
|
|
182
|
-
Number.isSafeInteger(code) &&
|
|
183
|
-
code >= 0 &&
|
|
184
|
-
code <= 1_000_000)
|
|
185
|
-
.join(',')
|
|
186
|
-
: '';
|
|
187
|
-
throw new CloudflareRequestError(`Cloudflare operation failed (HTTP ${response.status}${codes ? `; codes ${codes}` : ''}). Check scoped permissions and service eligibility; no paid plan is activated automatically.`, response.status);
|
|
188
|
-
}
|
|
189
|
-
if (options.analytics)
|
|
190
|
-
return { result: data.data };
|
|
191
|
-
if (!Object.hasOwn(data, 'result'))
|
|
192
|
-
throw new Error('Cloudflare returned no operation result.');
|
|
193
|
-
return { result: data.result, result_info: responseInfo(data.result_info) };
|
|
194
|
-
})(),
|
|
195
|
-
timeout,
|
|
196
|
-
]);
|
|
197
|
-
}
|
|
198
|
-
finally {
|
|
199
|
-
clearTimeout(timer);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
export async function listCloudflare(request, endpoint) {
|
|
204
|
-
const result = [];
|
|
205
|
-
let bytes = 0;
|
|
206
|
-
for (let page = 1; page <= 1000; page++) {
|
|
207
|
-
const response = await request('GET', `${endpoint}${endpoint.includes('?') ? '&' : '?'}page=${page}&per_page=100`);
|
|
208
|
-
if (!Array.isArray(response.result) ||
|
|
209
|
-
response.result.length > 100 ||
|
|
210
|
-
response.result.some((item) => !object(item)))
|
|
211
|
-
throw new Error('Unsupported provider resource list.');
|
|
212
|
-
try {
|
|
213
|
-
bytes += Buffer.byteLength(JSON.stringify(response.result));
|
|
214
|
-
}
|
|
215
|
-
catch {
|
|
216
|
-
throw new Error('Unsupported provider resource list.');
|
|
217
|
-
}
|
|
218
|
-
if (result.length + response.result.length > 10_000 || bytes > 10 * 1024 * 1024)
|
|
219
|
-
throw new Error('Provider resource listing exceeded its collection limit.');
|
|
220
|
-
result.push(...response.result);
|
|
221
|
-
const info = responseInfo(response.result_info);
|
|
222
|
-
if (info?.total_pages !== undefined ? page >= info.total_pages : response.result.length < 100)
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
throw new Error('Provider resource listing exceeded pagination limit.');
|
|
226
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { type CloudflareRequest } from './cloudflare.js';
|
|
2
|
-
import { defaultRunner, type ApplicationProject, type DeploymentTarget } from './project-state.js';
|
|
3
|
-
export interface TargetRelease {
|
|
4
|
-
target: string;
|
|
5
|
-
versionId: string;
|
|
6
|
-
urls: string[];
|
|
7
|
-
providerConfirmed: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface Release {
|
|
10
|
-
id: string;
|
|
11
|
-
commit: string;
|
|
12
|
-
startedAt: string;
|
|
13
|
-
finishedAt?: string;
|
|
14
|
-
state: 'running' | 'checked' | 'deployed' | 'configuration-required' | 'failed';
|
|
15
|
-
targets: TargetRelease[];
|
|
16
|
-
failure?: string;
|
|
17
|
-
configurationChanges?: string[];
|
|
18
|
-
operation?: 'ship' | 'rollback';
|
|
19
|
-
restoredReleaseId?: string;
|
|
20
|
-
verification?: {
|
|
21
|
-
state: 'passed' | 'failed';
|
|
22
|
-
checkedAt: string;
|
|
23
|
-
command: 'pnpm run test:live';
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export interface ReleaseHistory {
|
|
27
|
-
schemaVersion: 1;
|
|
28
|
-
projectId: string;
|
|
29
|
-
releases: Release[];
|
|
30
|
-
}
|
|
31
|
-
export declare function history(root: string, project: ApplicationProject): ReleaseHistory;
|
|
32
|
-
export declare function checkTargets(root: string, project: ApplicationProject, allowResourcePlaceholders?: boolean): void;
|
|
33
|
-
export declare function configurationFingerprint(root: string, project: ApplicationProject): string;
|
|
34
|
-
export declare function planDelivery(root: string, allowResourcePlaceholders?: boolean): {
|
|
35
|
-
project: ApplicationProject;
|
|
36
|
-
checks: string[][];
|
|
37
|
-
deployments: {
|
|
38
|
-
target: string;
|
|
39
|
-
directory: string;
|
|
40
|
-
command: string[];
|
|
41
|
-
}[];
|
|
42
|
-
resourcesProvisioned: boolean;
|
|
43
|
-
audience: "unconfigured" | "public" | "private";
|
|
44
|
-
};
|
|
45
|
-
export declare function parseDeploymentOutput(source: string, target: DeploymentTarget): TargetRelease;
|
|
46
|
-
export interface ActiveVersion {
|
|
47
|
-
versionId: string;
|
|
48
|
-
percentage: number;
|
|
49
|
-
}
|
|
50
|
-
export declare function activeVersions(value: unknown): ActiveVersion[];
|
|
51
|
-
export declare function providerStatus(root: string, project: ApplicationProject, target: DeploymentTarget, run: typeof defaultRunner, _request?: CloudflareRequest): Promise<unknown>;
|
|
52
|
-
export declare function fullyActive(versions: ActiveVersion[], versionId: string): boolean;
|
|
53
|
-
export declare function describeArchitecture(root: string, project: ApplicationProject): {
|
|
54
|
-
target: string;
|
|
55
|
-
workerName: string;
|
|
56
|
-
directory: string;
|
|
57
|
-
bindings: {
|
|
58
|
-
kind: string;
|
|
59
|
-
binding: string;
|
|
60
|
-
}[];
|
|
61
|
-
scheduled: string[];
|
|
62
|
-
}[];
|