@velajs/cloudflare 0.1.1 → 1.1.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 +29 -0
- package/README.md +52 -39
- package/dist/binding-ref.d.ts +2 -9
- package/dist/binding-ref.js +6 -10
- package/dist/cloudflare-application.d.ts +6 -6
- package/dist/cloudflare-application.js +35 -19
- package/dist/cloudflare-factory.d.ts +5 -8
- package/dist/cloudflare-factory.js +37 -26
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -5
- package/dist/modules/ai.module.d.ts +1 -6
- package/dist/modules/ai.module.js +7 -30
- package/dist/modules/create-binding-module.d.ts +14 -0
- package/dist/modules/create-binding-module.js +26 -0
- package/dist/modules/d1.module.d.ts +1 -6
- package/dist/modules/d1.module.js +7 -30
- package/dist/modules/durable-object.module.d.ts +1 -6
- package/dist/modules/durable-object.module.js +7 -30
- package/dist/modules/hyperdrive.module.d.ts +1 -6
- package/dist/modules/hyperdrive.module.js +7 -30
- package/dist/modules/kv.module.d.ts +1 -6
- package/dist/modules/kv.module.js +7 -30
- package/dist/modules/queue.module.d.ts +1 -6
- package/dist/modules/queue.module.js +7 -30
- package/dist/modules/r2.module.d.ts +1 -6
- package/dist/modules/r2.module.js +7 -30
- package/dist/modules/vectorize.module.d.ts +1 -6
- package/dist/modules/vectorize.module.js +7 -30
- package/dist/services/ai.service.d.ts +2 -12
- package/dist/services/ai.service.js +1 -4
- package/dist/services/d1.service.d.ts +2 -18
- package/dist/services/d1.service.js +1 -15
- package/dist/services/durable-object.service.d.ts +2 -20
- package/dist/services/durable-object.service.js +1 -16
- package/dist/services/hyperdrive.service.d.ts +2 -16
- package/dist/services/hyperdrive.service.js +1 -1
- package/dist/services/kv.service.d.ts +5 -18
- package/dist/services/kv.service.js +1 -16
- package/dist/services/queue.service.d.ts +3 -17
- package/dist/services/queue.service.js +1 -7
- package/dist/services/r2.service.d.ts +2 -14
- package/dist/services/r2.service.js +1 -16
- package/dist/services/vectorize.service.d.ts +2 -22
- package/dist/services/vectorize.service.js +1 -19
- package/dist/tokens.d.ts +0 -7
- package/dist/tokens.js +1 -9
- package/package.json +19 -13
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { BindingRef } from '../binding-ref';
|
|
2
|
-
type R2Binding = Record<string, any>;
|
|
3
|
-
/**
|
|
4
|
-
* Wrapper around Cloudflare R2 Bucket.
|
|
5
|
-
* Injected via `R2Module.forRoot({ binding: 'ASSETS' })`.
|
|
6
|
-
*/
|
|
7
2
|
export declare class R2Service {
|
|
8
3
|
private ref;
|
|
9
|
-
constructor(ref: BindingRef);
|
|
10
|
-
|
|
11
|
-
get bucket(): R2Binding;
|
|
12
|
-
get(key: string, options?: Record<string, unknown>): Promise<unknown>;
|
|
13
|
-
head(key: string): Promise<unknown>;
|
|
14
|
-
put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: Record<string, unknown>): Promise<unknown>;
|
|
15
|
-
delete(keys: string | string[]): Promise<void>;
|
|
16
|
-
list(options?: Record<string, unknown>): Promise<unknown>;
|
|
4
|
+
constructor(ref: BindingRef<R2Bucket>);
|
|
5
|
+
get bucket(): R2Bucket;
|
|
17
6
|
}
|
|
18
|
-
export {};
|
|
@@ -19,24 +19,9 @@ export class R2Service {
|
|
|
19
19
|
constructor(ref){
|
|
20
20
|
this.ref = ref;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
get bucket() {
|
|
23
23
|
return this.ref.value;
|
|
24
24
|
}
|
|
25
|
-
get(key, options) {
|
|
26
|
-
return this.bucket.get(key, options);
|
|
27
|
-
}
|
|
28
|
-
head(key) {
|
|
29
|
-
return this.bucket.head(key);
|
|
30
|
-
}
|
|
31
|
-
put(key, value, options) {
|
|
32
|
-
return this.bucket.put(key, value, options);
|
|
33
|
-
}
|
|
34
|
-
delete(keys) {
|
|
35
|
-
return this.bucket.delete(keys);
|
|
36
|
-
}
|
|
37
|
-
list(options) {
|
|
38
|
-
return this.bucket.list(options);
|
|
39
|
-
}
|
|
40
25
|
}
|
|
41
26
|
R2Service = _ts_decorate([
|
|
42
27
|
Injectable(),
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
import type { BindingRef } from '../binding-ref';
|
|
2
|
-
type VectorizeBinding = {
|
|
3
|
-
query: Function;
|
|
4
|
-
insert: Function;
|
|
5
|
-
upsert: Function;
|
|
6
|
-
getByIds: Function;
|
|
7
|
-
deleteByIds: Function;
|
|
8
|
-
describe: Function;
|
|
9
|
-
} & Record<string, any>;
|
|
10
|
-
/**
|
|
11
|
-
* Wrapper around Cloudflare Vectorize Index.
|
|
12
|
-
* Injected via `VectorizeModule.forRoot({ binding: 'EMBEDDINGS' })`.
|
|
13
|
-
*/
|
|
14
2
|
export declare class VectorizeService {
|
|
15
3
|
private ref;
|
|
16
|
-
constructor(ref: BindingRef);
|
|
17
|
-
|
|
18
|
-
get index(): VectorizeBinding;
|
|
19
|
-
query(vector: number[], options?: Record<string, unknown>): Promise<unknown>;
|
|
20
|
-
insert(vectors: unknown[]): Promise<unknown>;
|
|
21
|
-
upsert(vectors: unknown[]): Promise<unknown>;
|
|
22
|
-
getByIds(ids: string[]): Promise<unknown>;
|
|
23
|
-
deleteByIds(ids: string[]): Promise<unknown>;
|
|
24
|
-
describe(): Promise<unknown>;
|
|
4
|
+
constructor(ref: BindingRef<VectorizeIndex>);
|
|
5
|
+
get index(): VectorizeIndex;
|
|
25
6
|
}
|
|
26
|
-
export {};
|
|
@@ -19,27 +19,9 @@ export class VectorizeService {
|
|
|
19
19
|
constructor(ref){
|
|
20
20
|
this.ref = ref;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
get index() {
|
|
23
23
|
return this.ref.value;
|
|
24
24
|
}
|
|
25
|
-
query(vector, options) {
|
|
26
|
-
return this.index.query(vector, options);
|
|
27
|
-
}
|
|
28
|
-
insert(vectors) {
|
|
29
|
-
return this.index.insert(vectors);
|
|
30
|
-
}
|
|
31
|
-
upsert(vectors) {
|
|
32
|
-
return this.index.upsert(vectors);
|
|
33
|
-
}
|
|
34
|
-
getByIds(ids) {
|
|
35
|
-
return this.index.getByIds(ids);
|
|
36
|
-
}
|
|
37
|
-
deleteByIds(ids) {
|
|
38
|
-
return this.index.deleteByIds(ids);
|
|
39
|
-
}
|
|
40
|
-
describe() {
|
|
41
|
-
return this.index.describe();
|
|
42
|
-
}
|
|
43
25
|
}
|
|
44
26
|
VectorizeService = _ts_decorate([
|
|
45
27
|
Injectable(),
|
package/dist/tokens.d.ts
CHANGED
|
@@ -8,10 +8,3 @@ export declare const DO_BINDING_REF: InjectionToken<BindingRef<unknown>>;
|
|
|
8
8
|
export declare const AI_BINDING_REF: InjectionToken<BindingRef<unknown>>;
|
|
9
9
|
export declare const VECTORIZE_BINDING_REF: InjectionToken<BindingRef<unknown>>;
|
|
10
10
|
export declare const HYPERDRIVE_BINDING_REF: InjectionToken<BindingRef<unknown>>;
|
|
11
|
-
/**
|
|
12
|
-
* Global registry of binding refs to initialize on first request.
|
|
13
|
-
* Each module's `forRoot()` pushes its BindingRef here.
|
|
14
|
-
* CloudflareFactory reads from this to populate bindings.
|
|
15
|
-
*/
|
|
16
|
-
export declare const bindingsRegistry: BindingRef[];
|
|
17
|
-
export declare function clearBindingsRegistry(): void;
|
package/dist/tokens.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InjectionToken } from "@velajs/vela";
|
|
2
|
-
//
|
|
2
|
+
// Tokens for binding refs — used by services to receive the binding value.
|
|
3
3
|
export const KV_BINDING_REF = new InjectionToken('CF_KV_BINDING_REF');
|
|
4
4
|
export const D1_BINDING_REF = new InjectionToken('CF_D1_BINDING_REF');
|
|
5
5
|
export const R2_BINDING_REF = new InjectionToken('CF_R2_BINDING_REF');
|
|
@@ -8,11 +8,3 @@ export const DO_BINDING_REF = new InjectionToken('CF_DO_BINDING_REF');
|
|
|
8
8
|
export const AI_BINDING_REF = new InjectionToken('CF_AI_BINDING_REF');
|
|
9
9
|
export const VECTORIZE_BINDING_REF = new InjectionToken('CF_VECTORIZE_BINDING_REF');
|
|
10
10
|
export const HYPERDRIVE_BINDING_REF = new InjectionToken('CF_HYPERDRIVE_BINDING_REF');
|
|
11
|
-
/**
|
|
12
|
-
* Global registry of binding refs to initialize on first request.
|
|
13
|
-
* Each module's `forRoot()` pushes its BindingRef here.
|
|
14
|
-
* CloudflareFactory reads from this to populate bindings.
|
|
15
|
-
*/ export const bindingsRegistry = [];
|
|
16
|
-
export function clearBindingsRegistry() {
|
|
17
|
-
bindingsRegistry.length = 0;
|
|
18
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velajs/cloudflare",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Cloudflare Workers integration for Vela framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
"LICENSE",
|
|
18
18
|
"CHANGELOG.md"
|
|
19
19
|
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf dist && swc src -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"prepare": "swc src -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
|
|
25
|
+
"prepublishOnly": "pnpm run typecheck && pnpm test"
|
|
26
|
+
},
|
|
20
27
|
"sideEffects": false,
|
|
21
28
|
"keywords": [
|
|
22
29
|
"vela",
|
|
@@ -44,26 +51,25 @@
|
|
|
44
51
|
"node": ">=20"
|
|
45
52
|
},
|
|
46
53
|
"peerDependencies": {
|
|
47
|
-
"@
|
|
54
|
+
"@cloudflare/workers-types": ">=4",
|
|
55
|
+
"@velajs/vela": ">=1.1.0",
|
|
48
56
|
"hono": ">=4"
|
|
49
57
|
},
|
|
50
|
-
"peerDependenciesMeta": {
|
|
51
|
-
"@velajs/vela": {
|
|
52
|
-
"optional": true
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
58
|
"devDependencies": {
|
|
59
|
+
"@cloudflare/workers-types": "^4",
|
|
56
60
|
"@swc/cli": "^0.8.0",
|
|
57
61
|
"@swc/core": "^1.15.11",
|
|
58
|
-
"@velajs/vela": "^
|
|
62
|
+
"@velajs/vela": "^1.1.0",
|
|
59
63
|
"hono": "^4",
|
|
60
64
|
"typescript": "^5",
|
|
61
65
|
"unplugin-swc": "^1.5.9",
|
|
62
66
|
"vitest": "^4.0.18"
|
|
63
67
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
+
"packageManager": "pnpm@10.20.0",
|
|
69
|
+
"pnpm": {
|
|
70
|
+
"onlyBuiltDependencies": [
|
|
71
|
+
"@swc/core",
|
|
72
|
+
"esbuild"
|
|
73
|
+
]
|
|
68
74
|
}
|
|
69
|
-
}
|
|
75
|
+
}
|