@velajs/cloudflare 1.32.0 → 1.34.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/CHANGELOG.md +46 -0
- package/README.md +198 -1
- package/dist/_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js +9 -0
- package/dist/bindings.js +25 -1
- package/dist/bindings.js.map +1 -1
- package/dist/{cloudflare-application-CXDy9C1R.d.ts → cloudflare-application-Dsscb3Mo.d.ts} +2 -2
- package/dist/{cloudflare-factory-CuFNUJJD.d.ts → cloudflare-factory-DM9CBvNH.d.ts} +5 -5
- package/dist/durable-objects.d.ts +1 -1
- package/dist/email.d.ts +1 -1
- package/dist/entrypoints.d.ts +1 -1
- package/dist/index.d.ts +27 -12
- package/dist/index.js +2 -2
- package/dist/pipelines.d.ts +20 -0
- package/dist/pipelines.js +87 -0
- package/dist/pipelines.js.map +1 -0
- package/dist/queue-events/consume.js +120 -0
- package/dist/queue-events/consume.js.map +1 -0
- package/dist/queue-events.d.ts +71 -0
- package/dist/queue-events.js +2 -0
- package/dist/services/flagship-flag.driver.js +64 -6
- package/dist/services/flagship-flag.driver.js.map +1 -1
- package/dist/services/kv-cache.store.js +4 -4
- package/dist/services/kv-cache.store.js.map +1 -1
- package/dist/tail.d.ts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/tracing.d.ts +15 -0
- package/dist/tracing.js +24 -0
- package/dist/tracing.js.map +1 -0
- package/dist/websocket/binding-gateways.js +1 -1
- package/dist/websocket/binding-gateways.js.map +1 -1
- package/dist/workflows.d.ts +1 -1
- package/package.json +21 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.34.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2c61e5b: Unify Wrangler binding discovery across resource addition, configuration sync and deployment checks. Cover current native binding shapes, detect cross-kind name collisions, respect environment inheritance exceptions, and preserve unknown configuration. Known malformed bindings now fail before resource creation or config edits.
|
|
8
|
+
|
|
9
|
+
Add `vela add binding <kind> <BINDING> --options <JSON>` for native JSON/JSONC declarations without provisioning resources or adding modules. Selected-environment type generation now calls Wrangler with `--env` instead of running an unqualified types script.
|
|
10
|
+
|
|
11
|
+
Expose `flagship({ binding })` and `secretsStoreSecret({ binding })` native references from `@velajs/cloudflare`, resolving the original handle separately for each environment without caching values.
|
|
12
|
+
- 3cc469d: Preserve native Flagship evaluation reasons, variants and error codes through optional driver detail methods and Studio responses. Value-only providers now report UNKNOWN instead of STATIC; native context accepts only scalar attributes, and route guards deny all evaluation errors. Existing object-validation callback signatures are unchanged.
|
|
13
|
+
|
|
14
|
+
Add the optional crypto/cloudflare SecretsStoreKeyProvider for immutable, versioned AES-KW key material, with explicit per-instance caching, refresh, retry and rotation using retained decryption keys. Secrets Store supplies material for local Web Crypto; it is not a remote KMS.
|
|
15
|
+
- 9ebb189: Add the optional `@velajs/cloudflare/queue-events` subpath for Cloudflare platform event subscriptions inside existing `@QueueConsumer` handlers. Validate the documented versioned envelope, source/account/subscription expectations and Standard Schema payloads before awaiting explicit handlers. Acknowledge each success individually and request native retries for malformed, unmatched or failing messages while preserving partial-batch progress and DLQ behavior. Include a Worker build example, native delivery identity, idempotency and producer trust guidance, and workerd coverage separate from signed Vela job dispatch.
|
|
16
|
+
- f1c7be8: Add the optional `@velajs/cloudflare/pipelines` writer with Standard Schema producer validation, schema transform inference, strict JSON snapshots, and UTF-8 ingestion payload limits. Validate the entire batch before awaiting one native stream send, preserving the configured binding and its ingestion-only guarantees.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 5314b4e: Add the optional `/tracing` entrypoint with `CloudflareTracingInterceptor` for
|
|
21
|
+
native Workers spans around awaited HTTP and service RPC handler work. Span
|
|
22
|
+
names are fixed and labels contain only bounded class and method names.
|
|
23
|
+
- Updated dependencies [3cc469d]
|
|
24
|
+
- @velajs/feature-flags@1.32.0
|
|
25
|
+
|
|
26
|
+
## 1.33.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- b7d0725: Remove obsolete contracts and backward-compatibility paths.
|
|
31
|
+
|
|
32
|
+
Validation now requires Standard Schema or DTO descriptors. Decorated events require event definitions and use EventDispatcher; EventEmitter.emit always settles every matching callback. Remove token-only discovery, instance-based schedule views, ownerless entrypoints, disposed-container reuse, unmanaged scope finalization, and the `(.*)` middleware alias. Queue driver bind returns cleanup and enqueue after inline disposal rejects. Configure HTTP body caps through security.body.maxBytes.
|
|
33
|
+
|
|
34
|
+
WebSocket clients must report admission with trySendRaw. Tiered caches require expiry-aware read/write methods; KV entries without expiry metadata miss. Aggregate specs use only aggregations, the default CRUD adapter can be undefined, and Studio discovers resources registered through Crud. Remove the Studio path alias, the mail envelope argument overload, the AI embedding resolver fallback, and the obsolete contentHash export.
|
|
35
|
+
|
|
36
|
+
Storage encryption rejects invalid ciphertext; compression requires format metadata and a metadata-capable store.
|
|
37
|
+
|
|
38
|
+
Update adapters, examples, tests, API snapshots and migration documentation to the current contracts.
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [b7d0725]
|
|
43
|
+
- Updated dependencies [b7d0725]
|
|
44
|
+
- @velajs/vela@1.33.0
|
|
45
|
+
- @velajs/testing@1.33.0
|
|
46
|
+
- @velajs/storage@1.33.0
|
|
47
|
+
- @velajs/feature-flags@1.31.0
|
|
48
|
+
|
|
3
49
|
## 1.32.0
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -287,6 +287,78 @@ handlers still need the idempotency appropriate to their delivery semantics.
|
|
|
287
287
|
See [execution scopes](../../docs/execution-scopes.md) for lifetime ownership,
|
|
288
288
|
stream boundaries, cancellation and optional transport integration.
|
|
289
289
|
|
|
290
|
+
## Native handler tracing
|
|
291
|
+
|
|
292
|
+
Import `CloudflareTracingInterceptor` from the optional
|
|
293
|
+
`@velajs/cloudflare/tracing` entrypoint and register it on HTTP controllers or
|
|
294
|
+
`VelaEntrypoint` hosts with `@UseInterceptors`. It uses the native
|
|
295
|
+
`cloudflare:workers` tracing API; the package root does not import it.
|
|
296
|
+
|
|
297
|
+
```ts
|
|
298
|
+
import { Controller, Get, Injectable, Module, UseInterceptors } from '@velajs/vela';
|
|
299
|
+
import { defineCloudflareApp } from '@velajs/cloudflare';
|
|
300
|
+
import { VelaEntrypoint } from '@velajs/cloudflare/entrypoints';
|
|
301
|
+
import { CloudflareTracingInterceptor } from '@velajs/cloudflare/tracing';
|
|
302
|
+
|
|
303
|
+
@Controller('/status')
|
|
304
|
+
@UseInterceptors(CloudflareTracingInterceptor)
|
|
305
|
+
class StatusController {
|
|
306
|
+
@Get()
|
|
307
|
+
async read() {
|
|
308
|
+
return { ready: true };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
@Injectable()
|
|
313
|
+
@UseInterceptors(CloudflareTracingInterceptor)
|
|
314
|
+
class StatusHost {
|
|
315
|
+
async read() {
|
|
316
|
+
return { ready: true };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@Module({ controllers: [StatusController] })
|
|
321
|
+
class AppModule {}
|
|
322
|
+
|
|
323
|
+
const app = defineCloudflareApp(AppModule);
|
|
324
|
+
export class Status extends VelaEntrypoint(app, StatusHost, { rpc: ['read'] }) {}
|
|
325
|
+
export default app.worker;
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Enable traces in Wrangler and choose an application sampling rate:
|
|
329
|
+
|
|
330
|
+
```toml
|
|
331
|
+
[observability.traces]
|
|
332
|
+
enabled = true
|
|
333
|
+
head_sampling_rate = 1
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
The interceptor calls `next.handle()` inside `tracing.enterSpan()` and returns
|
|
337
|
+
its promise. Native child spans and awaited platform calls run within that
|
|
338
|
+
callback's async context. Cloudflare owns sampling, span completion and export,
|
|
339
|
+
including its service RPC transport instrumentation. Unsampled calls still run
|
|
340
|
+
normally. Use a Workers runtime with the
|
|
341
|
+
[native custom-span API](https://developers.cloudflare.com/workers/observability/traces/custom-spans/).
|
|
342
|
+
|
|
343
|
+
Span names are fixed: `vela.http.handler` and `vela.rpc.handler`. Sampled spans
|
|
344
|
+
add only `vela.handler.class` and `vela.handler.method`, each limited to 128
|
|
345
|
+
characters. Symbol method names are omitted. Labels use runtime names, which
|
|
346
|
+
may change with minification. No request values, arguments, errors, identifiers,
|
|
347
|
+
HTTP status or outcome attributes are added by this interceptor. Other execution
|
|
348
|
+
kinds pass through without a span.
|
|
349
|
+
|
|
350
|
+
The span covers the handler and inner interceptors until their returned promise
|
|
351
|
+
settles. Guards and pipes run earlier; response streams, deferred work and scope
|
|
352
|
+
disposal can outlive it. This integration does not implement Vela's portable
|
|
353
|
+
`Telemetry` interface or expose parent selection, span IDs or trace-header
|
|
354
|
+
propagation. See [observability](../../docs/observability.md) for that separate API.
|
|
355
|
+
|
|
356
|
+
The workerd tests exercise nested HTTP/RPC and KV calls, concurrent environments,
|
|
357
|
+
errors and disabled sampling. They do not inspect exported span trees or assert
|
|
358
|
+
parent IDs. Inspect sampled traces with Wrangler's
|
|
359
|
+
[local tracing tools](https://developers.cloudflare.com/changelog/post/2026-08-04-local-tracing/)
|
|
360
|
+
when verifying the runtime's exported hierarchy.
|
|
361
|
+
|
|
290
362
|
## Typed provider factories
|
|
291
363
|
|
|
292
364
|
Bindings retain their full native API and generic parameters. There are no
|
|
@@ -316,6 +388,15 @@ Use native `env.DB`, `env.CACHE`, `env.FILES`, `env.JOBS`, `env.AI`,
|
|
|
316
388
|
(`@InjectEnv()`) and factories (`inject: [ENV]`); it works the same in HTTP,
|
|
317
389
|
queue, cron and Durable Object code.
|
|
318
390
|
|
|
391
|
+
## Platform event subscriptions
|
|
392
|
+
|
|
393
|
+
`@velajs/cloudflare/queue-events` composes inside `@QueueConsumer` to validate
|
|
394
|
+
Cloudflare event subscription envelopes and Standard Schema payloads. It awaits
|
|
395
|
+
explicit handlers, acknowledges each success and retries failed messages through
|
|
396
|
+
the native queue policy. Use a dedicated queue with trusted producer permissions;
|
|
397
|
+
metadata checks are not authentication and duplicate deliveries require consumer
|
|
398
|
+
idempotency. See the [Worker build example and settlement guide](../../docs/cloudflare-queue-events.md).
|
|
399
|
+
|
|
319
400
|
## Queues and cron
|
|
320
401
|
|
|
321
402
|
```ts
|
|
@@ -567,7 +648,8 @@ application that fails to start is logged to the console instead. See
|
|
|
567
648
|
## Bindings by name
|
|
568
649
|
|
|
569
650
|
Module options name a binding instead of holding it. `kv`, `r2`, `d1`,
|
|
570
|
-
`queue`, `durableObject`, `rateLimit
|
|
651
|
+
`queue`, `durableObject`, `rateLimit`, `workflow`, `flagship` and
|
|
652
|
+
`secretsStoreSecret` each take `{ binding }`, the name
|
|
571
653
|
declared in the Wrangler configuration, and read nothing when declared: calling
|
|
572
654
|
the reference with an application's `ENV` returns the typed native binding, or
|
|
573
655
|
fails naming the binding and the Wrangler key that declares it
|
|
@@ -575,6 +657,37 @@ fails naming the binding and the Wrangler key that declares it
|
|
|
575
657
|
The drivers and stores below are built on them, so one static module graph
|
|
576
658
|
serves every environment.
|
|
577
659
|
|
|
660
|
+
`flagship` returns the native `Flagship` handle, including typed value and detail
|
|
661
|
+
methods. `secretsStoreSecret` returns a native `SecretsStoreSecret` handle; call
|
|
662
|
+
`get()` to read its current value. References perform structural checks only:
|
|
663
|
+
they do not read secrets, evaluate flags, cache results, create resources or prove
|
|
664
|
+
remote availability. Native method errors and local-development behavior are
|
|
665
|
+
unchanged. Use current generated Wrangler types or Workers types containing
|
|
666
|
+
these native interfaces (validated with Wrangler 4.135.0 and Workers types
|
|
667
|
+
5.20260920.1).
|
|
668
|
+
|
|
669
|
+
```ts
|
|
670
|
+
import { flagship, secretsStoreSecret } from '@velajs/cloudflare';
|
|
671
|
+
|
|
672
|
+
const flags = flagship({ binding: 'FLAGS' });
|
|
673
|
+
const apiKey = secretsStoreSecret({ binding: 'API_KEY' });
|
|
674
|
+
|
|
675
|
+
// In request/application scope, using that application's environment:
|
|
676
|
+
async function readSettings(env: Env) {
|
|
677
|
+
const enabled = await flags(env).getBooleanValue('new-layout', false);
|
|
678
|
+
const key = await apiKey(env).get();
|
|
679
|
+
return { enabled, key };
|
|
680
|
+
}
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
Declare `FLAGS` under `flagship` with an `app_id`, and `API_KEY` under
|
|
684
|
+
`secrets_store_secrets` with a `store_id` and `secret_name`, separately for each
|
|
685
|
+
named environment. `vela add binding` can write those config declarations;
|
|
686
|
+
resource setup remains explicit. See Cloudflare's [Flagship binding API](https://developers.cloudflare.com/flagship/binding/)
|
|
687
|
+
and [Secrets Store Workers integration](https://developers.cloudflare.com/secrets-store/integrations/workers/)
|
|
688
|
+
for native methods and local setup. In particular, local Secrets Store values
|
|
689
|
+
are separate from production secrets.
|
|
690
|
+
|
|
578
691
|
## Rate limiting
|
|
579
692
|
|
|
580
693
|
`ThrottlerModule` from `@velajs/vela/throttler` counts through Workers Rate
|
|
@@ -724,6 +837,90 @@ it('processes a created todo', async () => {
|
|
|
724
837
|
|
|
725
838
|
The subpath is not part of any Worker bundle: import it from tests only.
|
|
726
839
|
|
|
840
|
+
## Validated Pipelines producers
|
|
841
|
+
|
|
842
|
+
`@velajs/cloudflare/pipelines` adds producer validation to a configured native
|
|
843
|
+
stream handle. It is an optional adapter subpath: there is no module, queue
|
|
844
|
+
driver, or replacement for the native Pipelines API.
|
|
845
|
+
|
|
846
|
+
Configure the stream in Wrangler and regenerate your environment types:
|
|
847
|
+
|
|
848
|
+
```jsonc
|
|
849
|
+
{
|
|
850
|
+
"pipelines": [{ "binding": "EVENT_STREAM", "stream": "<STREAM_ID>" }],
|
|
851
|
+
}
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
Use a Standard Schema validator whose **output** matches the deployed stream
|
|
855
|
+
schema. Synchronous and asynchronous transforms are supported; `send()` takes
|
|
856
|
+
schema **inputs** and sends the validated outputs:
|
|
857
|
+
|
|
858
|
+
```ts
|
|
859
|
+
import { ENV, InjectionToken, defineProvider } from '@velajs/vela';
|
|
860
|
+
import { createPipelinesWriter, type PipelinesWriter } from '@velajs/cloudflare/pipelines';
|
|
861
|
+
import { z } from 'zod';
|
|
862
|
+
|
|
863
|
+
const event = z.object({
|
|
864
|
+
id: z.string().min(1),
|
|
865
|
+
count: z.string().regex(/^\d+$/).transform(Number).pipe(z.number().int().nonnegative()),
|
|
866
|
+
});
|
|
867
|
+
|
|
868
|
+
export const EVENTS = new InjectionToken<PipelinesWriter<z.input<typeof event>>>('events');
|
|
869
|
+
|
|
870
|
+
// Add this provider to your application's providers. ENV and the writer belong
|
|
871
|
+
// to that application; do not capture a request's environment at module scope.
|
|
872
|
+
export const eventsProvider = defineProvider(EVENTS, {
|
|
873
|
+
inject: [ENV],
|
|
874
|
+
useFactory: (env) => createPipelinesWriter(env.EVENT_STREAM, { schema: event }),
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
// In a provider that injects EVENTS:
|
|
878
|
+
// await this.events.send([{ id: 'sample-1', count: '2' }]);
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
The factory also works directly with `createPipelinesWriter(env.EVENT_STREAM,
|
|
882
|
+
{ schema: event })`. The binding is structural (`send(records): Promise<void>`),
|
|
883
|
+
remains available as `env.EVENT_STREAM`, and needs no `cloudflare:pipelines`
|
|
884
|
+
runtime import. Generated `Pipeline<RecordType>` bindings check schema output
|
|
885
|
+
compatibility at compile time. Select the stream through trusted configuration;
|
|
886
|
+
the writer does not accept a stream name or endpoint from a record or request.
|
|
887
|
+
|
|
888
|
+
Each nonempty `send(records)` validates all records before making one native
|
|
889
|
+
call. A failure rejects without sending any records; validation may stop at the
|
|
890
|
+
first error. Standard Schema failures use `SchemaValidationError` from
|
|
891
|
+
`@velajs/vela/validation`, with the record index prefixed to each issue path.
|
|
892
|
+
Validator exceptions and native failures propagate. There is no automatic retry,
|
|
893
|
+
batch splitting, rate limiter, or buffering. Empty batches reject.
|
|
894
|
+
|
|
895
|
+
After schema transforms, each record must be a plain JSON object. Nested objects
|
|
896
|
+
and dense arrays may contain strings, booleans, null, and finite numbers. The
|
|
897
|
+
writer rejects undefined values (including explicitly undefined optional fields),
|
|
898
|
+
functions, symbols, bigint, non-finite numbers, cycles, class instances, `Date`,
|
|
899
|
+
`Map`, `Set`, typed arrays, getters, non-enumerable or symbol properties, extra
|
|
900
|
+
array properties, and `toJSON` functions. Convert special values in your schema.
|
|
901
|
+
Validated outputs are copied before the next asynchronous validation, so later
|
|
902
|
+
mutations cannot alter already checked records. Callers must not mutate inputs
|
|
903
|
+
while their schema is validating them.
|
|
904
|
+
|
|
905
|
+
The writer measures the UTF-8 encoding of compact JSON outputs, including escapes,
|
|
906
|
+
commas and array brackets, against a conservative **5,000,000-byte request
|
|
907
|
+
ceiling**. A single record must fit inside that same JSON array (at most
|
|
908
|
+
4,999,998 bytes). The current [Cloudflare limits](https://developers.cloudflare.com/pipelines/platform/limits/)
|
|
909
|
+
document 5 MB per ingestion request without a separate record size cap; this
|
|
910
|
+
adapter does not invent one. Oversize records or batches reject with `RangeError`;
|
|
911
|
+
non-JSON output rejects with `TypeError`.
|
|
912
|
+
|
|
913
|
+
`send()` resolves to `void` only after native ingestion acceptance. Cloudflare
|
|
914
|
+
[accepts but later drops invalid structured events](https://developers.cloudflare.com/pipelines/streams/writing-to-streams/#schema-validation),
|
|
915
|
+
so keep your producer schema aligned with the configured stream. Resolution
|
|
916
|
+
provides no query visibility, transaction, application exactly-once, or terminal
|
|
917
|
+
storage guarantee. A failed native request may have reached the service; any
|
|
918
|
+
retry and deduplication policy belongs to the application.
|
|
919
|
+
|
|
920
|
+
Tests cover producer behavior and native type compatibility. Workerd tests also
|
|
921
|
+
exercise Miniflare's local Pipelines binding, whose `send()` is a no-op; they
|
|
922
|
+
provide no remote ingestion, schema enforcement, or downstream storage proof.
|
|
923
|
+
|
|
727
924
|
## Development
|
|
728
925
|
|
|
729
926
|
From the repository root:
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { __decorate as default };
|
package/dist/bindings.js
CHANGED
|
@@ -87,7 +87,31 @@ function workflow(ref) {
|
|
|
87
87
|
accepts: (value) => hasOperations(value, ["create", "get"])
|
|
88
88
|
})(ref);
|
|
89
89
|
}
|
|
90
|
+
/** A native Flagship binding declared under `flagship`. No flag values are cached. */
|
|
91
|
+
const FLAGSHIP = {
|
|
92
|
+
name: "Flagship",
|
|
93
|
+
configKey: "flagship",
|
|
94
|
+
accepts: (value) => hasOperations(value, [
|
|
95
|
+
"get",
|
|
96
|
+
"getBooleanValue",
|
|
97
|
+
"getStringValue",
|
|
98
|
+
"getNumberValue",
|
|
99
|
+
"getObjectValue",
|
|
100
|
+
"getBooleanDetails",
|
|
101
|
+
"getStringDetails",
|
|
102
|
+
"getNumberDetails",
|
|
103
|
+
"getObjectDetails"
|
|
104
|
+
])
|
|
105
|
+
};
|
|
106
|
+
const flagship = /* @__PURE__ */ defineBinding(FLAGSHIP);
|
|
107
|
+
/** A secret handle declared under `secrets_store_secrets`; resolve its value with `get()`. */
|
|
108
|
+
const SECRETS_STORE_SECRET = {
|
|
109
|
+
name: "Secrets Store secret",
|
|
110
|
+
configKey: "secrets_store_secrets",
|
|
111
|
+
accepts: (value) => hasOperations(value, ["get"])
|
|
112
|
+
};
|
|
113
|
+
const secretsStoreSecret = /* @__PURE__ */ defineBinding(SECRETS_STORE_SECRET);
|
|
90
114
|
//#endregion
|
|
91
|
-
export { D1_DATABASE, DURABLE_OBJECT_NAMESPACE, KV_NAMESPACE, QUEUE_PRODUCER, R2_BUCKET, RATE_LIMITER, d1, durableObject, kv, queue, r2, rateLimit, workflow };
|
|
115
|
+
export { D1_DATABASE, DURABLE_OBJECT_NAMESPACE, FLAGSHIP, KV_NAMESPACE, QUEUE_PRODUCER, R2_BUCKET, RATE_LIMITER, SECRETS_STORE_SECRET, d1, durableObject, flagship, kv, queue, r2, rateLimit, secretsStoreSecret, workflow };
|
|
92
116
|
|
|
93
117
|
//# sourceMappingURL=bindings.js.map
|
package/dist/bindings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.js","names":[],"sources":["../src/bindings.ts"],"sourcesContent":["import {\n defineBinding,\n type Binding,\n type BindingKind,\n type BindingRef,\n} from '@velajs/vela/module-kit';\n\n/** Whether a value exposes every named operation as a function. */\nfunction hasOperations(value: unknown, operations: readonly string[]): boolean {\n if (typeof value !== 'object' || value === null) return false;\n return operations.every((operation) => typeof Reflect.get(value, operation) === 'function');\n}\n\n/**\n * Name-based Workers binding factories. Each takes `{ binding }`, the name\n * declared in the Wrangler configuration, and returns a reference that reads\n * and validates the native binding from an application's `ENV` when called.\n * Declaring one reads no environment, so references belong in static module\n * options: `CacheModule.forRoot({ namespace, scope, store: kvCache({ binding: 'CACHE' }) })`.\n */\n\n/** A KV namespace declared under `kv_namespaces`. */\nexport const KV_NAMESPACE: BindingKind<KVNamespace> = {\n name: 'KV namespace',\n configKey: 'kv_namespaces',\n accepts: (value): value is KVNamespace =>\n hasOperations(value, ['get', 'put', 'delete', 'list', 'getWithMetadata']),\n};\nexport const kv = /* @__PURE__ */ defineBinding(KV_NAMESPACE);\n\n/** An R2 bucket declared under `r2_buckets`. */\nexport const R2_BUCKET: BindingKind<R2Bucket> = {\n name: 'R2 bucket',\n configKey: 'r2_buckets',\n accepts: (value): value is R2Bucket =>\n hasOperations(value, ['get', 'put', 'head', 'delete', 'list', 'createMultipartUpload']),\n};\nexport const r2 = /* @__PURE__ */ defineBinding(R2_BUCKET);\n\n/** A D1 database declared under `d1_databases`. */\nexport const D1_DATABASE: BindingKind<D1Database> = {\n name: 'D1 database',\n configKey: 'd1_databases',\n accepts: (value): value is D1Database => hasOperations(value, ['prepare', 'batch', 'exec']),\n};\nexport const d1 = /* @__PURE__ */ defineBinding(D1_DATABASE);\n\n/** A queue producer declared under `queues.producers`. */\nexport const QUEUE_PRODUCER: BindingKind<Queue> = {\n name: 'queue producer',\n configKey: 'queues.producers',\n accepts: (value): value is Queue => hasOperations(value, ['send']),\n};\nexport const queue = /* @__PURE__ */ defineBinding(QUEUE_PRODUCER);\n\n/** A Durable Object namespace declared under `durable_objects.bindings`. */\nexport const DURABLE_OBJECT_NAMESPACE: BindingKind<DurableObjectNamespace> = {\n name: 'Durable Object namespace',\n configKey: 'durable_objects.bindings',\n accepts: (value): value is DurableObjectNamespace => hasOperations(value, ['idFromName', 'get']),\n};\nexport const durableObject = /* @__PURE__ */ defineBinding(DURABLE_OBJECT_NAMESPACE);\n\n/** A Workers Rate Limiting binding declared under `ratelimits`. */\nexport const RATE_LIMITER: BindingKind<RateLimit> = {\n name: 'rate limiter',\n configKey: 'ratelimits',\n accepts: (value): value is RateLimit => hasOperations(value, ['limit']),\n};\nexport const rateLimit = /* @__PURE__ */ defineBinding(RATE_LIMITER);\n\n/**\n * A reference to a Workflow binding declared under `workflows`, whose\n * instances take `Params`: for a class from `VelaWorkflow()`,\n * `workflow<WorkflowParams<SignupWorkflow>>({ binding: 'SIGNUP_WORKFLOW' })`.\n * Called with an application's ENV, it returns the native binding typed with\n * those params: `await signups(env).create({ params: { email } })`. The\n * runtime checks that the binding is a Workflow; its params are what the\n * Workflow class declares.\n */\nexport function workflow<Params = unknown>(ref: BindingRef): Binding<Workflow<Params>> {\n return defineBinding<Workflow<Params>>({\n name: 'Workflow',\n configKey: 'workflows',\n accepts: (value): value is Workflow<Params> => hasOperations(value, ['create', 'get']),\n })(ref);\n}\n"],"mappings":";;;AAQA,SAAS,cAAc,OAAgB,YAAwC;CAC7E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAO,WAAW,OAAO,cAAc,OAAO,QAAQ,IAAI,OAAO,SAAS,MAAM,UAAU;AAC5F;;;;;;;;;AAWA,MAAa,eAAyC;CACpD,MAAM;CACN,WAAW;CACX,UAAU,UACR,cAAc,OAAO;EAAC;EAAO;EAAO;EAAU;EAAQ;CAAiB,CAAC;AAC5E;AACA,MAAa,KAAqB,8BAAc,YAAY;;AAG5D,MAAa,YAAmC;CAC9C,MAAM;CACN,WAAW;CACX,UAAU,UACR,cAAc,OAAO;EAAC;EAAO;EAAO;EAAQ;EAAU;EAAQ;CAAuB,CAAC;AAC1F;AACA,MAAa,KAAqB,8BAAc,SAAS;;AAGzD,MAAa,cAAuC;CAClD,MAAM;CACN,WAAW;CACX,UAAU,UAA+B,cAAc,OAAO;EAAC;EAAW;EAAS;CAAM,CAAC;AAC5F;AACA,MAAa,KAAqB,8BAAc,WAAW;;AAG3D,MAAa,iBAAqC;CAChD,MAAM;CACN,WAAW;CACX,UAAU,UAA0B,cAAc,OAAO,CAAC,MAAM,CAAC;AACnE;AACA,MAAa,QAAwB,8BAAc,cAAc;;AAGjE,MAAa,2BAAgE;CAC3E,MAAM;CACN,WAAW;CACX,UAAU,UAA2C,cAAc,OAAO,CAAC,cAAc,KAAK,CAAC;AACjG;AACA,MAAa,gBAAgC,8BAAc,wBAAwB;;AAGnF,MAAa,eAAuC;CAClD,MAAM;CACN,WAAW;CACX,UAAU,UAA8B,cAAc,OAAO,CAAC,OAAO,CAAC;AACxE;AACA,MAAa,YAA4B,8BAAc,YAAY;;;;;;;;;;AAWnE,SAAgB,SAA2B,KAA4C;CACrF,OAAO,cAAgC;EACrC,MAAM;EACN,WAAW;EACX,UAAU,UAAqC,cAAc,OAAO,CAAC,UAAU,KAAK,CAAC;CACvF,CAAC,CAAC,CAAC,GAAG;AACR"}
|
|
1
|
+
{"version":3,"file":"bindings.js","names":[],"sources":["../src/bindings.ts"],"sourcesContent":["import {\n defineBinding,\n type Binding,\n type BindingKind,\n type BindingRef,\n} from '@velajs/vela/module-kit';\n\n/** Whether a value exposes every named operation as a function. */\nfunction hasOperations(value: unknown, operations: readonly string[]): boolean {\n if (typeof value !== 'object' || value === null) return false;\n return operations.every((operation) => typeof Reflect.get(value, operation) === 'function');\n}\n\n/**\n * Name-based Workers binding factories. Each takes `{ binding }`, the name\n * declared in the Wrangler configuration, and returns a reference that reads\n * and validates the native binding from an application's `ENV` when called.\n * Declaring one reads no environment, so references belong in static module\n * options: `CacheModule.forRoot({ namespace, scope, store: kvCache({ binding: 'CACHE' }) })`.\n */\n\n/** A KV namespace declared under `kv_namespaces`. */\nexport const KV_NAMESPACE: BindingKind<KVNamespace> = {\n name: 'KV namespace',\n configKey: 'kv_namespaces',\n accepts: (value): value is KVNamespace =>\n hasOperations(value, ['get', 'put', 'delete', 'list', 'getWithMetadata']),\n};\nexport const kv = /* @__PURE__ */ defineBinding(KV_NAMESPACE);\n\n/** An R2 bucket declared under `r2_buckets`. */\nexport const R2_BUCKET: BindingKind<R2Bucket> = {\n name: 'R2 bucket',\n configKey: 'r2_buckets',\n accepts: (value): value is R2Bucket =>\n hasOperations(value, ['get', 'put', 'head', 'delete', 'list', 'createMultipartUpload']),\n};\nexport const r2 = /* @__PURE__ */ defineBinding(R2_BUCKET);\n\n/** A D1 database declared under `d1_databases`. */\nexport const D1_DATABASE: BindingKind<D1Database> = {\n name: 'D1 database',\n configKey: 'd1_databases',\n accepts: (value): value is D1Database => hasOperations(value, ['prepare', 'batch', 'exec']),\n};\nexport const d1 = /* @__PURE__ */ defineBinding(D1_DATABASE);\n\n/** A queue producer declared under `queues.producers`. */\nexport const QUEUE_PRODUCER: BindingKind<Queue> = {\n name: 'queue producer',\n configKey: 'queues.producers',\n accepts: (value): value is Queue => hasOperations(value, ['send']),\n};\nexport const queue = /* @__PURE__ */ defineBinding(QUEUE_PRODUCER);\n\n/** A Durable Object namespace declared under `durable_objects.bindings`. */\nexport const DURABLE_OBJECT_NAMESPACE: BindingKind<DurableObjectNamespace> = {\n name: 'Durable Object namespace',\n configKey: 'durable_objects.bindings',\n accepts: (value): value is DurableObjectNamespace => hasOperations(value, ['idFromName', 'get']),\n};\nexport const durableObject = /* @__PURE__ */ defineBinding(DURABLE_OBJECT_NAMESPACE);\n\n/** A Workers Rate Limiting binding declared under `ratelimits`. */\nexport const RATE_LIMITER: BindingKind<RateLimit> = {\n name: 'rate limiter',\n configKey: 'ratelimits',\n accepts: (value): value is RateLimit => hasOperations(value, ['limit']),\n};\nexport const rateLimit = /* @__PURE__ */ defineBinding(RATE_LIMITER);\n\n/**\n * A reference to a Workflow binding declared under `workflows`, whose\n * instances take `Params`: for a class from `VelaWorkflow()`,\n * `workflow<WorkflowParams<SignupWorkflow>>({ binding: 'SIGNUP_WORKFLOW' })`.\n * Called with an application's ENV, it returns the native binding typed with\n * those params: `await signups(env).create({ params: { email } })`. The\n * runtime checks that the binding is a Workflow; its params are what the\n * Workflow class declares.\n */\nexport function workflow<Params = unknown>(ref: BindingRef): Binding<Workflow<Params>> {\n return defineBinding<Workflow<Params>>({\n name: 'Workflow',\n configKey: 'workflows',\n accepts: (value): value is Workflow<Params> => hasOperations(value, ['create', 'get']),\n })(ref);\n}\n\n/** A native Flagship binding declared under `flagship`. No flag values are cached. */\nexport const FLAGSHIP: BindingKind<Flagship> = {\n name: 'Flagship',\n configKey: 'flagship',\n accepts: (value): value is Flagship =>\n hasOperations(value, [\n 'get',\n 'getBooleanValue',\n 'getStringValue',\n 'getNumberValue',\n 'getObjectValue',\n 'getBooleanDetails',\n 'getStringDetails',\n 'getNumberDetails',\n 'getObjectDetails',\n ]),\n};\nexport const flagship = /* @__PURE__ */ defineBinding(FLAGSHIP);\n\n/** A secret handle declared under `secrets_store_secrets`; resolve its value with `get()`. */\nexport const SECRETS_STORE_SECRET: BindingKind<SecretsStoreSecret> = {\n name: 'Secrets Store secret',\n configKey: 'secrets_store_secrets',\n accepts: (value): value is SecretsStoreSecret => hasOperations(value, ['get']),\n};\nexport const secretsStoreSecret = /* @__PURE__ */ defineBinding(SECRETS_STORE_SECRET);\n"],"mappings":";;;AAQA,SAAS,cAAc,OAAgB,YAAwC;CAC7E,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO;CACxD,OAAO,WAAW,OAAO,cAAc,OAAO,QAAQ,IAAI,OAAO,SAAS,MAAM,UAAU;AAC5F;;;;;;;;;AAWA,MAAa,eAAyC;CACpD,MAAM;CACN,WAAW;CACX,UAAU,UACR,cAAc,OAAO;EAAC;EAAO;EAAO;EAAU;EAAQ;CAAiB,CAAC;AAC5E;AACA,MAAa,KAAqB,8BAAc,YAAY;;AAG5D,MAAa,YAAmC;CAC9C,MAAM;CACN,WAAW;CACX,UAAU,UACR,cAAc,OAAO;EAAC;EAAO;EAAO;EAAQ;EAAU;EAAQ;CAAuB,CAAC;AAC1F;AACA,MAAa,KAAqB,8BAAc,SAAS;;AAGzD,MAAa,cAAuC;CAClD,MAAM;CACN,WAAW;CACX,UAAU,UAA+B,cAAc,OAAO;EAAC;EAAW;EAAS;CAAM,CAAC;AAC5F;AACA,MAAa,KAAqB,8BAAc,WAAW;;AAG3D,MAAa,iBAAqC;CAChD,MAAM;CACN,WAAW;CACX,UAAU,UAA0B,cAAc,OAAO,CAAC,MAAM,CAAC;AACnE;AACA,MAAa,QAAwB,8BAAc,cAAc;;AAGjE,MAAa,2BAAgE;CAC3E,MAAM;CACN,WAAW;CACX,UAAU,UAA2C,cAAc,OAAO,CAAC,cAAc,KAAK,CAAC;AACjG;AACA,MAAa,gBAAgC,8BAAc,wBAAwB;;AAGnF,MAAa,eAAuC;CAClD,MAAM;CACN,WAAW;CACX,UAAU,UAA8B,cAAc,OAAO,CAAC,OAAO,CAAC;AACxE;AACA,MAAa,YAA4B,8BAAc,YAAY;;;;;;;;;;AAWnE,SAAgB,SAA2B,KAA4C;CACrF,OAAO,cAAgC;EACrC,MAAM;EACN,WAAW;EACX,UAAU,UAAqC,cAAc,OAAO,CAAC,UAAU,KAAK,CAAC;CACvF,CAAC,CAAC,CAAC,GAAG;AACR;;AAGA,MAAa,WAAkC;CAC7C,MAAM;CACN,WAAW;CACX,UAAU,UACR,cAAc,OAAO;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACL;AACA,MAAa,WAA2B,8BAAc,QAAQ;;AAG9D,MAAa,uBAAwD;CACnE,MAAM;CACN,WAAW;CACX,UAAU,UAAuC,cAAc,OAAO,CAAC,KAAK,CAAC;AAC/E;AACA,MAAa,qBAAqC,8BAAc,oBAAoB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CorsOptions, InjectionToken, VelaApplication, VelaEnv } from "@velajs/vela";
|
|
2
2
|
import "@velajs/vela/module-kit";
|
|
3
|
-
import { ExecutionContext } from "hono";
|
|
3
|
+
import { ExecutionContext as ExecutionContext$1 } from "hono";
|
|
4
4
|
//#region src/scheduled-event.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* The event a Worker's `scheduled()` export receives. The native
|
|
@@ -97,7 +97,7 @@ declare class CloudflareApplication {
|
|
|
97
97
|
#private;
|
|
98
98
|
readonly env: VelaEnv;
|
|
99
99
|
constructor(app: VelaApplication, env: VelaEnv);
|
|
100
|
-
readonly fetch: (request: Request, env: VelaEnv, ctx?: ExecutionContext) => Promise<Response>;
|
|
100
|
+
readonly fetch: (request: Request, env: VelaEnv, ctx?: ExecutionContext$1) => Promise<Response>;
|
|
101
101
|
getHonoApp(): ReturnType<VelaApplication['getHonoApp']>;
|
|
102
102
|
/**
|
|
103
103
|
* Resolve a provider from the application's DI container (delegates to
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as ScheduledEvent, t as CloudflareApplication } from "./cloudflare-application-
|
|
1
|
+
import { a as ScheduledEvent, t as CloudflareApplication } from "./cloudflare-application-Dsscb3Mo.js";
|
|
2
2
|
import { CorsOptions, DynamicModule, GlobalPrefixOptions, Type, VelaApplication, VelaCreateOptions, VelaEnv, VelaSecurityOptions, VersioningOptions } from "@velajs/vela";
|
|
3
3
|
import { RuntimeAdapter } from "@velajs/vela/module-kit";
|
|
4
|
-
import { ExecutionContext } from "hono";
|
|
4
|
+
import { ExecutionContext as ExecutionContext$1 } from "hono";
|
|
5
5
|
//#region src/root-module.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The root a Worker or Durable Object is built from: a module class or a
|
|
@@ -149,7 +149,7 @@ interface CloudflareWorkerDescriptor {
|
|
|
149
149
|
}
|
|
150
150
|
/** The exported handlers of a Worker entry (`defineCloudflareApp().worker`, `createCloudflareWorker()`). */
|
|
151
151
|
interface CloudflareWorker {
|
|
152
|
-
fetch(request: Request, env: VelaEnv, ctx: ExecutionContext): Promise<Response>;
|
|
152
|
+
fetch(request: Request, env: VelaEnv, ctx: ExecutionContext$1): Promise<Response>;
|
|
153
153
|
scheduled(event: ScheduledEvent, env: VelaEnv, ctx?: {
|
|
154
154
|
waitUntil: (promise: Promise<unknown>) => void;
|
|
155
155
|
}): Promise<void>;
|
|
@@ -164,14 +164,14 @@ interface CloudflareWorker {
|
|
|
164
164
|
* `@velajs/cloudflare/email`: it runs the application's `@OnEmail()`
|
|
165
165
|
* handlers, and rejects a message none of them accepts.
|
|
166
166
|
*/
|
|
167
|
-
readonly email?: (message: ForwardableEmailMessage, env: VelaEnv, ctx?: ExecutionContext) => Promise<void>;
|
|
167
|
+
readonly email?: (message: ForwardableEmailMessage, env: VelaEnv, ctx?: ExecutionContext$1) => Promise<void>;
|
|
168
168
|
/**
|
|
169
169
|
* The Tail Workers handler, present once a module imports `OnTail` from
|
|
170
170
|
* `@velajs/cloudflare/tail`: it runs the application's `@OnTail()` handlers
|
|
171
171
|
* and never rejects, even when the application fails to start (the error is
|
|
172
172
|
* logged to the console, and the next batch retries).
|
|
173
173
|
*/
|
|
174
|
-
readonly tail?: (events: TraceItem[], env: VelaEnv, ctx?: ExecutionContext) => Promise<void>;
|
|
174
|
+
readonly tail?: (events: TraceItem[], env: VelaEnv, ctx?: ExecutionContext$1) => Promise<void>;
|
|
175
175
|
/**
|
|
176
176
|
* Symbol-keyed, so the platform, which reads string-keyed handlers, ignores
|
|
177
177
|
* it; enumerable, so `{ ...worker, email }` keeps it for the CLI.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./vela-env-DFvyoNT3.js";
|
|
2
|
-
import { a as CloudflareApp, y as CloudflareRoot } from "./cloudflare-factory-
|
|
2
|
+
import { a as CloudflareApp, y as CloudflareRoot } from "./cloudflare-factory-DM9CBvNH.js";
|
|
3
3
|
import { n as RpcMethods, t as RpcMethodOf } from "./host-members-DECj_4yz.js";
|
|
4
4
|
import { l as VelaDoPitrRpc, t as VelaNonceDurableObject } from "./nonce.durable-object-Bg1e0BMD.js";
|
|
5
5
|
import { DurableObject } from "cloudflare:workers";
|
package/dist/email.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./vela-env-DFvyoNT3.js";
|
|
2
|
-
import "./cloudflare-application-
|
|
2
|
+
import "./cloudflare-application-Dsscb3Mo.js";
|
|
3
3
|
import { EntrypointExecutionContext } from "@velajs/vela/module-kit";
|
|
4
4
|
//#region src/email/on-email.d.ts
|
|
5
5
|
/** Options of {@link OnEmail}. */
|
package/dist/entrypoints.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./vela-env-DFvyoNT3.js";
|
|
2
|
-
import { a as CloudflareApp } from "./cloudflare-factory-
|
|
2
|
+
import { a as CloudflareApp } from "./cloudflare-factory-DM9CBvNH.js";
|
|
3
3
|
import { n as RpcMethods, t as RpcMethodOf } from "./host-members-DECj_4yz.js";
|
|
4
4
|
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
5
5
|
import { InjectionToken, Type, VelaEnv } from "@velajs/vela";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./vela-env-DFvyoNT3.js";
|
|
2
|
-
import { a as ScheduledEvent, i as CloudflareScheduledEvent, n as MountOpenApiOptions, r as CLOUDFLARE_SCHEDULED_EVENT, t as CloudflareApplication } from "./cloudflare-application-
|
|
3
|
-
import { _ as defineCloudflareApp, a as CloudflareApp, c as CloudflareEntrypointDescriptor, d as CloudflareWorkerOptions, f as CloudflareWorkflowDescriptor, g as createCloudflareWorker, h as createCloudflareApp, i as CLOUDFLARE_WORKFLOW, l as CloudflareWorker, m as cloudflareAdapter, n as CLOUDFLARE_ENTRYPOINT, o as CloudflareAppOptions, p as CreateCloudflareAppOptions, r as CLOUDFLARE_WORKER, s as CloudflareDurableObjectDescriptor, t as CLOUDFLARE_DURABLE_OBJECT, u as CloudflareWorkerDescriptor, v as isCloudflareApp, y as CloudflareRoot } from "./cloudflare-factory-
|
|
2
|
+
import { a as ScheduledEvent, i as CloudflareScheduledEvent, n as MountOpenApiOptions, r as CLOUDFLARE_SCHEDULED_EVENT, t as CloudflareApplication } from "./cloudflare-application-Dsscb3Mo.js";
|
|
3
|
+
import { _ as defineCloudflareApp, a as CloudflareApp, c as CloudflareEntrypointDescriptor, d as CloudflareWorkerOptions, f as CloudflareWorkflowDescriptor, g as createCloudflareWorker, h as createCloudflareApp, i as CLOUDFLARE_WORKFLOW, l as CloudflareWorker, m as cloudflareAdapter, n as CLOUDFLARE_ENTRYPOINT, o as CloudflareAppOptions, p as CreateCloudflareAppOptions, r as CLOUDFLARE_WORKER, s as CloudflareDurableObjectDescriptor, t as CLOUDFLARE_DURABLE_OBJECT, u as CloudflareWorkerDescriptor, v as isCloudflareApp, y as CloudflareRoot } from "./cloudflare-factory-DM9CBvNH.js";
|
|
4
4
|
import { a as DoPitrId, c as DoPitrUnavailableError, d as isDoPitrUnavailable, f as readDoPitrBookmark, i as DoPitrBookmarkRead, l as VelaDoPitrRpc, n as DoPitrArmOptions, o as DoPitrNamespace, r as DoPitrArmResult, s as DoPitrStorage, t as VelaNonceDurableObject, u as armDoPitr } from "./nonce.durable-object-Bg1e0BMD.js";
|
|
5
5
|
import { DynamicModule, Type, VelaEnv } from "@velajs/vela";
|
|
6
6
|
import { Binding, BindingRef, EnvFactory, RuntimeAdapter } from "@velajs/vela/module-kit";
|
|
7
7
|
import { CommitStamp, CursorLog, InvalidationCommand, LiveDriver, LiveInvalidationSink, ResumeVerdict } from "@velajs/vela/live";
|
|
8
8
|
import { BroadcastCommand } from "@velajs/vela/websocket";
|
|
9
9
|
import { CacheEntry, CacheEntryReader, CacheEntryWriter, CacheInvalidationStore, CacheStore } from "@velajs/vela/cache";
|
|
10
|
-
import { FeatureFlagDriver, FlagContext } from "@velajs/feature-flags";
|
|
10
|
+
import { FeatureFlagDriver, FlagContext, FlagEvaluationDetails } from "@velajs/feature-flags";
|
|
11
11
|
import { ThrottlerStore } from "@velajs/vela/throttler";
|
|
12
12
|
import { NonceStore } from "@velajs/vela/security";
|
|
13
13
|
//#region src/websocket/room-id.d.ts
|
|
@@ -82,14 +82,16 @@ export declare const rateLimit: (ref: BindingRef) => Binding<RateLimit>;
|
|
|
82
82
|
* Workflow class declares.
|
|
83
83
|
*/
|
|
84
84
|
export declare function workflow<Params = unknown>(ref: BindingRef): Binding<Workflow<Params>>;
|
|
85
|
+
export declare const flagship: (ref: BindingRef) => Binding<Flagship>;
|
|
86
|
+
export declare const secretsStoreSecret: (ref: BindingRef) => Binding<SecretsStoreSecret>;
|
|
85
87
|
//#endregion
|
|
86
88
|
//#region src/services/kv-cache.store.d.ts
|
|
87
89
|
/** A KV namespace, or a function that reads it when an operation needs it. */
|
|
88
90
|
type KVNamespaceSource = KVNamespace | (() => KVNamespace);
|
|
89
91
|
/**
|
|
90
92
|
* Native KV JSON value store. Metadata retains logical expiry even when KV's
|
|
91
|
-
* physical retention rounds up to its 60-second minimum.
|
|
92
|
-
*
|
|
93
|
+
* physical retention rounds up to its 60-second minimum. Values without
|
|
94
|
+
* Vela expiry metadata are cache misses.
|
|
93
95
|
*/
|
|
94
96
|
export declare class KVCacheStore implements CacheStore, CacheEntryReader, CacheEntryWriter {
|
|
95
97
|
#private;
|
|
@@ -139,17 +141,24 @@ export declare function kvCacheInvalidation(ref: {
|
|
|
139
141
|
//#region src/services/flagship-flag.driver.d.ts
|
|
140
142
|
/**
|
|
141
143
|
* The subset of a Cloudflare **Flagship** binding this driver evaluates against
|
|
142
|
-
* —
|
|
144
|
+
* — typed value methods and optional evaluation details. The binding itself returns the supplied
|
|
143
145
|
* `defaultValue` on evaluation errors; transport-level failures reject and are
|
|
144
146
|
* left to propagate (never-throw is the service layer's job, not the driver's).
|
|
145
147
|
*
|
|
146
148
|
* @see https://developers.cloudflare.com/flagship/binding/
|
|
147
149
|
*/
|
|
150
|
+
type NativeFlagDetails<T> = Omit<FlagEvaluationDetails<T>, 'reason'> & {
|
|
151
|
+
reason?: string;
|
|
152
|
+
};
|
|
148
153
|
interface FlagshipBinding {
|
|
149
|
-
getBooleanValue(key: string, defaultValue: boolean, context?:
|
|
150
|
-
getStringValue(key: string, defaultValue: string, context?:
|
|
151
|
-
getNumberValue(key: string, defaultValue: number, context?:
|
|
152
|
-
getObjectValue(key: string, defaultValue: object, context?:
|
|
154
|
+
getBooleanValue(key: string, defaultValue: boolean, context?: Record<string, string | number | boolean>): Promise<boolean>;
|
|
155
|
+
getStringValue(key: string, defaultValue: string, context?: Record<string, string | number | boolean>): Promise<string>;
|
|
156
|
+
getNumberValue(key: string, defaultValue: number, context?: Record<string, string | number | boolean>): Promise<number>;
|
|
157
|
+
getObjectValue(key: string, defaultValue: object, context?: Record<string, string | number | boolean>): Promise<unknown>;
|
|
158
|
+
getBooleanDetails?(key: string, defaultValue: boolean, context?: Record<string, string | number | boolean>): Promise<NativeFlagDetails<boolean>>;
|
|
159
|
+
getStringDetails?(key: string, defaultValue: string, context?: Record<string, string | number | boolean>): Promise<NativeFlagDetails<string>>;
|
|
160
|
+
getNumberDetails?(key: string, defaultValue: number, context?: Record<string, string | number | boolean>): Promise<NativeFlagDetails<number>>;
|
|
161
|
+
getObjectDetails?(key: string, defaultValue: object, context?: Record<string, string | number | boolean>): Promise<NativeFlagDetails<unknown>>;
|
|
153
162
|
}
|
|
154
163
|
interface FlagshipFlagDriverOptions {
|
|
155
164
|
/** Driver name used for `use(name)` / default-driver selection. Default `"flagship"`. */
|
|
@@ -159,8 +168,9 @@ interface FlagshipFlagDriverOptions {
|
|
|
159
168
|
* {@link FeatureFlagDriver} backed by a Cloudflare Flagship binding.
|
|
160
169
|
*
|
|
161
170
|
* A thin, honest wrapper: each contract method maps 1:1 onto the binding's
|
|
162
|
-
* corresponding
|
|
163
|
-
* `defaultValue`) and evaluation context.
|
|
171
|
+
* corresponding native method, forwarding the caller's `fallback` (the binding's
|
|
172
|
+
* `defaultValue`) and validated scalar evaluation context. Optional detail methods
|
|
173
|
+
* preserve native reasons, variants and error codes; value-only bindings report UNKNOWN. The binding resolves the fallback on
|
|
164
174
|
* evaluation errors; anything the binding *rejects* with (e.g. a `remote: true`
|
|
165
175
|
* dev-proxy tunnel dropping) propagates — `@velajs/feature-flags`'s service owns
|
|
166
176
|
* the never-throw guarantee.
|
|
@@ -186,6 +196,11 @@ export declare class FlagshipFlagDriver implements FeatureFlagDriver {
|
|
|
186
196
|
getString(key: string, fallback: string, ctx?: FlagContext): Promise<string>;
|
|
187
197
|
getNumber(key: string, fallback: number, ctx?: FlagContext): Promise<number>;
|
|
188
198
|
getObject(key: string, fallback: object, ctx?: FlagContext): Promise<unknown>;
|
|
199
|
+
getBooleanDetails(key: string, fallback: boolean, ctx?: FlagContext): Promise<FlagEvaluationDetails<boolean>>;
|
|
200
|
+
getStringDetails(key: string, fallback: string, ctx?: FlagContext): Promise<FlagEvaluationDetails<string>>;
|
|
201
|
+
getNumberDetails(key: string, fallback: number, ctx?: FlagContext): Promise<FlagEvaluationDetails<number>>;
|
|
202
|
+
getObjectDetails(key: string, fallback: object, ctx?: FlagContext): Promise<FlagEvaluationDetails<unknown>>;
|
|
203
|
+
private details;
|
|
189
204
|
}
|
|
190
205
|
/** Convenience factory for {@link FlagshipFlagDriver}. */
|
|
191
206
|
export declare function flagshipFlagDriver(binding: FlagshipBinding | (() => FlagshipBinding), options?: FlagshipFlagDriverOptions): FlagshipFlagDriver;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { durableObjectRoomName } from "./websocket/room-id.js";
|
|
2
2
|
import { CLOUDFLARE_SCHEDULED_EVENT } from "./scheduled-event.js";
|
|
3
3
|
import { CloudflareApplication } from "./cloudflare-application.js";
|
|
4
|
-
import { d1, durableObject, kv, queue, r2, rateLimit, workflow } from "./bindings.js";
|
|
4
|
+
import { d1, durableObject, flagship, kv, queue, r2, rateLimit, secretsStoreSecret, workflow } from "./bindings.js";
|
|
5
5
|
import { durableObjectLive } from "./websocket/live-driver.js";
|
|
6
6
|
import { CLOUDFLARE_DURABLE_OBJECT, CLOUDFLARE_ENTRYPOINT, CLOUDFLARE_WORKER, CLOUDFLARE_WORKFLOW, cloudflareAdapter, createCloudflareApp, createCloudflareWorker, defineCloudflareApp, isCloudflareApp } from "./cloudflare-factory.js";
|
|
7
7
|
import { EntrypointError, isEntrypointError } from "./rpc/entrypoint-error.js";
|
|
@@ -13,4 +13,4 @@ import { DoPitrUnavailableError, armDoPitr, isDoPitrUnavailable, readDoPitrBookm
|
|
|
13
13
|
import { DoCursorLog, liveInvalidateToRoom } from "./websocket/do-live.js";
|
|
14
14
|
import { rateLimitStore } from "./rate-limit/cloudflare-rate-limit.store.js";
|
|
15
15
|
import { durableObjectNonceStore } from "./nonce/durable-object-nonce.store.js";
|
|
16
|
-
export { CLOUDFLARE_DURABLE_OBJECT, CLOUDFLARE_ENTRYPOINT, CLOUDFLARE_SCHEDULED_EVENT, CLOUDFLARE_WORKER, CLOUDFLARE_WORKFLOW, CloudflareApplication, DoCursorLog, DoPitrUnavailableError, EntrypointError, FlagshipFlagDriver, KVCacheInvalidationStore, KVCacheStore, KvFlagDriver, QueueConsumer, armDoPitr, cloudflareAdapter, createCloudflareApp, createCloudflareWorker, d1, defineCloudflareApp, durableObject, durableObjectLive, durableObjectNonceStore, durableObjectRoomName, flagshipFlagDriver, isCloudflareApp, isDoPitrUnavailable, isEntrypointError, kv, kvCache, kvCacheInvalidation, kvFlagDriver, liveInvalidateToRoom, queue, r2, rateLimit, rateLimitStore, readDoPitrBookmark, workflow };
|
|
16
|
+
export { CLOUDFLARE_DURABLE_OBJECT, CLOUDFLARE_ENTRYPOINT, CLOUDFLARE_SCHEDULED_EVENT, CLOUDFLARE_WORKER, CLOUDFLARE_WORKFLOW, CloudflareApplication, DoCursorLog, DoPitrUnavailableError, EntrypointError, FlagshipFlagDriver, KVCacheInvalidationStore, KVCacheStore, KvFlagDriver, QueueConsumer, armDoPitr, cloudflareAdapter, createCloudflareApp, createCloudflareWorker, d1, defineCloudflareApp, durableObject, durableObjectLive, durableObjectNonceStore, durableObjectRoomName, flagship, flagshipFlagDriver, isCloudflareApp, isDoPitrUnavailable, isEntrypointError, kv, kvCache, kvCacheInvalidation, kvFlagDriver, liveInvalidateToRoom, queue, r2, rateLimit, rateLimitStore, readDoPitrBookmark, secretsStoreSecret, workflow };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from "@velajs/vela/validation";
|
|
2
|
+
//#region src/pipelines.d.ts
|
|
3
|
+
/** The native stream handle remains usable independently of the writer. */
|
|
4
|
+
export interface PipelinesBinding<Output = Record<string, unknown>> {
|
|
5
|
+
readonly send: (records: Output[]) => Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export interface PipelinesWriter<Input> {
|
|
8
|
+
/** Validate the entire nonempty batch, then await one native ingestion request. */
|
|
9
|
+
send(records: readonly Input[]): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Bind a Standard Schema producer to one trusted, configured stream. Schema
|
|
13
|
+
* outputs must fit the binding's record type; send() accepts schema inputs.
|
|
14
|
+
* Resolution means ingestion acceptance only, not downstream delivery or query
|
|
15
|
+
* visibility. There is no retry, splitting, buffering, or cross-writer state.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createPipelinesWriter<S extends StandardSchemaV1<unknown, Record<string, unknown>>>(binding: PipelinesBinding<NoInfer<StandardSchemaV1.InferOutput<S>>>, { schema }: {
|
|
18
|
+
readonly schema: S;
|
|
19
|
+
}): PipelinesWriter<StandardSchemaV1.InferInput<S>>;
|
|
20
|
+
//#endregion
|