@awsless/awsless 0.0.413 → 0.0.415
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/bin.js +12 -4
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/server.d.ts +7 -1
- package/dist/server.js +48 -28
- package/package.json +10 -10
package/dist/bin.js
CHANGED
|
@@ -13524,7 +13524,6 @@ var testFeature = defineFeature({
|
|
|
13524
13524
|
import { aws as aws23, Node as Node23 } from "@awsless/formation";
|
|
13525
13525
|
var typeGenCode7 = `
|
|
13526
13526
|
import type { PublishOptions } from '@awsless/sns'
|
|
13527
|
-
import type { Mock } from 'vitest'
|
|
13528
13527
|
|
|
13529
13528
|
type Publish<Name extends string> = {
|
|
13530
13529
|
readonly name: Name
|
|
@@ -13708,26 +13707,35 @@ import { aws as aws25, Node as Node25 } from "@awsless/formation";
|
|
|
13708
13707
|
var typeGenCode8 = `
|
|
13709
13708
|
import type { PublishOptions } from '@awsless/sns'
|
|
13710
13709
|
|
|
13711
|
-
type
|
|
13710
|
+
type Alert<Name extends string> = {
|
|
13712
13711
|
readonly name: Name
|
|
13713
|
-
(
|
|
13712
|
+
(subject: string, payload?: string, options?: Omit<PublishOptions, 'subject' | 'topic' | 'payload'>): Promise<void>
|
|
13714
13713
|
}
|
|
13714
|
+
|
|
13715
|
+
type MockHandle = (payload: unknown) => void
|
|
13716
|
+
type MockBuilder = (handle?: MockHandle) => void
|
|
13715
13717
|
`;
|
|
13716
13718
|
var alertFeature = defineFeature({
|
|
13717
13719
|
name: "alert",
|
|
13718
13720
|
async onTypeGen(ctx) {
|
|
13719
13721
|
const gen = new TypeFile("@awsless/awsless");
|
|
13720
13722
|
const resources = new TypeObject(1);
|
|
13723
|
+
const mocks = new TypeObject(1);
|
|
13724
|
+
const mockResponses = new TypeObject(1);
|
|
13721
13725
|
for (const alert of Object.keys(ctx.appConfig.defaults.alerts ?? {})) {
|
|
13722
13726
|
const name = formatGlobalResourceName({
|
|
13723
13727
|
appName: ctx.appConfig.name,
|
|
13724
13728
|
resourceType: "alert",
|
|
13725
13729
|
resourceName: alert
|
|
13726
13730
|
});
|
|
13727
|
-
resources.addType(alert, `
|
|
13731
|
+
resources.addType(alert, `Alert<'${name}'>`);
|
|
13732
|
+
mockResponses.addType(alert, "Mock");
|
|
13733
|
+
mocks.addType(alert, `MockBuilder`);
|
|
13728
13734
|
}
|
|
13729
13735
|
gen.addCode(typeGenCode8);
|
|
13730
13736
|
gen.addInterface("AlertResources", resources);
|
|
13737
|
+
gen.addInterface("AlertMock", mocks);
|
|
13738
|
+
gen.addInterface("AlertMockResponse", mockResponses);
|
|
13731
13739
|
await ctx.write("alert.d.ts", gen, true);
|
|
13732
13740
|
},
|
|
13733
13741
|
onApp(ctx) {
|
|
Binary file
|
package/dist/server.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ declare class CommandOptions {
|
|
|
27
27
|
boolean(name: string): boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
interface AlertMock {
|
|
31
|
+
}
|
|
32
|
+
interface AlertMockResponse {
|
|
33
|
+
}
|
|
34
|
+
declare const mockAlert: (cb: (mock: AlertMock) => void) => AlertMockResponse;
|
|
35
|
+
|
|
30
36
|
interface FunctionMock {
|
|
31
37
|
}
|
|
32
38
|
interface FunctionMockResponse {
|
|
@@ -160,4 +166,4 @@ declare const Topic: TopicResources;
|
|
|
160
166
|
declare const APP: "app";
|
|
161
167
|
declare const STACK: "stack";
|
|
162
168
|
|
|
163
|
-
export { APP, Alert, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, CommandOptions, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, PubSub, type PublishOptions, Queue, type QueueMock, type QueueMockResponse, type QueueResources, type RpcAuthorizerResponse, STACK, Search, type SearchResources, Store, type StoreResources, Table, type TableResources, Task, type TaskMock, type TaskMockResponse, type TaskResources, Topic, type TopicMock, type TopicMockResponse, type TopicResources, getAlertName, getAuthProps, getCacheProps, getConfigName, getConfigValue, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
|
|
169
|
+
export { APP, Alert, type AlertMock, type AlertMockResponse, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, CommandOptions, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, PubSub, type PublishOptions, Queue, type QueueMock, type QueueMockResponse, type QueueResources, type RpcAuthorizerResponse, STACK, Search, type SearchResources, Store, type StoreResources, Table, type TableResources, Task, type TaskMock, type TaskMockResponse, type TaskResources, Topic, type TopicMock, type TopicMockResponse, type TopicResources, getAlertName, getAuthProps, getCacheProps, getConfigName, getConfigValue, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockAlert, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
|
package/dist/server.js
CHANGED
|
@@ -6,12 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-QL4FTNZ7.js";
|
|
7
7
|
import "./chunk-JSBRDJBE.js";
|
|
8
8
|
|
|
9
|
-
// src/lib/mock/
|
|
10
|
-
import {
|
|
9
|
+
// src/lib/mock/alert.ts
|
|
10
|
+
import { mockSNS } from "@awsless/sns";
|
|
11
11
|
|
|
12
|
-
// src/lib/server/
|
|
13
|
-
import {
|
|
14
|
-
import { WeakCache } from "@awsless/weak-cache";
|
|
12
|
+
// src/lib/server/alert.ts
|
|
13
|
+
import { publish } from "@awsless/sns";
|
|
15
14
|
|
|
16
15
|
// src/lib/server/util.ts
|
|
17
16
|
import { paramCase } from "change-case";
|
|
@@ -56,7 +55,46 @@ var bindGlobalResourceName = (resourceType) => {
|
|
|
56
55
|
};
|
|
57
56
|
};
|
|
58
57
|
|
|
58
|
+
// src/lib/server/alert.ts
|
|
59
|
+
var getAlertName = bindGlobalResourceName("alert");
|
|
60
|
+
var Alert = /* @__PURE__ */ createProxy((name) => {
|
|
61
|
+
const topic = getAlertName(name);
|
|
62
|
+
const ctx = {
|
|
63
|
+
[topic]: async (subject, payload, options = {}) => {
|
|
64
|
+
await publish({
|
|
65
|
+
...options,
|
|
66
|
+
topic,
|
|
67
|
+
subject,
|
|
68
|
+
payload
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const call = ctx[topic];
|
|
73
|
+
return call;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// src/lib/mock/alert.ts
|
|
77
|
+
var mockAlert = (cb) => {
|
|
78
|
+
const list = {};
|
|
79
|
+
const mock = createProxy((name) => {
|
|
80
|
+
return (handle) => {
|
|
81
|
+
list[getAlertName(name)] = handle ?? (() => {
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
cb(mock);
|
|
86
|
+
const result = mockSNS(list);
|
|
87
|
+
return createProxy((name) => {
|
|
88
|
+
return result[getAlertName(name)];
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/lib/mock/function.ts
|
|
93
|
+
import { mockLambda } from "@awsless/lambda";
|
|
94
|
+
|
|
59
95
|
// src/lib/server/function.ts
|
|
96
|
+
import { invoke } from "@awsless/lambda";
|
|
97
|
+
import { WeakCache } from "@awsless/weak-cache";
|
|
60
98
|
var cache = new WeakCache();
|
|
61
99
|
var getFunctionName = bindLocalResourceName("function");
|
|
62
100
|
var Function = /* @__PURE__ */ createProxy((stackName) => {
|
|
@@ -214,17 +252,17 @@ var mockTask = (cb) => {
|
|
|
214
252
|
};
|
|
215
253
|
|
|
216
254
|
// src/lib/mock/topic.ts
|
|
217
|
-
import { mockSNS } from "@awsless/sns";
|
|
255
|
+
import { mockSNS as mockSNS2 } from "@awsless/sns";
|
|
218
256
|
|
|
219
257
|
// src/lib/server/topic.ts
|
|
220
258
|
import { stringify } from "@awsless/json";
|
|
221
|
-
import { publish } from "@awsless/sns";
|
|
259
|
+
import { publish as publish2 } from "@awsless/sns";
|
|
222
260
|
var getTopicName = bindGlobalResourceName("topic");
|
|
223
261
|
var Topic = /* @__PURE__ */ createProxy((name) => {
|
|
224
262
|
const topic = getTopicName(name);
|
|
225
263
|
const ctx = {
|
|
226
264
|
[topic]: async (payload, options = {}) => {
|
|
227
|
-
await
|
|
265
|
+
await publish2({
|
|
228
266
|
...options,
|
|
229
267
|
topic,
|
|
230
268
|
payload: stringify(payload)
|
|
@@ -245,31 +283,12 @@ var mockTopic = (cb) => {
|
|
|
245
283
|
};
|
|
246
284
|
});
|
|
247
285
|
cb(mock);
|
|
248
|
-
const result =
|
|
286
|
+
const result = mockSNS2(list);
|
|
249
287
|
return createProxy((name) => {
|
|
250
288
|
return result[getTopicName(name)];
|
|
251
289
|
});
|
|
252
290
|
};
|
|
253
291
|
|
|
254
|
-
// src/lib/server/alert.ts
|
|
255
|
-
import { publish as publish2 } from "@awsless/sns";
|
|
256
|
-
var getAlertName = bindGlobalResourceName("alert");
|
|
257
|
-
var Alert = /* @__PURE__ */ createProxy((name) => {
|
|
258
|
-
const topic = getAlertName(name);
|
|
259
|
-
const ctx = {
|
|
260
|
-
[topic]: async (subject, payload, options = {}) => {
|
|
261
|
-
await publish2({
|
|
262
|
-
...options,
|
|
263
|
-
topic,
|
|
264
|
-
subject,
|
|
265
|
-
payload
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
const call = ctx[topic];
|
|
270
|
-
return call;
|
|
271
|
-
});
|
|
272
|
-
|
|
273
292
|
// src/lib/server/auth.ts
|
|
274
293
|
import { constantCase as constantCase2 } from "change-case";
|
|
275
294
|
var getAuthProps = (name) => {
|
|
@@ -573,6 +592,7 @@ export {
|
|
|
573
592
|
getTableName,
|
|
574
593
|
getTaskName,
|
|
575
594
|
getTopicName,
|
|
595
|
+
mockAlert,
|
|
576
596
|
mockFunction,
|
|
577
597
|
mockPubSub,
|
|
578
598
|
mockQueue,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.415",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@awsless/iot": "^0.0.2",
|
|
32
31
|
"@awsless/lambda": "^0.0.30",
|
|
33
|
-
"@awsless/
|
|
34
|
-
"@awsless/ssm": "^0.0.7",
|
|
32
|
+
"@awsless/iot": "^0.0.2",
|
|
35
33
|
"@awsless/open-search": "^0.0.15",
|
|
36
|
-
"@awsless/
|
|
34
|
+
"@awsless/redis": "^0.0.13",
|
|
35
|
+
"@awsless/sns": "^0.0.9",
|
|
37
36
|
"@awsless/s3": "^0.0.18",
|
|
37
|
+
"@awsless/sqs": "^0.0.7",
|
|
38
38
|
"@awsless/json": "^0.0.6",
|
|
39
39
|
"@awsless/validate": "^0.0.16",
|
|
40
|
-
"@awsless/
|
|
40
|
+
"@awsless/ssm": "^0.0.7",
|
|
41
41
|
"@awsless/weak-cache": "^0.0.1",
|
|
42
42
|
"@awsless/mqtt": "^0.0.2"
|
|
43
43
|
},
|
|
@@ -113,14 +113,14 @@
|
|
|
113
113
|
"zip-a-folder": "^3.1.6",
|
|
114
114
|
"zod": "^3.21.4",
|
|
115
115
|
"zod-to-json-schema": "^3.22.3",
|
|
116
|
-
"@awsless/
|
|
116
|
+
"@awsless/graphql": "^0.0.9",
|
|
117
117
|
"@awsless/duration": "^0.0.1",
|
|
118
118
|
"@awsless/formation": "^0.0.57",
|
|
119
119
|
"@awsless/validate": "^0.0.16",
|
|
120
|
-
"@awsless/ts-file-cache": "^0.0.10",
|
|
121
120
|
"@awsless/size": "^0.0.1",
|
|
122
|
-
"@awsless/
|
|
123
|
-
"@awsless/
|
|
121
|
+
"@awsless/ts-file-cache": "^0.0.10",
|
|
122
|
+
"@awsless/code": "^0.0.10",
|
|
123
|
+
"@awsless/json": "^0.0.6"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@node-rs/bcrypt": "^1.10.5"
|