@develit-io/backend-sdk 5.24.4 → 5.26.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const worker = require('../shared/backend-sdk.BiHu-BlC.cjs');
3
+ const worker = require('../shared/backend-sdk.DRtTRYdh.cjs');
4
4
  const cloudflare = require('alchemy/cloudflare');
5
5
  const environment_consts = require('../shared/backend-sdk.BdcrYpFD.cjs');
6
6
  require('@std/path');
@@ -144,7 +144,15 @@ class Infrastructure {
144
144
  * Creates an instance of Cloudflare Worker.
145
145
  */
146
146
  async worker(options) {
147
- const { resourceName, resource, path, crons, bindings, eventSources } = options;
147
+ const {
148
+ resourceName,
149
+ resource,
150
+ path,
151
+ assets,
152
+ crons,
153
+ bindings,
154
+ eventSources
155
+ } = options;
148
156
  const identifierName = composeIdentifierName({
149
157
  resourceName,
150
158
  resource: resource || "worker"
@@ -160,6 +168,7 @@ class Infrastructure {
160
168
  }),
161
169
  // TODO: Convert to util
162
170
  entrypoint: `${path}/src/index.ts`,
171
+ assets,
163
172
  crons: crons || worker.extractWorkerCrons({
164
173
  workerConfig,
165
174
  environment: this.environment
@@ -183,6 +192,34 @@ class Infrastructure {
183
192
  eventSources
184
193
  });
185
194
  }
195
+ /**
196
+ * Creates an instance of Cloudflare Worker as an orchestrator.
197
+ */
198
+ async orchestrator(options) {
199
+ const { resourceName, bindings, eventSources } = options;
200
+ return await this.worker({
201
+ resourceName,
202
+ resource: "orchestrator",
203
+ // TODO: Convert to util
204
+ path: `./apps/${resourceName}`,
205
+ bindings,
206
+ eventSources
207
+ });
208
+ }
209
+ /**
210
+ * Creates an instance of Cloudflare Worker as a client.
211
+ */
212
+ async client(options) {
213
+ const { resourceName, assets, bindings } = options;
214
+ return await this.worker({
215
+ resourceName,
216
+ resource: "orchestrator",
217
+ // TODO: Convert to util
218
+ path: `./apps/${resourceName}`,
219
+ assets,
220
+ bindings
221
+ });
222
+ }
186
223
  }
187
224
 
188
225
  const validateEnvironment = (environment) => {
@@ -1,9 +1,8 @@
1
1
  import { P as Project } from '../shared/backend-sdk.B5vcbB2_.cjs';
2
2
  import { E as Environment } from '../shared/backend-sdk.D5vSybcI.cjs';
3
3
  import { KVNamespace, D1Database, Queue, R2Bucket, Bindings, Worker } from 'alchemy/cloudflare';
4
- import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.CkewpXu0.cjs';
5
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.CkewpXu0.cjs';
6
- import 'comment-json';
4
+ import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.Cb-705pK.cjs';
5
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.Cb-705pK.cjs';
7
6
 
8
7
  declare class Infrastructure {
9
8
  private project;
@@ -76,6 +75,10 @@ declare class Infrastructure {
76
75
  * Path to the root of the Worker.
77
76
  */
78
77
  path: string;
78
+ /**
79
+ * Static assets of the Worker.
80
+ */
81
+ assets?: Bindings;
79
82
  /**
80
83
  * Cron expressions for the trigger of the Worker.
81
84
  */
@@ -106,6 +109,40 @@ declare class Infrastructure {
106
109
  */
107
110
  eventSources?: Queue[];
108
111
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
112
+ /**
113
+ * Creates an instance of Cloudflare Worker as an orchestrator.
114
+ */
115
+ orchestrator(options: {
116
+ /**
117
+ * Name of the orchestrator. Do not include the 'orchestrator' prefix.
118
+ */
119
+ resourceName: string;
120
+ /**
121
+ * Bindings of the Worker.
122
+ */
123
+ bindings?: Bindings;
124
+ /**
125
+ * Event sources for the orchestrator to consume.
126
+ */
127
+ eventSources?: Queue[];
128
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
129
+ /**
130
+ * Creates an instance of Cloudflare Worker as a client.
131
+ */
132
+ client(options: {
133
+ /**
134
+ * Name of the client. Do not include the 'client' prefix.
135
+ */
136
+ resourceName: string;
137
+ /**
138
+ * Static assets of the Worker.
139
+ */
140
+ assets?: Bindings;
141
+ /**
142
+ * Bindings of the Worker.
143
+ */
144
+ bindings?: Bindings;
145
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
109
146
  }
110
147
 
111
148
  declare const composeD1Arguments: ({ resourceName, }: {
@@ -1,9 +1,8 @@
1
1
  import { P as Project } from '../shared/backend-sdk.B5vcbB2_.mjs';
2
2
  import { E as Environment } from '../shared/backend-sdk.D5vSybcI.mjs';
3
3
  import { KVNamespace, D1Database, Queue, R2Bucket, Bindings, Worker } from 'alchemy/cloudflare';
4
- import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.5XEqGlkD.mjs';
5
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.5XEqGlkD.mjs';
6
- import 'comment-json';
4
+ import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.CUuG2-SC.mjs';
5
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.CUuG2-SC.mjs';
7
6
 
8
7
  declare class Infrastructure {
9
8
  private project;
@@ -76,6 +75,10 @@ declare class Infrastructure {
76
75
  * Path to the root of the Worker.
77
76
  */
78
77
  path: string;
78
+ /**
79
+ * Static assets of the Worker.
80
+ */
81
+ assets?: Bindings;
79
82
  /**
80
83
  * Cron expressions for the trigger of the Worker.
81
84
  */
@@ -106,6 +109,40 @@ declare class Infrastructure {
106
109
  */
107
110
  eventSources?: Queue[];
108
111
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
112
+ /**
113
+ * Creates an instance of Cloudflare Worker as an orchestrator.
114
+ */
115
+ orchestrator(options: {
116
+ /**
117
+ * Name of the orchestrator. Do not include the 'orchestrator' prefix.
118
+ */
119
+ resourceName: string;
120
+ /**
121
+ * Bindings of the Worker.
122
+ */
123
+ bindings?: Bindings;
124
+ /**
125
+ * Event sources for the orchestrator to consume.
126
+ */
127
+ eventSources?: Queue[];
128
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
129
+ /**
130
+ * Creates an instance of Cloudflare Worker as a client.
131
+ */
132
+ client(options: {
133
+ /**
134
+ * Name of the client. Do not include the 'client' prefix.
135
+ */
136
+ resourceName: string;
137
+ /**
138
+ * Static assets of the Worker.
139
+ */
140
+ assets?: Bindings;
141
+ /**
142
+ * Bindings of the Worker.
143
+ */
144
+ bindings?: Bindings;
145
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
109
146
  }
110
147
 
111
148
  declare const composeD1Arguments: ({ resourceName, }: {
@@ -1,9 +1,8 @@
1
1
  import { P as Project } from '../shared/backend-sdk.B5vcbB2_.js';
2
2
  import { E as Environment } from '../shared/backend-sdk.D5vSybcI.js';
3
3
  import { KVNamespace, D1Database, Queue, R2Bucket, Bindings, Worker } from 'alchemy/cloudflare';
4
- import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.DXHTs6BM.js';
5
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.DXHTs6BM.js';
6
- import 'comment-json';
4
+ import { W as WorkerType$1, R as Resource } from '../shared/backend-sdk.Cpbr7RlX.js';
5
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.Cpbr7RlX.js';
7
6
 
8
7
  declare class Infrastructure {
9
8
  private project;
@@ -76,6 +75,10 @@ declare class Infrastructure {
76
75
  * Path to the root of the Worker.
77
76
  */
78
77
  path: string;
78
+ /**
79
+ * Static assets of the Worker.
80
+ */
81
+ assets?: Bindings;
79
82
  /**
80
83
  * Cron expressions for the trigger of the Worker.
81
84
  */
@@ -106,6 +109,40 @@ declare class Infrastructure {
106
109
  */
107
110
  eventSources?: Queue[];
108
111
  }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
112
+ /**
113
+ * Creates an instance of Cloudflare Worker as an orchestrator.
114
+ */
115
+ orchestrator(options: {
116
+ /**
117
+ * Name of the orchestrator. Do not include the 'orchestrator' prefix.
118
+ */
119
+ resourceName: string;
120
+ /**
121
+ * Bindings of the Worker.
122
+ */
123
+ bindings?: Bindings;
124
+ /**
125
+ * Event sources for the orchestrator to consume.
126
+ */
127
+ eventSources?: Queue[];
128
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
129
+ /**
130
+ * Creates an instance of Cloudflare Worker as a client.
131
+ */
132
+ client(options: {
133
+ /**
134
+ * Name of the client. Do not include the 'client' prefix.
135
+ */
136
+ resourceName: string;
137
+ /**
138
+ * Static assets of the Worker.
139
+ */
140
+ assets?: Bindings;
141
+ /**
142
+ * Bindings of the Worker.
143
+ */
144
+ bindings?: Bindings;
145
+ }): Promise<Worker<Bindings, Rpc.WorkerEntrypointBranded>>;
109
146
  }
110
147
 
111
148
  declare const composeD1Arguments: ({ resourceName, }: {
@@ -1,4 +1,4 @@
1
- import { D as D1_LOCATION_HINT, Q as QUEUE_MESSAGE_RETENTION_PERIOD, a as QUEUE_DELIVERY_DELAY, R as R2_STORAGE_CLASS, b as R2_LOCATION_HINT, d as R2_JURISDICTION, l as loadWorkerConfig, c as composeWorkerArguments, e as extractWorkerCrons } from '../shared/backend-sdk.DiW9aySx.mjs';
1
+ import { D as D1_LOCATION_HINT, Q as QUEUE_MESSAGE_RETENTION_PERIOD, a as QUEUE_DELIVERY_DELAY, R as R2_STORAGE_CLASS, b as R2_LOCATION_HINT, d as R2_JURISDICTION, l as loadWorkerConfig, c as composeWorkerArguments, e as extractWorkerCrons } from '../shared/backend-sdk.670b7XEP.mjs';
2
2
  import { KVNamespace, D1Database, Queue, R2Bucket, Worker } from 'alchemy/cloudflare';
3
3
  import { E as ENVIRONMENT } from '../shared/backend-sdk.DXRpnctc.mjs';
4
4
  import '@std/path';
@@ -142,7 +142,15 @@ class Infrastructure {
142
142
  * Creates an instance of Cloudflare Worker.
143
143
  */
144
144
  async worker(options) {
145
- const { resourceName, resource, path, crons, bindings, eventSources } = options;
145
+ const {
146
+ resourceName,
147
+ resource,
148
+ path,
149
+ assets,
150
+ crons,
151
+ bindings,
152
+ eventSources
153
+ } = options;
146
154
  const identifierName = composeIdentifierName({
147
155
  resourceName,
148
156
  resource: resource || "worker"
@@ -158,6 +166,7 @@ class Infrastructure {
158
166
  }),
159
167
  // TODO: Convert to util
160
168
  entrypoint: `${path}/src/index.ts`,
169
+ assets,
161
170
  crons: crons || extractWorkerCrons({
162
171
  workerConfig,
163
172
  environment: this.environment
@@ -181,6 +190,34 @@ class Infrastructure {
181
190
  eventSources
182
191
  });
183
192
  }
193
+ /**
194
+ * Creates an instance of Cloudflare Worker as an orchestrator.
195
+ */
196
+ async orchestrator(options) {
197
+ const { resourceName, bindings, eventSources } = options;
198
+ return await this.worker({
199
+ resourceName,
200
+ resource: "orchestrator",
201
+ // TODO: Convert to util
202
+ path: `./apps/${resourceName}`,
203
+ bindings,
204
+ eventSources
205
+ });
206
+ }
207
+ /**
208
+ * Creates an instance of Cloudflare Worker as a client.
209
+ */
210
+ async client(options) {
211
+ const { resourceName, assets, bindings } = options;
212
+ return await this.worker({
213
+ resourceName,
214
+ resource: "orchestrator",
215
+ // TODO: Convert to util
216
+ path: `./apps/${resourceName}`,
217
+ assets,
218
+ bindings
219
+ });
220
+ }
184
221
  }
185
222
 
186
223
  const validateEnvironment = (environment) => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const worker = require('../shared/backend-sdk.BiHu-BlC.cjs');
3
+ const worker = require('../shared/backend-sdk.DRtTRYdh.cjs');
4
4
  require('../shared/backend-sdk.BdcrYpFD.cjs');
5
5
  require('@std/path');
6
6
  require('comment-json');
@@ -1,4 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.CkewpXu0.cjs';
2
- import 'comment-json';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.Cb-705pK.cjs';
3
2
  import 'alchemy/cloudflare';
4
3
  import '../shared/backend-sdk.D5vSybcI.cjs';
@@ -1,4 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.5XEqGlkD.mjs';
2
- import 'comment-json';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.CUuG2-SC.mjs';
3
2
  import 'alchemy/cloudflare';
4
3
  import '../shared/backend-sdk.D5vSybcI.mjs';
@@ -1,4 +1,3 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.DXHTs6BM.js';
2
- import 'comment-json';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.Cpbr7RlX.js';
3
2
  import 'alchemy/cloudflare';
4
3
  import '../shared/backend-sdk.D5vSybcI.js';
@@ -1,4 +1,4 @@
1
- export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.DiW9aySx.mjs';
1
+ export { c as composeWorkerArguments, e as extractWorkerCrons, l as loadWorkerConfig } from '../shared/backend-sdk.670b7XEP.mjs';
2
2
  import '../shared/backend-sdk.DXRpnctc.mjs';
3
3
  import '@std/path';
4
4
  import 'comment-json';
@@ -13,7 +13,11 @@ const R2_LOCATION_HINT = "weur";
13
13
 
14
14
  const loadWorkerConfig = async ({ path }) => {
15
15
  const workerConfigFile = Bun.file(join(path, "./wrangler.jsonc"));
16
- return parse(await workerConfigFile.text(), null, true);
16
+ return parse(
17
+ await workerConfigFile.text(),
18
+ null,
19
+ true
20
+ );
17
21
  };
18
22
  const extractWorkerCrons = ({
19
23
  workerConfig,
@@ -27,6 +31,7 @@ const extractWorkerCrons = ({
27
31
  const composeWorkerArguments = ({
28
32
  resourceName,
29
33
  entrypoint,
34
+ assets,
30
35
  crons = [],
31
36
  bindings,
32
37
  eventSources = []
@@ -41,8 +46,9 @@ const composeWorkerArguments = ({
41
46
  },
42
47
  url: false,
43
48
  eventSources,
44
- bindings,
45
- crons
49
+ assets,
50
+ crons,
51
+ bindings
46
52
  };
47
53
  };
48
54
 
@@ -1,4 +1,3 @@
1
- import * as comment_json from 'comment-json';
2
1
  import { Bindings, Queue } from 'alchemy/cloudflare';
3
2
  import { E as Environment } from './backend-sdk.D5vSybcI.mjs';
4
3
 
@@ -19,14 +18,15 @@ interface WorkerConfig {
19
18
 
20
19
  declare const loadWorkerConfig: ({ path }: {
21
20
  path: string;
22
- }) => Promise<comment_json.CommentJSONValue>;
21
+ }) => Promise<WorkerConfig>;
23
22
  declare const extractWorkerCrons: ({ workerConfig, environment, }: {
24
23
  workerConfig: WorkerConfig;
25
24
  environment: Environment;
26
25
  }) => string[];
27
- declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindings, eventSources, }: {
26
+ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, crons, bindings, eventSources, }: {
28
27
  resourceName: string;
29
28
  entrypoint: string;
29
+ assets?: Bindings;
30
30
  crons?: string[];
31
31
  bindings?: Bindings;
32
32
  eventSources?: Queue[];
@@ -40,8 +40,9 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindin
40
40
  };
41
41
  url: false;
42
42
  eventSources: Queue[];
43
- bindings: Bindings | undefined;
43
+ assets: Bindings | undefined;
44
44
  crons: string[];
45
+ bindings: Bindings | undefined;
45
46
  };
46
47
 
47
48
  export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
@@ -1,4 +1,3 @@
1
- import * as comment_json from 'comment-json';
2
1
  import { Bindings, Queue } from 'alchemy/cloudflare';
3
2
  import { E as Environment } from './backend-sdk.D5vSybcI.cjs';
4
3
 
@@ -19,14 +18,15 @@ interface WorkerConfig {
19
18
 
20
19
  declare const loadWorkerConfig: ({ path }: {
21
20
  path: string;
22
- }) => Promise<comment_json.CommentJSONValue>;
21
+ }) => Promise<WorkerConfig>;
23
22
  declare const extractWorkerCrons: ({ workerConfig, environment, }: {
24
23
  workerConfig: WorkerConfig;
25
24
  environment: Environment;
26
25
  }) => string[];
27
- declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindings, eventSources, }: {
26
+ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, crons, bindings, eventSources, }: {
28
27
  resourceName: string;
29
28
  entrypoint: string;
29
+ assets?: Bindings;
30
30
  crons?: string[];
31
31
  bindings?: Bindings;
32
32
  eventSources?: Queue[];
@@ -40,8 +40,9 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindin
40
40
  };
41
41
  url: false;
42
42
  eventSources: Queue[];
43
- bindings: Bindings | undefined;
43
+ assets: Bindings | undefined;
44
44
  crons: string[];
45
+ bindings: Bindings | undefined;
45
46
  };
46
47
 
47
48
  export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
@@ -1,4 +1,3 @@
1
- import * as comment_json from 'comment-json';
2
1
  import { Bindings, Queue } from 'alchemy/cloudflare';
3
2
  import { E as Environment } from './backend-sdk.D5vSybcI.js';
4
3
 
@@ -19,14 +18,15 @@ interface WorkerConfig {
19
18
 
20
19
  declare const loadWorkerConfig: ({ path }: {
21
20
  path: string;
22
- }) => Promise<comment_json.CommentJSONValue>;
21
+ }) => Promise<WorkerConfig>;
23
22
  declare const extractWorkerCrons: ({ workerConfig, environment, }: {
24
23
  workerConfig: WorkerConfig;
25
24
  environment: Environment;
26
25
  }) => string[];
27
- declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindings, eventSources, }: {
26
+ declare const composeWorkerArguments: ({ resourceName, entrypoint, assets, crons, bindings, eventSources, }: {
28
27
  resourceName: string;
29
28
  entrypoint: string;
29
+ assets?: Bindings;
30
30
  crons?: string[];
31
31
  bindings?: Bindings;
32
32
  eventSources?: Queue[];
@@ -40,8 +40,9 @@ declare const composeWorkerArguments: ({ resourceName, entrypoint, crons, bindin
40
40
  };
41
41
  url: false;
42
42
  eventSources: Queue[];
43
- bindings: Bindings | undefined;
43
+ assets: Bindings | undefined;
44
44
  crons: string[];
45
+ bindings: Bindings | undefined;
45
46
  };
46
47
 
47
48
  export { composeWorkerArguments as c, extractWorkerCrons as e, loadWorkerConfig as l };
@@ -15,7 +15,11 @@ const R2_LOCATION_HINT = "weur";
15
15
 
16
16
  const loadWorkerConfig = async ({ path: path$1 }) => {
17
17
  const workerConfigFile = Bun.file(path.join(path$1, "./wrangler.jsonc"));
18
- return commentJson.parse(await workerConfigFile.text(), null, true);
18
+ return commentJson.parse(
19
+ await workerConfigFile.text(),
20
+ null,
21
+ true
22
+ );
19
23
  };
20
24
  const extractWorkerCrons = ({
21
25
  workerConfig,
@@ -29,6 +33,7 @@ const extractWorkerCrons = ({
29
33
  const composeWorkerArguments = ({
30
34
  resourceName,
31
35
  entrypoint,
36
+ assets,
32
37
  crons = [],
33
38
  bindings,
34
39
  eventSources = []
@@ -43,8 +48,9 @@ const composeWorkerArguments = ({
43
48
  },
44
49
  url: false,
45
50
  eventSources,
46
- bindings,
47
- crons
51
+ assets,
52
+ crons,
53
+ bindings
48
54
  };
49
55
  };
50
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-io/backend-sdk",
3
- "version": "5.24.4",
3
+ "version": "5.26.0",
4
4
  "description": "Develit Backend SDK",
5
5
  "author": "Develit.io",
6
6
  "license": "ISC",