@layers/amba 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-client.d.ts +121 -12
- package/dist/bundle.d.ts +86 -0
- package/dist/commands/domains.d.ts +27 -0
- package/dist/commands/functions-logs.d.ts +4 -2
- package/dist/commands/functions.d.ts +26 -6
- package/dist/commands/iac.d.ts +116 -0
- package/dist/commands/monetization.d.ts +36 -0
- package/dist/commands/payments.d.ts +33 -0
- package/dist/commands/secrets.d.ts +29 -9
- package/dist/index.js +1815 -155
- package/package.json +3 -3
- package/skill-bundle/SKILL.md +2 -0
- package/skill-bundle/references/infrastructure.md +20 -17
package/dist/api-client.d.ts
CHANGED
|
@@ -277,6 +277,9 @@ export interface FunctionDeploymentRow {
|
|
|
277
277
|
bundle_sha: string;
|
|
278
278
|
status: 'active' | 'superseded' | 'disabled';
|
|
279
279
|
created_at: string;
|
|
280
|
+
/** Opt-in public flag (#17). True = X-Api-Key gate skipped for this
|
|
281
|
+
* function so external webhook senders can reach it. Default false. */
|
|
282
|
+
is_public?: boolean;
|
|
280
283
|
}
|
|
281
284
|
export declare function recordFunctionDeployment(projectId: string, input: {
|
|
282
285
|
name: string;
|
|
@@ -310,6 +313,13 @@ export declare function deployFunctionViaApi(projectId: string, input: {
|
|
|
310
313
|
max: number;
|
|
311
314
|
key: 'user_id' | 'ip';
|
|
312
315
|
} | null;
|
|
316
|
+
/**
|
|
317
|
+
* Opt-in public flag (#17). When true, the edge runtime skips the
|
|
318
|
+
* X-Api-Key gate for this function so third-party webhook senders can
|
|
319
|
+
* reach it. Default false (private). The customer verifies the webhook
|
|
320
|
+
* HMAC inside the handler.
|
|
321
|
+
*/
|
|
322
|
+
public?: boolean;
|
|
313
323
|
}): Promise<DeployFunctionResult>;
|
|
314
324
|
export declare function listFunctionDeployments(projectId: string, options?: {
|
|
315
325
|
activeOnly?: boolean;
|
|
@@ -348,11 +358,14 @@ export declare function scheduleFunction(projectId: string, input: {
|
|
|
348
358
|
schedule_id: string;
|
|
349
359
|
}>>;
|
|
350
360
|
export interface FunctionLogEvent {
|
|
351
|
-
/**
|
|
361
|
+
/** Sanitized log row — see `r2-log-reader.ts:SanitizedLogEvent`. Field-shape stable. */
|
|
352
362
|
Event?: {
|
|
353
363
|
Timestamp?: string;
|
|
354
364
|
};
|
|
355
|
-
|
|
365
|
+
/** The function's name (parsed server-side from the internal script name). */
|
|
366
|
+
function_name?: string;
|
|
367
|
+
/** The deploy version this event came from. */
|
|
368
|
+
version?: number;
|
|
356
369
|
Outcome?: string;
|
|
357
370
|
Logs?: Array<{
|
|
358
371
|
Level?: string;
|
|
@@ -376,6 +389,7 @@ export declare function getFunctionLogs(projectId: string, functionName: string,
|
|
|
376
389
|
since?: string;
|
|
377
390
|
until?: string;
|
|
378
391
|
limit?: number;
|
|
392
|
+
requestId?: string;
|
|
379
393
|
}): Promise<ApiResponse<FunctionLogsResponse>>;
|
|
380
394
|
export interface QueueBinding {
|
|
381
395
|
queue_name: string;
|
|
@@ -417,8 +431,8 @@ export declare function listSecretSyncStatus(projectId: string): Promise<ApiList
|
|
|
417
431
|
export interface SetSecretResultRow {
|
|
418
432
|
/** Secret name as set by the customer. */
|
|
419
433
|
name: string;
|
|
420
|
-
/** Function
|
|
421
|
-
function: string;
|
|
434
|
+
/** Function the secret binds to, or `null` for a project-wide secret. */
|
|
435
|
+
function: string | null;
|
|
422
436
|
/** Secret store version number (1, 2, 3, ...). */
|
|
423
437
|
version: number;
|
|
424
438
|
/** Backend version resource path — exposed for ops debugging. */
|
|
@@ -432,12 +446,16 @@ export declare function setSecretViaApi(projectId: string, input: {
|
|
|
432
446
|
name: string;
|
|
433
447
|
/** Plaintext secret value. <=64KiB. */
|
|
434
448
|
value: string;
|
|
435
|
-
/**
|
|
436
|
-
|
|
449
|
+
/**
|
|
450
|
+
* Function the secret binds to. OMIT for a PROJECT-WIDE secret
|
|
451
|
+
* (applied to every function in the project, including ones deployed
|
|
452
|
+
* later).
|
|
453
|
+
*/
|
|
454
|
+
function?: string;
|
|
437
455
|
}): Promise<ApiResponse<SetSecretResultRow>>;
|
|
438
456
|
export interface ListSecretsRow {
|
|
439
|
-
/** Function
|
|
440
|
-
function: string;
|
|
457
|
+
/** Function the secret binds to, or `null` for a project-wide secret. */
|
|
458
|
+
function: string | null;
|
|
441
459
|
/** Secret name. */
|
|
442
460
|
name: string;
|
|
443
461
|
/** Latest secret-store version number. */
|
|
@@ -447,12 +465,14 @@ export interface ListSecretsRow {
|
|
|
447
465
|
last_error: string | null;
|
|
448
466
|
updated_at: string;
|
|
449
467
|
}
|
|
450
|
-
export declare function listSecretsViaApi(projectId: string
|
|
451
|
-
|
|
452
|
-
|
|
468
|
+
export declare function listSecretsViaApi(projectId: string, options?: {
|
|
469
|
+
function?: string;
|
|
470
|
+
}): Promise<ApiListResponse<ListSecretsRow>>;
|
|
471
|
+
export declare function deleteSecretViaApi(projectId: string, name: string, options?: {
|
|
472
|
+
function?: string;
|
|
453
473
|
}): Promise<ApiResponse<{
|
|
454
474
|
name: string;
|
|
455
|
-
function: string;
|
|
475
|
+
function: string | null;
|
|
456
476
|
deleted: true;
|
|
457
477
|
}>>;
|
|
458
478
|
/** Closed set of column types the server accepts. */
|
|
@@ -579,9 +599,23 @@ export interface SiteDomainRow {
|
|
|
579
599
|
hostname: string;
|
|
580
600
|
provider_hostname_id: string | null;
|
|
581
601
|
cert_status: 'pending_validation' | 'pending_issuance' | 'pending_deployment' | 'active' | 'error';
|
|
602
|
+
ownership_status: 'pending' | 'active' | 'error';
|
|
582
603
|
created_at: string;
|
|
583
604
|
updated_at: string;
|
|
584
605
|
}
|
|
606
|
+
/** A DNS record the customer must publish to validate / prove ownership. */
|
|
607
|
+
export interface DomainValidationRecord {
|
|
608
|
+
txt_name?: string;
|
|
609
|
+
txt_value?: string;
|
|
610
|
+
http_url?: string;
|
|
611
|
+
http_body?: string;
|
|
612
|
+
}
|
|
613
|
+
/** Hostname-ownership token returned as a DNS TXT record. */
|
|
614
|
+
export interface DomainOwnershipVerification {
|
|
615
|
+
type?: string;
|
|
616
|
+
name?: string;
|
|
617
|
+
value?: string;
|
|
618
|
+
}
|
|
585
619
|
export declare function createSite(projectId: string, input: {
|
|
586
620
|
name: string;
|
|
587
621
|
}): Promise<ApiResponse<SiteRow>>;
|
|
@@ -622,7 +656,16 @@ export declare function addSiteDomainViaApi(projectId: string, siteName: string,
|
|
|
622
656
|
hostname: string;
|
|
623
657
|
provider_hostname_id: string;
|
|
624
658
|
cert_status: SiteDomainRow["cert_status"];
|
|
659
|
+
ownership_status: SiteDomainRow["ownership_status"];
|
|
625
660
|
dns_target: string;
|
|
661
|
+
is_apex: boolean;
|
|
662
|
+
dns_note: string | null;
|
|
663
|
+
ssl_validation: DomainValidationRecord[];
|
|
664
|
+
ownership_verification: DomainOwnershipVerification | null;
|
|
665
|
+
ownership_verification_http: {
|
|
666
|
+
http_url?: string;
|
|
667
|
+
http_body?: string;
|
|
668
|
+
} | null;
|
|
626
669
|
created_at: string;
|
|
627
670
|
}>>;
|
|
628
671
|
/**
|
|
@@ -654,6 +697,51 @@ export declare function deleteSiteViaApi(projectId: string, siteName: string, op
|
|
|
654
697
|
deleted: true;
|
|
655
698
|
cascade: DeleteCascadeSummary;
|
|
656
699
|
}>>;
|
|
700
|
+
/** A candidate domain from a search. */
|
|
701
|
+
export interface DomainSuggestion {
|
|
702
|
+
domain: string;
|
|
703
|
+
available: boolean;
|
|
704
|
+
price_usd: number | null;
|
|
705
|
+
currency: string;
|
|
706
|
+
premium: boolean;
|
|
707
|
+
}
|
|
708
|
+
/** Authoritative availability + price for a specific domain. */
|
|
709
|
+
export interface DomainAvailability extends DomainSuggestion {
|
|
710
|
+
supported: boolean;
|
|
711
|
+
}
|
|
712
|
+
/** Purchase response — either a quote (executed=false) or a result. */
|
|
713
|
+
export interface DomainPurchaseResult {
|
|
714
|
+
domain: string;
|
|
715
|
+
site: string;
|
|
716
|
+
executed: boolean;
|
|
717
|
+
available?: boolean;
|
|
718
|
+
price_usd?: number | null;
|
|
719
|
+
currency?: string;
|
|
720
|
+
premium?: boolean;
|
|
721
|
+
confirmation_required?: boolean;
|
|
722
|
+
gated?: boolean;
|
|
723
|
+
live?: boolean;
|
|
724
|
+
registered?: boolean;
|
|
725
|
+
provisioned?: boolean;
|
|
726
|
+
cert_status?: string;
|
|
727
|
+
ownership_status?: string;
|
|
728
|
+
dns_autoconfigured?: boolean;
|
|
729
|
+
url?: string;
|
|
730
|
+
public_url?: string;
|
|
731
|
+
message?: string;
|
|
732
|
+
}
|
|
733
|
+
export declare function searchDomainsViaApi(projectId: string, query: string, limit?: number): Promise<ApiListResponse<DomainSuggestion>>;
|
|
734
|
+
export declare function checkDomainsViaApi(projectId: string, domains: string[]): Promise<ApiListResponse<DomainAvailability>>;
|
|
735
|
+
export declare function purchaseDomainViaApi(projectId: string, body: {
|
|
736
|
+
domain: string;
|
|
737
|
+
site: string;
|
|
738
|
+
accept_price_usd?: number;
|
|
739
|
+
confirm?: boolean;
|
|
740
|
+
auto_renew?: boolean;
|
|
741
|
+
privacy?: boolean;
|
|
742
|
+
years?: number;
|
|
743
|
+
}): Promise<ApiResponse<DomainPurchaseResult>>;
|
|
744
|
+
export declare function listPurchasedDomainsViaApi(projectId: string): Promise<ApiListResponse<Record<string, unknown>>>;
|
|
657
745
|
/**
|
|
658
746
|
* Delete a function entirely. Cascade: removes the deployed script
|
|
659
747
|
* (backend 404 treated as success), then marks every historical
|
|
@@ -680,6 +768,27 @@ export declare function updateSiteDomain(projectId: string, siteName: string, ho
|
|
|
680
768
|
export declare function detachSiteDomain(projectId: string, siteName: string, hostname: string): Promise<ApiResponse<{
|
|
681
769
|
deleted: boolean;
|
|
682
770
|
}>>;
|
|
771
|
+
/** A declarative promotion bundle. Section keys are all optional. */
|
|
772
|
+
export interface PromotionBundleWire {
|
|
773
|
+
version: number;
|
|
774
|
+
exported_at: string;
|
|
775
|
+
[section: string]: unknown;
|
|
776
|
+
}
|
|
777
|
+
/** `{ created, updated, skipped }` counts for one bundle section. */
|
|
778
|
+
export interface PromotionSectionSummary {
|
|
779
|
+
created: number;
|
|
780
|
+
updated: number;
|
|
781
|
+
skipped: number;
|
|
782
|
+
}
|
|
783
|
+
export type PromotionImportMode = 'merge' | 'skip_existing';
|
|
784
|
+
export interface PromotionImportResult {
|
|
785
|
+
mode: PromotionImportMode;
|
|
786
|
+
summary: Record<string, PromotionSectionSummary>;
|
|
787
|
+
}
|
|
788
|
+
/** GET the current project's declarative configuration bundle. */
|
|
789
|
+
export declare function exportPromotionBundle(projectId: string): Promise<ApiResponse<PromotionBundleWire>>;
|
|
790
|
+
/** POST a declarative bundle to import it into the project. */
|
|
791
|
+
export declare function importPromotionBundle(projectId: string, bundle: PromotionBundleWire, mode: PromotionImportMode): Promise<ApiResponse<PromotionImportResult>>;
|
|
683
792
|
export declare function validateApiKey(apiKey: string): Promise<{
|
|
684
793
|
valid: false;
|
|
685
794
|
error: string;
|
package/dist/bundle.d.ts
CHANGED
|
@@ -23,6 +23,25 @@
|
|
|
23
23
|
* empty; customer code is expected to be self-contained.
|
|
24
24
|
*/
|
|
25
25
|
import { type BuildOptions } from 'esbuild';
|
|
26
|
+
/**
|
|
27
|
+
* Conventional entry-point filenames probed (in order) when
|
|
28
|
+
* `amba functions deploy <dir>` is pointed at a directory rather than a
|
|
29
|
+
* single file. Mirrors the Node / bundler convention (`index.*`) so a
|
|
30
|
+
* developer can `amba functions deploy ./my-fn` with an `index.ts` inside.
|
|
31
|
+
*/
|
|
32
|
+
export declare const FUNCTION_ENTRY_CANDIDATES: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the bundler entry point from a deploy target that may be either a
|
|
35
|
+
* single file OR a directory.
|
|
36
|
+
*
|
|
37
|
+
* - File → returned as-is (single-file back-compat path).
|
|
38
|
+
* - Dir → resolved by convention to `index.{ts,js,mjs}`, or to an
|
|
39
|
+
* explicit `entry` (relative to the directory) when provided.
|
|
40
|
+
*
|
|
41
|
+
* Throws an actionable error when the target doesn't exist, or when a
|
|
42
|
+
* directory has no resolvable entry point (and no `--entry` was passed).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveFunctionEntry(target: string, explicitEntry?: string): Promise<string>;
|
|
26
45
|
/**
|
|
27
46
|
* Modules the bundler treats as `external` by default. The Amba
|
|
28
47
|
* function runtime exposes zero npm packages — there is no "platform
|
|
@@ -46,6 +65,62 @@ export declare class BundleSizeError extends Error {
|
|
|
46
65
|
readonly maxBytes: number;
|
|
47
66
|
constructor(sizeBytes: number, maxBytes: number);
|
|
48
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The single source-of-truth message for the wrong-handler-shape failure.
|
|
70
|
+
* Shared between the CLI bundler (pre-upload), the local `dev` runner, and
|
|
71
|
+
* the server-side deploy hint so dev / deploy / prod all describe the fix
|
|
72
|
+
* identically. Customer functions run as Module Workers; the legacy
|
|
73
|
+
* service-worker shape (`export default async function (req) { … }`) is
|
|
74
|
+
* rejected by the runtime at upload, so we reject it before the round-trip.
|
|
75
|
+
*/
|
|
76
|
+
export declare const HANDLER_SHAPE_FIX_MESSAGE: string;
|
|
77
|
+
/** Message used when the entry file has no `export default` at all. */
|
|
78
|
+
export declare const HANDLER_SHAPE_MISSING_DEFAULT_MESSAGE: string;
|
|
79
|
+
/** Message used when the default export is present but has no `fetch` method. */
|
|
80
|
+
export declare const HANDLER_SHAPE_NO_FETCH_MESSAGE: string;
|
|
81
|
+
/**
|
|
82
|
+
* Thrown when the bundled entry's `export default` is not the Module Worker
|
|
83
|
+
* shape (`{ fetch(req, env, ctx) }`). Raised BEFORE any upload so a wrong
|
|
84
|
+
* handler shape fails fast on the developer's machine with an actionable
|
|
85
|
+
* message instead of an opaque upstream rejection at deploy time.
|
|
86
|
+
*/
|
|
87
|
+
export declare class HandlerShapeError extends Error {
|
|
88
|
+
readonly kind: 'plain-function' | 'missing-default' | 'no-fetch';
|
|
89
|
+
constructor(message: string, kind: 'plain-function' | 'missing-default' | 'no-fetch');
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Inspect an already-imported module namespace and assert it has the
|
|
93
|
+
* Module Worker handler shape: a default export that is an object (or
|
|
94
|
+
* function-with-properties) carrying a callable `fetch`.
|
|
95
|
+
*
|
|
96
|
+
* Pure + side-effect free — it only reads the shape of `mod.default`, never
|
|
97
|
+
* invokes `fetch`. This is the unit-testable core; `assertModuleWorkerShape`
|
|
98
|
+
* wraps the import-from-code plumbing around it.
|
|
99
|
+
*
|
|
100
|
+
* Throws `HandlerShapeError` on:
|
|
101
|
+
* - no default export (`missing-default`)
|
|
102
|
+
* - a default-exported plain function — the legacy service-worker shape
|
|
103
|
+
* (`plain-function`)
|
|
104
|
+
* - a default export with no callable `fetch` (`no-fetch`)
|
|
105
|
+
*/
|
|
106
|
+
export declare function assertHandlerShape(mod: {
|
|
107
|
+
default?: unknown;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Validate that the bundled customer code exports the Module Worker handler
|
|
111
|
+
* shape, by importing it in isolation and inspecting `mod.default`.
|
|
112
|
+
*
|
|
113
|
+
* Mechanism: write the bundle to a throwaway temp `.mjs` and dynamic-import
|
|
114
|
+
* it, then hand the namespace to `assertHandlerShape`. This is the same
|
|
115
|
+
* import-and-inspect approach the local `dev` runner uses
|
|
116
|
+
* (`functions.ts` DEV_RUNNER_SOURCE) — reused here so the pre-upload check
|
|
117
|
+
* and the dev runner agree on what "valid shape" means. Importing runs the
|
|
118
|
+
* module's top-level code (unavoidable to read the export), but the handler
|
|
119
|
+
* itself is NEVER invoked — we only read the shape of the exported object.
|
|
120
|
+
*
|
|
121
|
+
* The temp file is always cleaned up (best-effort) before returning.
|
|
122
|
+
*/
|
|
123
|
+
export declare function assertModuleWorkerShape(code: string): Promise<void>;
|
|
49
124
|
export interface BundleResult {
|
|
50
125
|
/** The bundled JS source (UTF-8). */
|
|
51
126
|
code: string;
|
|
@@ -67,6 +142,17 @@ export interface BundleOptions {
|
|
|
67
142
|
extraExternals?: string[];
|
|
68
143
|
/** Source map handling. Default: inline. */
|
|
69
144
|
sourcemap?: BuildOptions['sourcemap'];
|
|
145
|
+
/**
|
|
146
|
+
* Validate the bundled entry exports the Module Worker handler shape
|
|
147
|
+
* (`export default { async fetch(req, env, ctx) { … } }`) before
|
|
148
|
+
* returning, throwing `HandlerShapeError` if not. Default: true.
|
|
149
|
+
*
|
|
150
|
+
* The check imports the bundle in isolation to inspect `mod.default`;
|
|
151
|
+
* it never invokes the handler. Both `deploy` and `dev` leave this on so
|
|
152
|
+
* a function that bundles in `dev` cannot fail the shape check in
|
|
153
|
+
* `deploy` (dev / prod parity).
|
|
154
|
+
*/
|
|
155
|
+
validateHandlerShape?: boolean;
|
|
70
156
|
}
|
|
71
157
|
/**
|
|
72
158
|
* Bundle a customer function file for upload to a Workers dispatch
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `amba domains ...` commands — buy a domain through Amba.
|
|
3
|
+
*
|
|
4
|
+
* amba domains search <query> find available domains + prices
|
|
5
|
+
* amba domains check <domain...> authoritative availability + price
|
|
6
|
+
* amba domains buy <domain> --site s buy + connect to a site
|
|
7
|
+
* amba domains list domains this project has purchased
|
|
8
|
+
*
|
|
9
|
+
* Search + check are free. `buy` surfaces the cost and requires explicit
|
|
10
|
+
* confirmation (interactive y/N, or `--yes`) before it submits a purchase —
|
|
11
|
+
* and the API itself only executes a real, paid registration when the
|
|
12
|
+
* platform has live purchasing enabled. A registered domain is auto-
|
|
13
|
+
* connected to the chosen site with no DNS setup by the customer.
|
|
14
|
+
*/
|
|
15
|
+
export declare function domainsSearchCommand(query: string, options?: {
|
|
16
|
+
limit?: number;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
export declare function domainsCheckCommand(domains: string[]): Promise<void>;
|
|
19
|
+
export interface DomainsBuyOptions {
|
|
20
|
+
site: string;
|
|
21
|
+
yes?: boolean;
|
|
22
|
+
noPrivacy?: boolean;
|
|
23
|
+
noAutoRenew?: boolean;
|
|
24
|
+
years?: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function domainsBuyCommand(domain: string, options: DomainsBuyOptions): Promise<void>;
|
|
27
|
+
export declare function domainsListCommand(): Promise<void>;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* Output formatting:
|
|
10
10
|
* - `--json`: NDJSON to stdout (one event per line) so `| jq` works.
|
|
11
11
|
* - default: human-readable lines:
|
|
12
|
-
* 2026-05-08T12:34:56.789Z scan-letter
|
|
13
|
-
* 2026-05-08T12:34:57.012Z scan-letter
|
|
12
|
+
* 2026-05-08T12:34:56.789Z scan-letter@v3 [info] "scanning"
|
|
13
|
+
* 2026-05-08T12:34:57.012Z scan-letter@v3 [exception] TypeError: …
|
|
14
14
|
*
|
|
15
15
|
* Server-side scoping is enforced — the API filters by ScriptName
|
|
16
16
|
* prefix so a developer can never read another tenant's logs.
|
|
@@ -26,5 +26,7 @@ export interface FunctionsLogsOptions {
|
|
|
26
26
|
tail?: boolean;
|
|
27
27
|
/** NDJSON output. */
|
|
28
28
|
json?: boolean;
|
|
29
|
+
/** Only show events whose log/exception text mentions this request id (`r_...`). */
|
|
30
|
+
requestId?: string;
|
|
29
31
|
}
|
|
30
32
|
export declare function functionsLogsCommand(functionName: string, options?: FunctionsLogsOptions): Promise<void>;
|
|
@@ -9,8 +9,19 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { type RateLimitConfig } from '../_internal/shared.js';
|
|
11
11
|
export interface DeployOptions {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Override the function name. Default: when a file is deployed, the
|
|
14
|
+
* filename without extension; when a directory is deployed, the
|
|
15
|
+
* directory's leaf name (NOT the resolved `index` entry's name).
|
|
16
|
+
*/
|
|
13
17
|
name?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Entry file when the deploy target is a DIRECTORY (relative to it).
|
|
20
|
+
* Only valid with a directory target; ignored for single-file deploys.
|
|
21
|
+
* When omitted, a directory resolves its entry by convention
|
|
22
|
+
* (`index.ts` / `index.js` / `index.mjs`).
|
|
23
|
+
*/
|
|
24
|
+
entry?: string;
|
|
14
25
|
/** Print bundle report but skip the CF API + DB write. Useful for size triage. */
|
|
15
26
|
dryRun?: boolean;
|
|
16
27
|
/**
|
|
@@ -23,8 +34,16 @@ export interface DeployOptions {
|
|
|
23
34
|
rateLimitWindow?: string;
|
|
24
35
|
rateLimitMax?: number;
|
|
25
36
|
rateLimitKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Opt-in public flag (#17). Deploy the function WITHOUT the X-Api-Key
|
|
39
|
+
* gate so third-party webhook senders (Stripe, RevenueCat, GitHub,
|
|
40
|
+
* Slack) that can't attach a custom header can reach it. Default false
|
|
41
|
+
* (private). The customer MUST verify the webhook HMAC signature inside
|
|
42
|
+
* the handler — public skips the credential gate only.
|
|
43
|
+
*/
|
|
44
|
+
public?: boolean;
|
|
26
45
|
}
|
|
27
|
-
export declare function functionsDeployCommand(
|
|
46
|
+
export declare function functionsDeployCommand(target: string, options?: DeployOptions): Promise<void>;
|
|
28
47
|
export declare function functionsListCommand(): Promise<void>;
|
|
29
48
|
export declare function functionsDeleteCommand(name: string, options?: {
|
|
30
49
|
confirm?: string;
|
|
@@ -55,11 +74,12 @@ export interface DevOptions {
|
|
|
55
74
|
* — externalization rules, size cap, and source-map handling are
|
|
56
75
|
* identical so dev → prod parity is automatic.
|
|
57
76
|
*
|
|
58
|
-
* Handler shape: `export default async
|
|
77
|
+
* Handler shape: `export default { async fetch(req, env, ctx) { ... } }`.
|
|
59
78
|
* `.env.local` values in the customer's working directory are passed
|
|
60
|
-
* through to the child process
|
|
61
|
-
*
|
|
62
|
-
*
|
|
79
|
+
* through to the child process and bridged into the `env` parameter so
|
|
80
|
+
* the handler reads them the same way as in production (`env.MY_KEY`).
|
|
81
|
+
* Existing values in the parent's env take priority (so
|
|
82
|
+
* `MY_KEY=x amba functions dev …` wins).
|
|
63
83
|
*/
|
|
64
84
|
export declare function functionsDevCommand(entryPoint: string, options?: DevOptions): Promise<void>;
|
|
65
85
|
/**
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `amba apply` / `amba diff` / `amba export` — declarative
|
|
3
|
+
* infrastructure-as-code for a project's reusable configuration.
|
|
4
|
+
*
|
|
5
|
+
* A declarative bundle (default `amba.config.json`) captures the entities a
|
|
6
|
+
* developer hand-builds once and wants to stand up identically elsewhere:
|
|
7
|
+
* remote configs, collection schemas, content libraries + items, currencies,
|
|
8
|
+
* achievements, streaks, challenges, leaderboards, and xp_rules. It carries
|
|
9
|
+
* CONFIGURATION ONLY — no secrets, no per-user data.
|
|
10
|
+
*
|
|
11
|
+
* These commands wrap the platform's promotion endpoints:
|
|
12
|
+
* GET /v1/admin/projects/:p/promotion/export
|
|
13
|
+
* POST /v1/admin/projects/:p/promotion/import (mode=skip_existing|merge)
|
|
14
|
+
*
|
|
15
|
+
* - `amba export [file]` writes the current project's bundle to disk.
|
|
16
|
+
* - `amba apply [file]` POSTs the local bundle to the import endpoint and
|
|
17
|
+
* prints a `{ created, updated, skipped }` summary
|
|
18
|
+
* per section (the server's authoritative result).
|
|
19
|
+
* - `amba diff [file]` shows what `apply` WOULD change without writing.
|
|
20
|
+
* The import route has NO server-side dry-run, so
|
|
21
|
+
* `diff` exports the current project and computes the
|
|
22
|
+
* created/updated/skipped per section LOCALLY.
|
|
23
|
+
*/
|
|
24
|
+
import { type PromotionBundleWire, type PromotionImportMode } from '../api-client.js';
|
|
25
|
+
/** Default declarative bundle filename when no `[file]` is passed. */
|
|
26
|
+
export declare const DEFAULT_BUNDLE_FILE = "amba.config.json";
|
|
27
|
+
export interface ApplyOptions {
|
|
28
|
+
project?: string;
|
|
29
|
+
/** `skip_existing` (default) no-ops on conflict; `merge` refreshes. */
|
|
30
|
+
mode?: PromotionImportMode;
|
|
31
|
+
}
|
|
32
|
+
export interface DiffOptions {
|
|
33
|
+
project?: string;
|
|
34
|
+
mode?: PromotionImportMode;
|
|
35
|
+
}
|
|
36
|
+
export interface ExportOptions {
|
|
37
|
+
project?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Per-section, per-key diff outcome. */
|
|
40
|
+
export interface SectionDiff {
|
|
41
|
+
created: number;
|
|
42
|
+
updated: number;
|
|
43
|
+
skipped: number;
|
|
44
|
+
}
|
|
45
|
+
export type LocalDiff = Record<string, SectionDiff>;
|
|
46
|
+
/**
|
|
47
|
+
* Read + parse a declarative bundle from disk. JSON only — we deliberately
|
|
48
|
+
* don't pull in a YAML dependency the CLI doesn't already ship (the package
|
|
49
|
+
* has no YAML lib), so `.yaml`/`.yml` files are rejected with a clear hint
|
|
50
|
+
* rather than silently mis-parsed.
|
|
51
|
+
*/
|
|
52
|
+
export declare function readBundleFile(file: string): Promise<PromotionBundleWire>;
|
|
53
|
+
/**
|
|
54
|
+
* Pure section-by-section diff of a desired bundle against the current
|
|
55
|
+
* project's exported bundle. The classification MIRRORS the server's import
|
|
56
|
+
* (`apps/api/src/lib/promotion-bundle.ts`) so `amba diff` agrees with what
|
|
57
|
+
* `amba apply` will report:
|
|
58
|
+
* - created — natural key absent in current.
|
|
59
|
+
* - updated — natural key present AND `mode === 'merge'`. The server runs an
|
|
60
|
+
* UNCONDITIONAL update for every existing key in merge mode and
|
|
61
|
+
* increments `updated` — it does NOT compare field values, so we
|
|
62
|
+
* don't either (a local field comparison made `diff` under-report).
|
|
63
|
+
* - skipped — natural key present under `skip_existing`; OR an existing
|
|
64
|
+
* collection (always — collections are create-if-absent, never
|
|
65
|
+
* merged); OR a `remote_configs` row flagged `is_system: true`
|
|
66
|
+
* (the server always skips those before any existence check); OR
|
|
67
|
+
* a desired row with no valid natural key (can't be matched
|
|
68
|
+
* against the export, and the server import dedups by that key —
|
|
69
|
+
* so it is never a reliable create).
|
|
70
|
+
*
|
|
71
|
+
* Within one bundle section, the server walks rows sequentially and each
|
|
72
|
+
* insert mutates the DB, so a SECOND row sharing a natural key already created
|
|
73
|
+
* by an EARLIER row in the same section is seen as existing (→ skip under
|
|
74
|
+
* skip_existing, update under merge) rather than created a second time. We
|
|
75
|
+
* track already-seen keys per section to mirror that, so duplicate-keyed local
|
|
76
|
+
* rows don't inflate the `created` total versus what `apply` does.
|
|
77
|
+
*/
|
|
78
|
+
export declare function computeLocalDiff(desired: PromotionBundleWire, current: PromotionBundleWire, mode: PromotionImportMode): LocalDiff;
|
|
79
|
+
declare function totalOf(s: {
|
|
80
|
+
created: number;
|
|
81
|
+
updated: number;
|
|
82
|
+
skipped: number;
|
|
83
|
+
}): number;
|
|
84
|
+
/** Roll a per-section diff up into grand totals across every section. */
|
|
85
|
+
export declare function summarizeDiff(diff: Record<string, SectionDiff>): SectionDiff;
|
|
86
|
+
/**
|
|
87
|
+
* `amba export [file]` — write the current project's declarative bundle to
|
|
88
|
+
* disk so it can be checked in, diffed, and re-applied.
|
|
89
|
+
*/
|
|
90
|
+
export declare function exportConfigCommand(file?: string, options?: ExportOptions): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* `amba apply [file]` — read a local declarative bundle and POST it to the
|
|
93
|
+
* import endpoint. Prints the server's authoritative `{ created, updated,
|
|
94
|
+
* skipped }` per section.
|
|
95
|
+
*/
|
|
96
|
+
export declare function applyConfigCommand(file?: string, options?: ApplyOptions): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* `amba diff [file]` — show what `apply` WOULD change without writing.
|
|
99
|
+
*
|
|
100
|
+
* The import route has no server-side dry-run, so this fetches the current
|
|
101
|
+
* project's exported bundle and computes the diff LOCALLY. Output mirrors the
|
|
102
|
+
* `apply` summary shape so the two read identically.
|
|
103
|
+
*/
|
|
104
|
+
export declare function diffConfigCommand(file?: string, options?: DiffOptions): Promise<void>;
|
|
105
|
+
/** Test-only re-export of internal helpers. Not a public API. */
|
|
106
|
+
export declare const __testHelpers: {
|
|
107
|
+
computeLocalDiff: typeof computeLocalDiff;
|
|
108
|
+
summarizeDiff: typeof summarizeDiff;
|
|
109
|
+
readBundleFile: typeof readBundleFile;
|
|
110
|
+
BUNDLE_SECTIONS: readonly {
|
|
111
|
+
key: string;
|
|
112
|
+
naturalKey: string;
|
|
113
|
+
}[];
|
|
114
|
+
totalOf: typeof totalOf;
|
|
115
|
+
};
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `amba monetization *` subcommands — CLI access to the monetization control
|
|
3
|
+
* plane behind `/v1/admin/projects/:id/monetization/*`.
|
|
4
|
+
*
|
|
5
|
+
* amba monetization plan — three-way diff (declared vs adopted baseline
|
|
6
|
+
* vs live provider) + store-floor preflight +
|
|
7
|
+
* drift. READ-ONLY — previews; applies nothing.
|
|
8
|
+
* amba monetization drift — out-of-band changes to Amba-managed objects.
|
|
9
|
+
* amba monetization export — snapshot the live config to a declarative
|
|
10
|
+
* bundle (the `monetization` section), to stdout
|
|
11
|
+
* or a file.
|
|
12
|
+
* amba monetization adopt — record the live config as the managed baseline
|
|
13
|
+
* so the next plan is a no-op. Writes ONLY Amba's
|
|
14
|
+
* own state — never the provider. Idempotent.
|
|
15
|
+
* amba monetization apply — push the declared config to the provider.
|
|
16
|
+
* ADDITIVE only: create entitlements/offerings/
|
|
17
|
+
* packages/paywall-drafts + attach products.
|
|
18
|
+
* Refuses if the provider drifted since the plan;
|
|
19
|
+
* never does destructive changes.
|
|
20
|
+
*
|
|
21
|
+
* Project is resolved via `loadProjectConfig` — same pattern as the other
|
|
22
|
+
* project-scoped CLI commands.
|
|
23
|
+
*/
|
|
24
|
+
export declare function monetizationPlanCommand(): Promise<void>;
|
|
25
|
+
export declare function monetizationDriftCommand(): Promise<void>;
|
|
26
|
+
export declare function monetizationExportCommand(options?: {
|
|
27
|
+
file?: string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
export declare function monetizationAdoptCommand(options?: {
|
|
30
|
+
all?: boolean;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export declare function monetizationApplyCommand(options?: {
|
|
33
|
+
confirm?: boolean;
|
|
34
|
+
allowDetachLive?: boolean;
|
|
35
|
+
reconcile?: string;
|
|
36
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `amba payments *` subcommands — CLI access to the Amba Payments (Stripe
|
|
3
|
+
* Connect platform) surface at `/v1/admin/projects/:id/payments/*`
|
|
4
|
+
* (tracker #10).
|
|
5
|
+
*
|
|
6
|
+
* Amba is the payments rail for the developer's app: the app is the seller,
|
|
7
|
+
* Amba takes a platform fee, Stripe carries money-transmission. This is the
|
|
8
|
+
* developer-facing onboarding + config + reporting surface, so naming Stripe
|
|
9
|
+
* here is by intent (same as `amba billing`).
|
|
10
|
+
*
|
|
11
|
+
* amba payments setup — create the connected account +
|
|
12
|
+
* print the hosted onboarding URL.
|
|
13
|
+
* amba payments status — onboarding stage + capability flags.
|
|
14
|
+
* amba payments set-fee <bps|off> — default platform fee (basis points).
|
|
15
|
+
* amba payments balance — connected-account balance.
|
|
16
|
+
* amba payments payouts — recent payouts.
|
|
17
|
+
*
|
|
18
|
+
* Every live call is gated by the platform's PAYMENTS_CONNECT_LIVE
|
|
19
|
+
* kill-switch — when off the API returns PAYMENTS_NOT_ENABLED, surfaced
|
|
20
|
+
* verbatim here. Project resolved via loadProjectConfig (same as billing).
|
|
21
|
+
*/
|
|
22
|
+
export declare function paymentsSetupCommand(input: {
|
|
23
|
+
country?: string;
|
|
24
|
+
email?: string;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export declare function paymentsStatusCommand(): Promise<void>;
|
|
27
|
+
export declare function paymentsSetFeeCommand(input: {
|
|
28
|
+
bps: number | null;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
export declare function paymentsBalanceCommand(): Promise<void>;
|
|
31
|
+
export declare function paymentsPayoutsCommand(input: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
}): Promise<void>;
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `amba secrets ...` — write
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* `amba secrets ...` — write secrets through the platform API. The CLI
|
|
3
|
+
* sends `{name, value, function?}` to the admin endpoint; the server
|
|
4
|
+
* stores the value, validates reserved binding names, and propagates it to
|
|
5
|
+
* the deployed Worker binding(s). Sync is eventual — `amba secrets list`
|
|
6
|
+
* shows progress.
|
|
7
|
+
*
|
|
8
|
+
* Two scopes:
|
|
9
|
+
* - `--function <name>` → the secret binds to that one function.
|
|
10
|
+
* - no `--function` → a PROJECT-WIDE secret, visible to every
|
|
11
|
+
* function in the project (and to any function deployed later). Set it
|
|
12
|
+
* once instead of repeating the same value per function.
|
|
13
|
+
*
|
|
14
|
+
* Secrets may be set BEFORE the function is deployed. The sync drains once
|
|
15
|
+
* a deployment lands (and `amba functions deploy` re-syncs at the end).
|
|
7
16
|
*/
|
|
8
17
|
export interface SecretsSetOptions {
|
|
9
|
-
/**
|
|
10
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Function the secret binds to. Omit for a PROJECT-WIDE secret (applied
|
|
20
|
+
* to every function in the project, including ones deployed later).
|
|
21
|
+
*/
|
|
22
|
+
function?: string;
|
|
11
23
|
/**
|
|
12
24
|
* Environment selector. Currently informational: both `dev` and `prod`
|
|
13
25
|
* write to the same secret namespace per project. Workarounds:
|
|
@@ -23,7 +35,15 @@ export interface SecretsSetOptions {
|
|
|
23
35
|
fromStdin?: boolean;
|
|
24
36
|
}
|
|
25
37
|
export declare function secretsSetCommand(name: string, value: string | undefined, options: SecretsSetOptions): Promise<void>;
|
|
26
|
-
export
|
|
38
|
+
export interface SecretsListOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Filter to secrets for a single function. Without this, all secrets
|
|
41
|
+
* across all functions in the project are listed — noisy when a
|
|
42
|
+
* project has 10+ functions.
|
|
43
|
+
*/
|
|
44
|
+
function?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function secretsListCommand(options?: SecretsListOptions): Promise<void>;
|
|
27
47
|
export declare function secretsUnsetCommand(name: string, options: {
|
|
28
|
-
function
|
|
48
|
+
function?: string;
|
|
29
49
|
}): Promise<void>;
|