oblaka-iac 0.0.12 → 0.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oblaka-iac",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "main": "./src/index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -0,0 +1,24 @@
1
+ import type { Bindable, Config } from '../types'
2
+
3
+ export class AiSearch implements Bindable {
4
+ constructor(
5
+ private readonly options: {
6
+ namespace: string
7
+ remote?: boolean
8
+ },
9
+ ) {}
10
+
11
+ configureBinding(args: { config: Config; binding: string; env: string }): Config {
12
+ return {
13
+ ...args.config,
14
+ ai_search_namespaces: [
15
+ ...(args.config.ai_search_namespaces ?? []),
16
+ {
17
+ binding: args.binding,
18
+ namespace: this.options.namespace,
19
+ remote: this.options.remote,
20
+ },
21
+ ],
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,28 @@
1
+ import type { Bindable, Config } from '../types'
2
+
3
+ export class EmailService implements Bindable {
4
+ constructor(
5
+ private readonly options?: {
6
+ destinationAddress?: string
7
+ allowedDestinationAddresses?: string[]
8
+ allowedSenderAddresses?: string[]
9
+ remote?: boolean
10
+ },
11
+ ) {}
12
+
13
+ configureBinding(args: { config: Config; binding: string; env: string }): Config {
14
+ return {
15
+ ...args.config,
16
+ send_email: [
17
+ ...(args.config.send_email ?? []),
18
+ {
19
+ name: args.binding,
20
+ destination_address: this.options?.destinationAddress,
21
+ allowed_destination_addresses: this.options?.allowedDestinationAddresses,
22
+ allowed_sender_addresses: this.options?.allowedSenderAddresses,
23
+ remote: this.options?.remote,
24
+ },
25
+ ],
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,22 @@
1
+ import type { Bindable, Config } from '../types'
2
+
3
+ export class Flagship implements Bindable {
4
+ constructor(
5
+ private readonly options: {
6
+ appId: string
7
+ },
8
+ ) {}
9
+
10
+ configureBinding(args: { config: Config; binding: string; env: string }): Config {
11
+ return {
12
+ ...args.config,
13
+ flagship: [
14
+ ...(args.config.flagship ?? []),
15
+ {
16
+ binding: args.binding,
17
+ app_id: this.options.appId,
18
+ },
19
+ ],
20
+ }
21
+ }
22
+ }
@@ -10,11 +10,14 @@ import { WorkerDestroyer } from './worker'
10
10
  import { WorkflowDestroyer } from './workflow'
11
11
 
12
12
  export * from './ai-gateway'
13
+ export * from './ai-search'
13
14
  export * from './analytics-engine'
14
15
  export * from './browser'
15
16
  export * from './container'
16
17
  export * from './d1'
17
18
  export * from './do'
19
+ export * from './email'
20
+ export * from './flagship'
18
21
  export * from './images'
19
22
  export * from './kv'
20
23
  export * from './queues'
@@ -22,7 +25,9 @@ export * from './r2'
22
25
  export * from './service-reference'
23
26
  export * from './vectorize'
24
27
  export * from './version-metadata'
28
+ export * from './vpc'
25
29
  export * from './worker'
30
+ export * from './worker-loader'
26
31
  export * from './workflow'
27
32
 
28
33
  export const destroyers: Destroyers = {
@@ -0,0 +1,34 @@
1
+ import type { Bindable, Config } from '../types'
2
+
3
+ export type VpcNetworkOptions =
4
+ | { networkId: string; remote?: boolean }
5
+ | { tunnelId: string; remote?: boolean }
6
+
7
+ export class VpcNetwork implements Bindable {
8
+ constructor(
9
+ private readonly options: VpcNetworkOptions,
10
+ ) {}
11
+
12
+ static mesh(options?: { remote?: boolean }): VpcNetwork {
13
+ return new VpcNetwork({ networkId: 'cf1:network', remote: options?.remote })
14
+ }
15
+
16
+ static tunnel(tunnelId: string, options?: { remote?: boolean }): VpcNetwork {
17
+ return new VpcNetwork({ tunnelId, remote: options?.remote })
18
+ }
19
+
20
+ configureBinding(args: { config: Config; binding: string; env: string }): Config {
21
+ return {
22
+ ...args.config,
23
+ vpc_networks: [
24
+ ...(args.config.vpc_networks ?? []),
25
+ {
26
+ binding: args.binding,
27
+ network_id: 'networkId' in this.options ? this.options.networkId : undefined,
28
+ tunnel_id: 'tunnelId' in this.options ? this.options.tunnelId : undefined,
29
+ remote: this.options.remote ?? true,
30
+ },
31
+ ],
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,13 @@
1
+ import type { Bindable, Config } from '../types'
2
+
3
+ export class WorkerLoader implements Bindable {
4
+ configureBinding(args: { config: Config; binding: string; env: string }): Config {
5
+ return {
6
+ ...args.config,
7
+ worker_loaders: [
8
+ ...(args.config.worker_loaders ?? []),
9
+ { binding: args.binding },
10
+ ],
11
+ }
12
+ }
13
+ }
package/src/types.ts CHANGED
@@ -12,7 +12,23 @@ export interface Context {
12
12
  client: CloudflareClient
13
13
  }
14
14
 
15
- export type Config = Unstable_RawEnvironment
15
+ export type Config = Unstable_RawEnvironment & {
16
+ vpc_networks?: Array<{
17
+ binding: string
18
+ network_id?: string
19
+ tunnel_id?: string
20
+ remote?: boolean
21
+ }>
22
+ ai_search_namespaces?: Array<{
23
+ binding: string
24
+ namespace: string
25
+ remote?: boolean
26
+ }>
27
+ flagship?: Array<{
28
+ binding: string
29
+ app_id: string
30
+ }>
31
+ }
16
32
 
17
33
  export type ResourceKind =
18
34
  | 'worker'