effortless-aws 0.29.0 → 0.31.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/dist/index.d.ts +537 -535
- package/dist/index.js +361 -87
- package/dist/index.js.map +1 -1
- package/dist/runtime/wrap-api.js +8 -6
- package/dist/runtime/wrap-bucket.js +3 -3
- package/dist/runtime/wrap-cron.js +40 -0
- package/dist/runtime/wrap-fifo-queue.js +3 -3
- package/dist/runtime/wrap-table-stream.js +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,28 +34,80 @@ var param = (key, transform) => {
|
|
|
34
34
|
var generateHex = (bytes) => `hex:${bytes}`;
|
|
35
35
|
var generateBase64 = (bytes) => `base64:${bytes}`;
|
|
36
36
|
var generateUuid = () => "uuid";
|
|
37
|
-
function unsafeAs() {
|
|
38
|
-
return (input) => input;
|
|
39
|
-
}
|
|
40
37
|
|
|
41
38
|
// src/handlers/define-table.ts
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
function defineTable(options) {
|
|
40
|
+
const {
|
|
41
|
+
schema,
|
|
42
|
+
...tableConfig
|
|
43
|
+
} = options ?? {};
|
|
44
|
+
const spec = { ...tableConfig };
|
|
45
|
+
const state = {
|
|
46
|
+
spec,
|
|
47
|
+
...schema ? { schema } : {}
|
|
48
|
+
};
|
|
49
|
+
const applyLambdaOptions = (lambda) => {
|
|
50
|
+
if (Object.keys(lambda).length > 0) {
|
|
51
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const finalize = () => ({
|
|
46
55
|
__brand: "effortless-table",
|
|
47
|
-
__spec,
|
|
48
|
-
...schema ? { schema } : {},
|
|
49
|
-
...onError ? { onError } : {},
|
|
50
|
-
...
|
|
51
|
-
...setup ? { setup } : {},
|
|
52
|
-
...deps ? { deps } : {},
|
|
53
|
-
...config ? { config } : {},
|
|
54
|
-
...
|
|
55
|
-
...onRecord ? { onRecord } : {},
|
|
56
|
-
...onRecordBatch ? { onRecordBatch } : {}
|
|
56
|
+
__spec: state.spec,
|
|
57
|
+
...state.schema ? { schema: state.schema } : {},
|
|
58
|
+
...state.onError ? { onError: state.onError } : {},
|
|
59
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
60
|
+
...state.setup ? { setup: state.setup } : {},
|
|
61
|
+
...state.deps ? { deps: state.deps } : {},
|
|
62
|
+
...state.config ? { config: state.config } : {},
|
|
63
|
+
...state.static ? { static: state.static } : {},
|
|
64
|
+
...state.onRecord ? { onRecord: state.onRecord } : {},
|
|
65
|
+
...state.onRecordBatch ? { onRecordBatch: state.onRecordBatch } : {}
|
|
66
|
+
});
|
|
67
|
+
const builder = {
|
|
68
|
+
deps(fn) {
|
|
69
|
+
state.deps = fn;
|
|
70
|
+
return builder;
|
|
71
|
+
},
|
|
72
|
+
config(fn) {
|
|
73
|
+
state.config = resolveConfigFactory(fn);
|
|
74
|
+
return builder;
|
|
75
|
+
},
|
|
76
|
+
include(glob) {
|
|
77
|
+
state.static = [...state.static ?? [], glob];
|
|
78
|
+
return builder;
|
|
79
|
+
},
|
|
80
|
+
setup(fnOrLambda, maybeLambda) {
|
|
81
|
+
if (typeof fnOrLambda === "function") {
|
|
82
|
+
state.setup = fnOrLambda;
|
|
83
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
84
|
+
} else {
|
|
85
|
+
applyLambdaOptions(fnOrLambda);
|
|
86
|
+
}
|
|
87
|
+
return builder;
|
|
88
|
+
},
|
|
89
|
+
onRecord(fn) {
|
|
90
|
+
state.onRecord = fn;
|
|
91
|
+
return finalize();
|
|
92
|
+
},
|
|
93
|
+
onRecordBatch(fn) {
|
|
94
|
+
state.onRecordBatch = fn;
|
|
95
|
+
return finalize();
|
|
96
|
+
},
|
|
97
|
+
onError(fn) {
|
|
98
|
+
state.onError = fn;
|
|
99
|
+
return builder;
|
|
100
|
+
},
|
|
101
|
+
onCleanup(fn) {
|
|
102
|
+
state.onCleanup = fn;
|
|
103
|
+
return builder;
|
|
104
|
+
},
|
|
105
|
+
build() {
|
|
106
|
+
return finalize();
|
|
107
|
+
}
|
|
57
108
|
};
|
|
58
|
-
|
|
109
|
+
return builder;
|
|
110
|
+
}
|
|
59
111
|
|
|
60
112
|
// src/handlers/define-app.ts
|
|
61
113
|
var defineApp = () => (options) => ({
|
|
@@ -70,41 +122,146 @@ var defineStaticSite = () => (options) => ({
|
|
|
70
122
|
});
|
|
71
123
|
|
|
72
124
|
// src/handlers/define-fifo-queue.ts
|
|
73
|
-
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
125
|
+
function defineFifoQueue(options) {
|
|
126
|
+
const {
|
|
127
|
+
schema,
|
|
128
|
+
...queueConfig
|
|
129
|
+
} = options ?? {};
|
|
130
|
+
const spec = { ...queueConfig };
|
|
131
|
+
const state = {
|
|
132
|
+
spec,
|
|
133
|
+
...schema ? { schema } : {}
|
|
134
|
+
};
|
|
135
|
+
const applyLambdaOptions = (lambda) => {
|
|
136
|
+
if (Object.keys(lambda).length > 0) {
|
|
137
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const finalize = () => ({
|
|
77
141
|
__brand: "effortless-fifo-queue",
|
|
78
|
-
__spec,
|
|
79
|
-
...schema ? { schema } : {},
|
|
80
|
-
...onError ? { onError } : {},
|
|
81
|
-
...
|
|
82
|
-
...setup ? { setup } : {},
|
|
83
|
-
...deps ? { deps } : {},
|
|
84
|
-
...config ? { config } : {},
|
|
85
|
-
...
|
|
86
|
-
...onMessage ? { onMessage } : {},
|
|
87
|
-
...onMessageBatch ? { onMessageBatch } : {}
|
|
142
|
+
__spec: state.spec,
|
|
143
|
+
...state.schema ? { schema: state.schema } : {},
|
|
144
|
+
...state.onError ? { onError: state.onError } : {},
|
|
145
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
146
|
+
...state.setup ? { setup: state.setup } : {},
|
|
147
|
+
...state.deps ? { deps: state.deps } : {},
|
|
148
|
+
...state.config ? { config: state.config } : {},
|
|
149
|
+
...state.static ? { static: state.static } : {},
|
|
150
|
+
...state.onMessage ? { onMessage: state.onMessage } : {},
|
|
151
|
+
...state.onMessageBatch ? { onMessageBatch: state.onMessageBatch } : {}
|
|
152
|
+
});
|
|
153
|
+
const builder = {
|
|
154
|
+
deps(fn) {
|
|
155
|
+
state.deps = fn;
|
|
156
|
+
return builder;
|
|
157
|
+
},
|
|
158
|
+
config(fn) {
|
|
159
|
+
state.config = resolveConfigFactory(fn);
|
|
160
|
+
return builder;
|
|
161
|
+
},
|
|
162
|
+
include(glob) {
|
|
163
|
+
state.static = [...state.static ?? [], glob];
|
|
164
|
+
return builder;
|
|
165
|
+
},
|
|
166
|
+
setup(fnOrLambda, maybeLambda) {
|
|
167
|
+
if (typeof fnOrLambda === "function") {
|
|
168
|
+
state.setup = fnOrLambda;
|
|
169
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
170
|
+
} else {
|
|
171
|
+
applyLambdaOptions(fnOrLambda);
|
|
172
|
+
}
|
|
173
|
+
return builder;
|
|
174
|
+
},
|
|
175
|
+
onMessage(fn) {
|
|
176
|
+
state.onMessage = fn;
|
|
177
|
+
return finalize();
|
|
178
|
+
},
|
|
179
|
+
onMessageBatch(fn) {
|
|
180
|
+
state.onMessageBatch = fn;
|
|
181
|
+
return finalize();
|
|
182
|
+
},
|
|
183
|
+
onError(fn) {
|
|
184
|
+
state.onError = fn;
|
|
185
|
+
return builder;
|
|
186
|
+
},
|
|
187
|
+
onCleanup(fn) {
|
|
188
|
+
state.onCleanup = fn;
|
|
189
|
+
return builder;
|
|
190
|
+
}
|
|
88
191
|
};
|
|
89
|
-
|
|
192
|
+
return builder;
|
|
193
|
+
}
|
|
90
194
|
|
|
91
195
|
// src/handlers/define-bucket.ts
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
196
|
+
function defineBucket(options) {
|
|
197
|
+
const bucketConfig = options ?? {};
|
|
198
|
+
const spec = {
|
|
199
|
+
...bucketConfig
|
|
200
|
+
};
|
|
201
|
+
const state = {
|
|
202
|
+
spec
|
|
203
|
+
};
|
|
204
|
+
const applyLambdaOptions = (lambda) => {
|
|
205
|
+
if (Object.keys(lambda).length > 0) {
|
|
206
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const finalize = () => ({
|
|
96
210
|
__brand: "effortless-bucket",
|
|
97
|
-
__spec,
|
|
98
|
-
...onError ? { onError } : {},
|
|
99
|
-
...
|
|
100
|
-
...setup ? { setup } : {},
|
|
101
|
-
...deps ? { deps } : {},
|
|
102
|
-
...config ? { config } : {},
|
|
103
|
-
...
|
|
104
|
-
...onObjectCreated ? { onObjectCreated } : {},
|
|
105
|
-
...onObjectRemoved ? { onObjectRemoved } : {}
|
|
211
|
+
__spec: state.spec,
|
|
212
|
+
...state.onError ? { onError: state.onError } : {},
|
|
213
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
214
|
+
...state.setup ? { setup: state.setup } : {},
|
|
215
|
+
...state.deps ? { deps: state.deps } : {},
|
|
216
|
+
...state.config ? { config: state.config } : {},
|
|
217
|
+
...state.static ? { static: state.static } : {},
|
|
218
|
+
...state.onObjectCreated ? { onObjectCreated: state.onObjectCreated } : {},
|
|
219
|
+
...state.onObjectRemoved ? { onObjectRemoved: state.onObjectRemoved } : {}
|
|
220
|
+
});
|
|
221
|
+
const builder = {
|
|
222
|
+
deps(fn) {
|
|
223
|
+
state.deps = fn;
|
|
224
|
+
return builder;
|
|
225
|
+
},
|
|
226
|
+
config(fn) {
|
|
227
|
+
state.config = resolveConfigFactory(fn);
|
|
228
|
+
return builder;
|
|
229
|
+
},
|
|
230
|
+
include(glob) {
|
|
231
|
+
state.static = [...state.static ?? [], glob];
|
|
232
|
+
return builder;
|
|
233
|
+
},
|
|
234
|
+
setup(fnOrLambda, maybeLambda) {
|
|
235
|
+
if (typeof fnOrLambda === "function") {
|
|
236
|
+
state.setup = fnOrLambda;
|
|
237
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
238
|
+
} else {
|
|
239
|
+
applyLambdaOptions(fnOrLambda);
|
|
240
|
+
}
|
|
241
|
+
return builder;
|
|
242
|
+
},
|
|
243
|
+
onObjectCreated(fn) {
|
|
244
|
+
state.onObjectCreated = fn;
|
|
245
|
+
return finalize();
|
|
246
|
+
},
|
|
247
|
+
onObjectRemoved(fn) {
|
|
248
|
+
state.onObjectRemoved = fn;
|
|
249
|
+
return finalize();
|
|
250
|
+
},
|
|
251
|
+
onError(fn) {
|
|
252
|
+
state.onError = fn;
|
|
253
|
+
return builder;
|
|
254
|
+
},
|
|
255
|
+
onCleanup(fn) {
|
|
256
|
+
state.onCleanup = fn;
|
|
257
|
+
return builder;
|
|
258
|
+
},
|
|
259
|
+
build() {
|
|
260
|
+
return finalize();
|
|
261
|
+
}
|
|
106
262
|
};
|
|
107
|
-
|
|
263
|
+
return builder;
|
|
264
|
+
}
|
|
108
265
|
|
|
109
266
|
// src/handlers/define-mailer.ts
|
|
110
267
|
var defineMailer = () => (options) => ({
|
|
@@ -113,51 +270,170 @@ var defineMailer = () => (options) => ({
|
|
|
113
270
|
});
|
|
114
271
|
|
|
115
272
|
// src/handlers/define-api.ts
|
|
116
|
-
|
|
117
|
-
const {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
...onError ? { onError } : {},
|
|
125
|
-
...onAfterInvoke ? { onAfterInvoke } : {},
|
|
126
|
-
...setup ? { setup } : {},
|
|
127
|
-
...deps ? { deps } : {},
|
|
128
|
-
...config ? { config } : {},
|
|
129
|
-
...staticFiles ? { static: staticFiles } : {}
|
|
273
|
+
function defineApi(options) {
|
|
274
|
+
const { basePath, stream } = options;
|
|
275
|
+
const state = {
|
|
276
|
+
spec: {
|
|
277
|
+
basePath,
|
|
278
|
+
...stream ? { stream } : {}
|
|
279
|
+
},
|
|
280
|
+
routes: []
|
|
130
281
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
path,
|
|
139
|
-
onRequest: route.onRequest,
|
|
140
|
-
...route.public ? { public: true } : {}
|
|
282
|
+
const addRoute = (method, path, handler, opts) => {
|
|
283
|
+
state.routes.push({
|
|
284
|
+
method,
|
|
285
|
+
path,
|
|
286
|
+
onRequest: handler,
|
|
287
|
+
...opts?.public ? { public: true } : {}
|
|
288
|
+
});
|
|
141
289
|
};
|
|
142
|
-
|
|
290
|
+
const applyLambdaOptions = (lambda) => {
|
|
291
|
+
if (Object.keys(lambda).length > 0) {
|
|
292
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const finalize = () => {
|
|
296
|
+
const handler = {
|
|
297
|
+
__brand: "effortless-api",
|
|
298
|
+
__spec: state.spec,
|
|
299
|
+
routes: state.routes,
|
|
300
|
+
...state.onError ? { onError: state.onError } : {},
|
|
301
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
302
|
+
...state.setup ? { setup: state.setup } : {},
|
|
303
|
+
...state.deps ? { deps: state.deps } : {},
|
|
304
|
+
...state.config ? { config: state.config } : {},
|
|
305
|
+
...state.static ? { static: state.static } : {}
|
|
306
|
+
};
|
|
307
|
+
for (const m of ["get", "post", "put", "patch", "delete"]) {
|
|
308
|
+
handler[m] = (path, fn, opts) => {
|
|
309
|
+
addRoute(m.toUpperCase(), path, fn, opts);
|
|
310
|
+
handler.routes = state.routes;
|
|
311
|
+
return handler;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return handler;
|
|
315
|
+
};
|
|
316
|
+
const builder = {
|
|
317
|
+
deps(fn) {
|
|
318
|
+
state.deps = fn;
|
|
319
|
+
return builder;
|
|
320
|
+
},
|
|
321
|
+
config(fn) {
|
|
322
|
+
state.config = resolveConfigFactory(fn);
|
|
323
|
+
return builder;
|
|
324
|
+
},
|
|
325
|
+
include(glob) {
|
|
326
|
+
state.static = [...state.static ?? [], glob];
|
|
327
|
+
return builder;
|
|
328
|
+
},
|
|
329
|
+
setup(fnOrLambda, maybeLambda) {
|
|
330
|
+
if (typeof fnOrLambda === "function") {
|
|
331
|
+
state.setup = fnOrLambda;
|
|
332
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
333
|
+
} else {
|
|
334
|
+
applyLambdaOptions(fnOrLambda);
|
|
335
|
+
}
|
|
336
|
+
return builder;
|
|
337
|
+
},
|
|
338
|
+
onError(fn) {
|
|
339
|
+
state.onError = fn;
|
|
340
|
+
return builder;
|
|
341
|
+
},
|
|
342
|
+
onCleanup(fn) {
|
|
343
|
+
state.onCleanup = fn;
|
|
344
|
+
return builder;
|
|
345
|
+
},
|
|
346
|
+
get(path, handler, opts) {
|
|
347
|
+
addRoute("GET", path, handler, opts);
|
|
348
|
+
return finalize();
|
|
349
|
+
},
|
|
350
|
+
post(path, handler, opts) {
|
|
351
|
+
addRoute("POST", path, handler, opts);
|
|
352
|
+
return finalize();
|
|
353
|
+
},
|
|
354
|
+
put(path, handler, opts) {
|
|
355
|
+
addRoute("PUT", path, handler, opts);
|
|
356
|
+
return finalize();
|
|
357
|
+
},
|
|
358
|
+
patch(path, handler, opts) {
|
|
359
|
+
addRoute("PATCH", path, handler, opts);
|
|
360
|
+
return finalize();
|
|
361
|
+
},
|
|
362
|
+
delete(path, handler, opts) {
|
|
363
|
+
addRoute("DELETE", path, handler, opts);
|
|
364
|
+
return finalize();
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
return builder;
|
|
368
|
+
}
|
|
143
369
|
|
|
144
|
-
// src/handlers/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
370
|
+
// src/handlers/define-cron.ts
|
|
371
|
+
function defineCron(options) {
|
|
372
|
+
const { schedule, timezone } = options;
|
|
373
|
+
const spec = {
|
|
374
|
+
schedule,
|
|
375
|
+
...timezone ? { timezone } : {}
|
|
376
|
+
};
|
|
377
|
+
const state = { spec };
|
|
378
|
+
const applyLambdaOptions = (lambda) => {
|
|
379
|
+
if (Object.keys(lambda).length > 0) {
|
|
380
|
+
state.spec = { ...state.spec, lambda: { ...state.spec.lambda, ...lambda } };
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
const finalize = () => ({
|
|
384
|
+
__brand: "effortless-cron",
|
|
385
|
+
__spec: state.spec,
|
|
386
|
+
...state.onError ? { onError: state.onError } : {},
|
|
387
|
+
...state.onCleanup ? { onCleanup: state.onCleanup } : {},
|
|
388
|
+
...state.setup ? { setup: state.setup } : {},
|
|
389
|
+
...state.deps ? { deps: state.deps } : {},
|
|
390
|
+
...state.config ? { config: state.config } : {},
|
|
391
|
+
...state.static ? { static: state.static } : {},
|
|
392
|
+
...state.onTick ? { onTick: state.onTick } : {}
|
|
393
|
+
});
|
|
394
|
+
const builder = {
|
|
395
|
+
deps(fn) {
|
|
396
|
+
state.deps = fn;
|
|
397
|
+
return builder;
|
|
398
|
+
},
|
|
399
|
+
config(fn) {
|
|
400
|
+
state.config = resolveConfigFactory(fn);
|
|
401
|
+
return builder;
|
|
402
|
+
},
|
|
403
|
+
include(glob) {
|
|
404
|
+
state.static = [...state.static ?? [], glob];
|
|
405
|
+
return builder;
|
|
406
|
+
},
|
|
407
|
+
setup(fnOrLambda, maybeLambda) {
|
|
408
|
+
if (typeof fnOrLambda === "function") {
|
|
409
|
+
state.setup = fnOrLambda;
|
|
410
|
+
if (maybeLambda) applyLambdaOptions(maybeLambda);
|
|
411
|
+
} else {
|
|
412
|
+
applyLambdaOptions(fnOrLambda);
|
|
413
|
+
}
|
|
414
|
+
return builder;
|
|
415
|
+
},
|
|
416
|
+
onError(fn) {
|
|
417
|
+
state.onError = fn;
|
|
418
|
+
return builder;
|
|
419
|
+
},
|
|
420
|
+
onCleanup(fn) {
|
|
421
|
+
state.onCleanup = fn;
|
|
422
|
+
return builder;
|
|
423
|
+
},
|
|
424
|
+
onTick(fn) {
|
|
425
|
+
state.onTick = fn;
|
|
426
|
+
return finalize();
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
return builder;
|
|
430
|
+
}
|
|
156
431
|
export {
|
|
157
432
|
defineApi,
|
|
158
433
|
defineApp,
|
|
159
434
|
defineBucket,
|
|
160
435
|
defineConfig,
|
|
436
|
+
defineCron,
|
|
161
437
|
defineFifoQueue,
|
|
162
438
|
defineMailer,
|
|
163
439
|
defineSecret,
|
|
@@ -167,9 +443,7 @@ export {
|
|
|
167
443
|
generateHex,
|
|
168
444
|
generateUuid,
|
|
169
445
|
param,
|
|
170
|
-
result,
|
|
171
446
|
secret,
|
|
172
|
-
toSeconds
|
|
173
|
-
unsafeAs
|
|
447
|
+
toSeconds
|
|
174
448
|
};
|
|
175
449
|
//# sourceMappingURL=index.js.map
|