@mizchi/k1c 0.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/LICENSE +21 -0
- package/README.md +150 -0
- package/dist/canary/dispatcher-template.d.ts +17 -0
- package/dist/canary/dispatcher-template.js +42 -0
- package/dist/canary/effects-cloudflare.d.ts +9 -0
- package/dist/canary/effects-cloudflare.js +66 -0
- package/dist/canary/rollout-command.d.ts +15 -0
- package/dist/canary/rollout-command.js +92 -0
- package/dist/canary/runtime.d.ts +59 -0
- package/dist/canary/runtime.js +138 -0
- package/dist/canary/state-machine.d.ts +72 -0
- package/dist/canary/state-machine.js +161 -0
- package/dist/cli/args.d.ts +51 -0
- package/dist/cli/args.js +239 -0
- package/dist/cli/canary-integration.d.ts +11 -0
- package/dist/cli/canary-integration.js +101 -0
- package/dist/cli/format.d.ts +4 -0
- package/dist/cli/format.js +44 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +158 -0
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +246 -0
- package/dist/manifest/lower.d.ts +22 -0
- package/dist/manifest/lower.js +913 -0
- package/dist/manifest/parse.d.ts +22 -0
- package/dist/manifest/parse.js +106 -0
- package/dist/manifest/schemas.d.ts +10359 -0
- package/dist/manifest/schemas.js +309 -0
- package/dist/manifest/types.d.ts +246 -0
- package/dist/manifest/types.js +12 -0
- package/dist/providers/configmap.d.ts +8 -0
- package/dist/providers/configmap.js +29 -0
- package/dist/providers/custom-domain.d.ts +11 -0
- package/dist/providers/custom-domain.js +120 -0
- package/dist/providers/d1-database.d.ts +9 -0
- package/dist/providers/d1-database.js +106 -0
- package/dist/providers/dispatch-namespace.d.ts +8 -0
- package/dist/providers/dispatch-namespace.js +100 -0
- package/dist/providers/dns-record.d.ts +14 -0
- package/dist/providers/dns-record.js +136 -0
- package/dist/providers/errors.d.ts +8 -0
- package/dist/providers/errors.js +64 -0
- package/dist/providers/hyperdrive.d.ts +27 -0
- package/dist/providers/hyperdrive.js +168 -0
- package/dist/providers/index.d.ts +6 -0
- package/dist/providers/index.js +36 -0
- package/dist/providers/kv-namespace.d.ts +8 -0
- package/dist/providers/kv-namespace.js +90 -0
- package/dist/providers/logpush-job.d.ts +17 -0
- package/dist/providers/logpush-job.js +181 -0
- package/dist/providers/queue.d.ts +10 -0
- package/dist/providers/queue.js +124 -0
- package/dist/providers/r2-bucket.d.ts +11 -0
- package/dist/providers/r2-bucket.js +98 -0
- package/dist/providers/registry.d.ts +9 -0
- package/dist/providers/registry.js +22 -0
- package/dist/providers/secret.d.ts +8 -0
- package/dist/providers/secret.js +30 -0
- package/dist/providers/types.d.ts +69 -0
- package/dist/providers/types.js +12 -0
- package/dist/providers/vectorize.d.ts +11 -0
- package/dist/providers/vectorize.js +110 -0
- package/dist/providers/worker.d.ts +106 -0
- package/dist/providers/worker.js +430 -0
- package/dist/providers/workflow.d.ts +10 -0
- package/dist/providers/workflow.js +103 -0
- package/dist/reconciler/apply.d.ts +10 -0
- package/dist/reconciler/apply.js +114 -0
- package/dist/reconciler/fake-provider.d.ts +48 -0
- package/dist/reconciler/fake-provider.js +83 -0
- package/dist/reconciler/plan.d.ts +6 -0
- package/dist/reconciler/plan.js +124 -0
- package/dist/reconciler/topo.d.ts +10 -0
- package/dist/reconciler/topo.js +53 -0
- package/dist/reconciler/types.d.ts +54 -0
- package/dist/reconciler/types.js +8 -0
- package/package.json +61 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { NotFound } from "./types.js";
|
|
3
|
+
import { toProviderError } from "./errors.js";
|
|
4
|
+
export const r2BucketSchema = z.object({
|
|
5
|
+
bucketName: z.string(),
|
|
6
|
+
location: z.enum(['wnam', 'enam', 'weur', 'eeur', 'apac', 'oc']).optional(),
|
|
7
|
+
storageClass: z.enum(['Standard', 'InfrequentAccess']).optional(),
|
|
8
|
+
});
|
|
9
|
+
const NAME_PREFIX = 'k1c-';
|
|
10
|
+
function parseLabel(name) {
|
|
11
|
+
if (!name.startsWith(NAME_PREFIX))
|
|
12
|
+
return null;
|
|
13
|
+
const rest = name.slice(NAME_PREFIX.length);
|
|
14
|
+
const dash = rest.indexOf('-');
|
|
15
|
+
if (dash <= 0 || dash === rest.length - 1)
|
|
16
|
+
return null;
|
|
17
|
+
const namespace = rest.slice(0, dash);
|
|
18
|
+
const objectName = rest.slice(dash + 1);
|
|
19
|
+
return `${namespace}/${objectName}`;
|
|
20
|
+
}
|
|
21
|
+
export const r2BucketProvider = {
|
|
22
|
+
resourceType: 'R2Bucket',
|
|
23
|
+
schema: r2BucketSchema,
|
|
24
|
+
async *list(ctx) {
|
|
25
|
+
let response;
|
|
26
|
+
try {
|
|
27
|
+
response = await ctx.cloudflare.r2.buckets.list({ account_id: ctx.accountId });
|
|
28
|
+
}
|
|
29
|
+
catch (raw) {
|
|
30
|
+
throw toProviderError(raw);
|
|
31
|
+
}
|
|
32
|
+
for (const bucket of response.buckets ?? []) {
|
|
33
|
+
const name = bucket.name;
|
|
34
|
+
if (!name)
|
|
35
|
+
continue;
|
|
36
|
+
const label = parseLabel(name);
|
|
37
|
+
if (label === null)
|
|
38
|
+
continue;
|
|
39
|
+
yield { nativeId: name, label };
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
async read(ctx, nativeId) {
|
|
43
|
+
try {
|
|
44
|
+
const bucket = await ctx.cloudflare.r2.buckets.get(nativeId, { account_id: ctx.accountId });
|
|
45
|
+
const props = {
|
|
46
|
+
bucketName: bucket.name ?? nativeId,
|
|
47
|
+
...(bucket.location ? { location: bucket.location } : {}),
|
|
48
|
+
...(bucket.storage_class ? { storageClass: bucket.storage_class } : {}),
|
|
49
|
+
};
|
|
50
|
+
return props;
|
|
51
|
+
}
|
|
52
|
+
catch (raw) {
|
|
53
|
+
const err = toProviderError(raw);
|
|
54
|
+
if (err.code === 'NotFound')
|
|
55
|
+
return NotFound;
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
async create(ctx, _label, desired) {
|
|
60
|
+
try {
|
|
61
|
+
const result = await ctx.cloudflare.r2.buckets.create({
|
|
62
|
+
account_id: ctx.accountId,
|
|
63
|
+
name: desired.bucketName,
|
|
64
|
+
...(desired.location ? { locationHint: desired.location } : {}),
|
|
65
|
+
...(desired.storageClass ? { storageClass: desired.storageClass } : {}),
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
kind: 'sync',
|
|
69
|
+
nativeId: result.name ?? desired.bucketName,
|
|
70
|
+
properties: desired,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
catch (raw) {
|
|
74
|
+
throw toProviderError(raw);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
async update(_ctx, _nativeId, prior, desired) {
|
|
78
|
+
if (prior.location !== desired.location || prior.storageClass !== desired.storageClass) {
|
|
79
|
+
throw {
|
|
80
|
+
code: 'NotUpdatable',
|
|
81
|
+
recoverable: false,
|
|
82
|
+
suggest: 'recreate',
|
|
83
|
+
message: 'R2 bucket location and storage class are immutable; recreate to change.',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { kind: 'noop' };
|
|
87
|
+
},
|
|
88
|
+
async delete(ctx, nativeId) {
|
|
89
|
+
try {
|
|
90
|
+
await ctx.cloudflare.r2.buckets.delete(nativeId, { account_id: ctx.accountId });
|
|
91
|
+
return { kind: 'sync' };
|
|
92
|
+
}
|
|
93
|
+
catch (raw) {
|
|
94
|
+
throw toProviderError(raw);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=r2-bucket.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CloudflareResourceProvider } from './types.ts';
|
|
2
|
+
export declare class ProviderRegistry {
|
|
3
|
+
#private;
|
|
4
|
+
register<P>(provider: CloudflareResourceProvider<P>): void;
|
|
5
|
+
get(resourceType: string): CloudflareResourceProvider<unknown>;
|
|
6
|
+
has(resourceType: string): boolean;
|
|
7
|
+
types(): IterableIterator<string>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class ProviderRegistry {
|
|
2
|
+
#providers = new Map();
|
|
3
|
+
register(provider) {
|
|
4
|
+
if (this.#providers.has(provider.resourceType)) {
|
|
5
|
+
throw new Error(`provider already registered: ${provider.resourceType}`);
|
|
6
|
+
}
|
|
7
|
+
this.#providers.set(provider.resourceType, provider);
|
|
8
|
+
}
|
|
9
|
+
get(resourceType) {
|
|
10
|
+
const p = this.#providers.get(resourceType);
|
|
11
|
+
if (!p)
|
|
12
|
+
throw new Error(`no provider for resource type: ${resourceType}`);
|
|
13
|
+
return p;
|
|
14
|
+
}
|
|
15
|
+
has(resourceType) {
|
|
16
|
+
return this.#providers.has(resourceType);
|
|
17
|
+
}
|
|
18
|
+
*types() {
|
|
19
|
+
yield* this.#providers.keys();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CloudflareResourceProvider } from './types.ts';
|
|
3
|
+
export interface SecretProperties {
|
|
4
|
+
readonly stringData: Readonly<Record<string, string>>;
|
|
5
|
+
}
|
|
6
|
+
export declare const secretSchema: z.ZodType<SecretProperties>;
|
|
7
|
+
export declare const secretProvider: CloudflareResourceProvider<SecretProperties>;
|
|
8
|
+
//# sourceMappingURL=secret.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { NotFound } from "./types.js";
|
|
3
|
+
export const secretSchema = z.object({
|
|
4
|
+
stringData: z.record(z.string()),
|
|
5
|
+
});
|
|
6
|
+
export const secretProvider = {
|
|
7
|
+
resourceType: 'Secret',
|
|
8
|
+
schema: secretSchema,
|
|
9
|
+
async *list(_ctx) {
|
|
10
|
+
// Secrets are always inferred from referenced Workers and from the manifest itself.
|
|
11
|
+
return;
|
|
12
|
+
},
|
|
13
|
+
async read(_ctx, _nativeId) {
|
|
14
|
+
// Cloudflare returns secret names but never values. We rely on the manifest as the
|
|
15
|
+
// source of value truth; drift detection is hash-based via k1c.io/last-applied.
|
|
16
|
+
throw new Error('secretProvider.read should be served by the reconciler graph, not invoked directly');
|
|
17
|
+
},
|
|
18
|
+
async create(_ctx, _label, _desired) {
|
|
19
|
+
// Actual upload happens in the Worker provider; this records intent only.
|
|
20
|
+
return { kind: 'sync', nativeId: _label, properties: { keys: Object.keys(_desired.stringData) } };
|
|
21
|
+
},
|
|
22
|
+
async update(_ctx, _nativeId, _prior, _desired) {
|
|
23
|
+
return { kind: 'noop' };
|
|
24
|
+
},
|
|
25
|
+
async delete(_ctx, _nativeId) {
|
|
26
|
+
// Secret deletion is realised by the Worker provider when the binding is removed.
|
|
27
|
+
return { kind: 'sync' };
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type Cloudflare from 'cloudflare';
|
|
2
|
+
import type { ZodSchema } from 'zod';
|
|
3
|
+
export interface ProviderContext {
|
|
4
|
+
readonly cloudflare: Cloudflare;
|
|
5
|
+
readonly accountId: string;
|
|
6
|
+
readonly zoneId?: string;
|
|
7
|
+
readonly namespace: string;
|
|
8
|
+
readonly managedByLabel: string;
|
|
9
|
+
readonly signal: AbortSignal;
|
|
10
|
+
/**
|
|
11
|
+
* Read a local asset file (Worker entrypoint, etc.). Defaults to fs/promises.readFile.
|
|
12
|
+
* Tests inject a stub to avoid filesystem coupling.
|
|
13
|
+
*/
|
|
14
|
+
readonly readFile?: (path: string) => Promise<Uint8Array>;
|
|
15
|
+
}
|
|
16
|
+
export interface ListedResource {
|
|
17
|
+
readonly nativeId: string;
|
|
18
|
+
readonly label: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const NotFound: unique symbol;
|
|
21
|
+
export type NotFound = typeof NotFound;
|
|
22
|
+
export type CreateResult = {
|
|
23
|
+
readonly kind: 'sync';
|
|
24
|
+
readonly nativeId: string;
|
|
25
|
+
readonly properties: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: 'async';
|
|
28
|
+
readonly nativeId: string;
|
|
29
|
+
readonly opId: string;
|
|
30
|
+
};
|
|
31
|
+
export type UpdateResult = CreateResult | {
|
|
32
|
+
readonly kind: 'noop';
|
|
33
|
+
};
|
|
34
|
+
export type DeleteResult = {
|
|
35
|
+
readonly kind: 'sync';
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'async';
|
|
38
|
+
readonly opId: string;
|
|
39
|
+
};
|
|
40
|
+
export type StatusResult = {
|
|
41
|
+
readonly kind: 'pending';
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: 'success';
|
|
44
|
+
readonly properties: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: 'failure';
|
|
47
|
+
readonly error: ProviderError;
|
|
48
|
+
};
|
|
49
|
+
export type ProviderErrorCode = 'Throttling' | 'NotStabilized' | 'NetworkFailure' | 'ServiceInternalError' | 'ServiceTimeout' | 'AccessDenied' | 'NotUpdatable' | 'AlreadyExists' | 'NotFound' | 'InvalidRequest';
|
|
50
|
+
export interface ProviderError {
|
|
51
|
+
readonly code: ProviderErrorCode;
|
|
52
|
+
readonly recoverable: boolean;
|
|
53
|
+
readonly suggest?: 'recreate';
|
|
54
|
+
readonly message: string;
|
|
55
|
+
readonly cause?: unknown;
|
|
56
|
+
}
|
|
57
|
+
export declare const RECOVERABLE_CODES: Set<ProviderErrorCode>;
|
|
58
|
+
export declare function isRecoverable(code: ProviderErrorCode): boolean;
|
|
59
|
+
export interface CloudflareResourceProvider<P> {
|
|
60
|
+
readonly resourceType: string;
|
|
61
|
+
readonly schema: ZodSchema<P>;
|
|
62
|
+
list(ctx: ProviderContext): AsyncIterable<ListedResource>;
|
|
63
|
+
read(ctx: ProviderContext, nativeId: string): Promise<P | NotFound>;
|
|
64
|
+
create(ctx: ProviderContext, label: string, desired: P): Promise<CreateResult>;
|
|
65
|
+
update(ctx: ProviderContext, nativeId: string, prior: P, desired: P): Promise<UpdateResult>;
|
|
66
|
+
delete(ctx: ProviderContext, nativeId: string): Promise<DeleteResult>;
|
|
67
|
+
status?(ctx: ProviderContext, nativeId: string, opId: string): Promise<StatusResult>;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const NotFound = Symbol('NotFound');
|
|
2
|
+
export const RECOVERABLE_CODES = new Set([
|
|
3
|
+
'Throttling',
|
|
4
|
+
'NotStabilized',
|
|
5
|
+
'NetworkFailure',
|
|
6
|
+
'ServiceInternalError',
|
|
7
|
+
'ServiceTimeout',
|
|
8
|
+
]);
|
|
9
|
+
export function isRecoverable(code) {
|
|
10
|
+
return RECOVERABLE_CODES.has(code);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CloudflareResourceProvider } from './types.ts';
|
|
3
|
+
export interface VectorizeProperties {
|
|
4
|
+
readonly indexName: string;
|
|
5
|
+
readonly dimensions: number;
|
|
6
|
+
readonly metric: 'cosine' | 'euclidean' | 'dot-product';
|
|
7
|
+
readonly description?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const vectorizePropsSchema: z.ZodType<VectorizeProperties>;
|
|
10
|
+
export declare const vectorizeProvider: CloudflareResourceProvider<VectorizeProperties>;
|
|
11
|
+
//# sourceMappingURL=vectorize.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { NotFound } from "./types.js";
|
|
3
|
+
import { toProviderError } from "./errors.js";
|
|
4
|
+
export const vectorizePropsSchema = z.object({
|
|
5
|
+
indexName: z.string(),
|
|
6
|
+
dimensions: z.number().int().positive(),
|
|
7
|
+
metric: z.enum(['cosine', 'euclidean', 'dot-product']),
|
|
8
|
+
description: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
const NAME_PREFIX = 'k1c-';
|
|
11
|
+
function parseLabel(name) {
|
|
12
|
+
if (!name.startsWith(NAME_PREFIX))
|
|
13
|
+
return null;
|
|
14
|
+
const rest = name.slice(NAME_PREFIX.length);
|
|
15
|
+
const dash = rest.indexOf('-');
|
|
16
|
+
if (dash <= 0 || dash === rest.length - 1)
|
|
17
|
+
return null;
|
|
18
|
+
return `${rest.slice(0, dash)}/${rest.slice(dash + 1)}`;
|
|
19
|
+
}
|
|
20
|
+
export const vectorizeProvider = {
|
|
21
|
+
resourceType: 'Vectorize',
|
|
22
|
+
schema: vectorizePropsSchema,
|
|
23
|
+
async *list(ctx) {
|
|
24
|
+
let iter;
|
|
25
|
+
try {
|
|
26
|
+
iter = ctx.cloudflare.vectorize.indexes.list({ account_id: ctx.accountId });
|
|
27
|
+
}
|
|
28
|
+
catch (raw) {
|
|
29
|
+
throw toProviderError(raw);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
for await (const idx of iter) {
|
|
33
|
+
const name = idx.name;
|
|
34
|
+
if (!name)
|
|
35
|
+
continue;
|
|
36
|
+
const label = parseLabel(name);
|
|
37
|
+
if (label === null)
|
|
38
|
+
continue;
|
|
39
|
+
// Vectorize uses the index name as its identifier; no separate UUID.
|
|
40
|
+
yield { nativeId: name, label };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (raw) {
|
|
44
|
+
throw toProviderError(raw);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
async read(ctx, nativeId) {
|
|
48
|
+
try {
|
|
49
|
+
const idx = await ctx.cloudflare.vectorize.indexes.get(nativeId, {
|
|
50
|
+
account_id: ctx.accountId,
|
|
51
|
+
});
|
|
52
|
+
if (idx === null)
|
|
53
|
+
return NotFound;
|
|
54
|
+
const i = idx;
|
|
55
|
+
if (!i.name || !i.config?.dimensions || !i.config?.metric)
|
|
56
|
+
return NotFound;
|
|
57
|
+
return {
|
|
58
|
+
indexName: i.name,
|
|
59
|
+
dimensions: i.config.dimensions,
|
|
60
|
+
metric: i.config.metric,
|
|
61
|
+
...(i.description !== undefined ? { description: i.description } : {}),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
catch (raw) {
|
|
65
|
+
const err = toProviderError(raw);
|
|
66
|
+
if (err.code === 'NotFound')
|
|
67
|
+
return NotFound;
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
async create(ctx, _label, desired) {
|
|
72
|
+
try {
|
|
73
|
+
const idx = await ctx.cloudflare.vectorize.indexes.create({
|
|
74
|
+
account_id: ctx.accountId,
|
|
75
|
+
name: desired.indexName,
|
|
76
|
+
config: { dimensions: desired.dimensions, metric: desired.metric },
|
|
77
|
+
...(desired.description !== undefined ? { description: desired.description } : {}),
|
|
78
|
+
});
|
|
79
|
+
const name = idx?.name ?? desired.indexName;
|
|
80
|
+
return { kind: 'sync', nativeId: name, properties: desired };
|
|
81
|
+
}
|
|
82
|
+
catch (raw) {
|
|
83
|
+
throw toProviderError(raw);
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async update(_ctx, _nativeId, prior, desired) {
|
|
87
|
+
// Vectorize indexes are immutable: dimensions, metric, and name cannot be changed.
|
|
88
|
+
if (prior.indexName !== desired.indexName ||
|
|
89
|
+
prior.dimensions !== desired.dimensions ||
|
|
90
|
+
prior.metric !== desired.metric) {
|
|
91
|
+
throw {
|
|
92
|
+
code: 'NotUpdatable',
|
|
93
|
+
recoverable: false,
|
|
94
|
+
suggest: 'recreate',
|
|
95
|
+
message: 'Vectorize index name / dimensions / metric are immutable; recreate to change.',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return { kind: 'noop' };
|
|
99
|
+
},
|
|
100
|
+
async delete(ctx, nativeId) {
|
|
101
|
+
try {
|
|
102
|
+
await ctx.cloudflare.vectorize.indexes.delete(nativeId, { account_id: ctx.accountId });
|
|
103
|
+
return { kind: 'sync' };
|
|
104
|
+
}
|
|
105
|
+
catch (raw) {
|
|
106
|
+
throw toProviderError(raw);
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=vectorize.js.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CloudflareResourceProvider } from './types.ts';
|
|
3
|
+
export interface WorkerProperties {
|
|
4
|
+
readonly scriptName: string;
|
|
5
|
+
readonly entrypoint: string;
|
|
6
|
+
readonly compatibilityDate: string;
|
|
7
|
+
readonly compatibilityFlags?: ReadonlyArray<string>;
|
|
8
|
+
readonly vars?: Readonly<Record<string, string>>;
|
|
9
|
+
readonly secrets?: Readonly<Record<string, string>>;
|
|
10
|
+
readonly bindings?: ReadonlyArray<WorkerBinding>;
|
|
11
|
+
readonly observability?: {
|
|
12
|
+
readonly enabled: boolean;
|
|
13
|
+
};
|
|
14
|
+
readonly placement?: {
|
|
15
|
+
readonly mode: 'smart';
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* If set, the Worker is uploaded to a Workers for Platforms dispatch namespace
|
|
19
|
+
* (`scripts.update` on the namespace endpoint, no versioned deployment) instead of as a
|
|
20
|
+
* top-level Worker. Used by canary Rollouts to register the stable / candidate variants.
|
|
21
|
+
*/
|
|
22
|
+
readonly dispatchNamespace?: string;
|
|
23
|
+
/**
|
|
24
|
+
* If set, this string is uploaded as the script body verbatim and `entrypoint` is
|
|
25
|
+
* ignored for I/O. Used for k1c-generated workers (dispatcher, etc.) whose source is
|
|
26
|
+
* synthesized in-process rather than read from disk.
|
|
27
|
+
*/
|
|
28
|
+
readonly entrypointContent?: string;
|
|
29
|
+
/**
|
|
30
|
+
* SHA-256 hex of the entrypoint bytes. Computed by lower; round-tripped through
|
|
31
|
+
* `metadata.tags` as `k1c.io/content-hash=<hash>` so the read path can reconstruct
|
|
32
|
+
* it from the live script and propertiesEqual catches file-only edits.
|
|
33
|
+
*/
|
|
34
|
+
readonly entrypointHash?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Cron expressions wired to the script via `cloudflare.workers.scripts.schedules`.
|
|
37
|
+
* Set by lowerCronJob; an empty array (or undefined) means the script has no
|
|
38
|
+
* cron triggers.
|
|
39
|
+
*/
|
|
40
|
+
readonly cronSchedules?: ReadonlyArray<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Durable Object class names this Worker defines. Lowering a `StatefulSet` populates
|
|
43
|
+
* this. The Worker provider:
|
|
44
|
+
* - emits one `durable_object_namespace` self-binding per class
|
|
45
|
+
* - on first deploy (no `k1c.io/do-classes=` tag in prior), declares them via
|
|
46
|
+
* `metadata.migrations.new_sqlite_classes`. Adding / removing classes on a
|
|
47
|
+
* later apply is **not yet implemented** in v0.2; CF will reject migrations
|
|
48
|
+
* that try to redeclare an existing class.
|
|
49
|
+
*/
|
|
50
|
+
readonly durableObjectClasses?: ReadonlyArray<string>;
|
|
51
|
+
}
|
|
52
|
+
export type WorkerBinding = {
|
|
53
|
+
readonly type: 'r2_bucket';
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly bucketName: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: 'kv_namespace';
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly namespaceId: string;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: 'service';
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly service: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: 'dispatch_namespace';
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly dispatchNamespace: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: 'hyperdrive';
|
|
70
|
+
readonly name: string;
|
|
71
|
+
readonly hyperdriveId: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: 'd1';
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly databaseId: string;
|
|
76
|
+
} | {
|
|
77
|
+
readonly type: 'queue';
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly queueName: string;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: 'durable_object_namespace';
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly className: string;
|
|
84
|
+
/** When the DO class lives in another script, set this to that script's name. */
|
|
85
|
+
readonly scriptName?: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly type: 'vectorize';
|
|
88
|
+
readonly name: string;
|
|
89
|
+
readonly indexName: string;
|
|
90
|
+
} | {
|
|
91
|
+
readonly type: 'ai';
|
|
92
|
+
readonly name: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly type: 'browser';
|
|
95
|
+
readonly name: string;
|
|
96
|
+
} | {
|
|
97
|
+
readonly type: 'version_metadata';
|
|
98
|
+
readonly name: string;
|
|
99
|
+
} | {
|
|
100
|
+
readonly type: 'analytics_engine';
|
|
101
|
+
readonly name: string;
|
|
102
|
+
readonly dataset: string;
|
|
103
|
+
};
|
|
104
|
+
export declare const workerSchema: z.ZodType<WorkerProperties>;
|
|
105
|
+
export declare const workerProvider: CloudflareResourceProvider<WorkerProperties>;
|
|
106
|
+
//# sourceMappingURL=worker.d.ts.map
|