@awsless/awsless 0.0.414 → 0.0.416

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 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 Publish<Name extends string> = {
13710
+ type Alert<Name extends string> = {
13712
13711
  readonly name: Name
13713
- (subject: string, payload?: string, options?: Omit<PublishOptions, 'subject' | 'topic' | 'payload'>): Promise<void>
13712
+ (subject: string, payload?: unknown, 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, `Publish<'${name}'>`);
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,12 @@ import {
6
6
  } from "./chunk-QL4FTNZ7.js";
7
7
  import "./chunk-JSBRDJBE.js";
8
8
 
9
- // src/lib/mock/function.ts
10
- import { mockLambda } from "@awsless/lambda";
9
+ // src/lib/mock/alert.ts
10
+ import { mockSNS } from "@awsless/sns";
11
11
 
12
- // src/lib/server/function.ts
13
- import { invoke } from "@awsless/lambda";
14
- import { WeakCache } from "@awsless/weak-cache";
12
+ // src/lib/server/alert.ts
13
+ import { stringify } from "@awsless/json";
14
+ import { publish } from "@awsless/sns";
15
15
 
16
16
  // src/lib/server/util.ts
17
17
  import { paramCase } from "change-case";
@@ -56,7 +56,46 @@ var bindGlobalResourceName = (resourceType) => {
56
56
  };
57
57
  };
58
58
 
59
+ // src/lib/server/alert.ts
60
+ var getAlertName = bindGlobalResourceName("alert");
61
+ var Alert = /* @__PURE__ */ createProxy((name) => {
62
+ const topic = getAlertName(name);
63
+ const ctx = {
64
+ [topic]: async (subject, payload, options = {}) => {
65
+ await publish({
66
+ ...options,
67
+ topic,
68
+ subject,
69
+ payload: typeof payload === "string" || typeof payload === "undefined" ? payload : stringify(payload)
70
+ });
71
+ }
72
+ };
73
+ const call = ctx[topic];
74
+ return call;
75
+ });
76
+
77
+ // src/lib/mock/alert.ts
78
+ var mockAlert = (cb) => {
79
+ const list = {};
80
+ const mock = createProxy((name) => {
81
+ return (handle) => {
82
+ list[getAlertName(name)] = handle ?? (() => {
83
+ });
84
+ };
85
+ });
86
+ cb(mock);
87
+ const result = mockSNS(list);
88
+ return createProxy((name) => {
89
+ return result[getAlertName(name)];
90
+ });
91
+ };
92
+
93
+ // src/lib/mock/function.ts
94
+ import { mockLambda } from "@awsless/lambda";
95
+
59
96
  // src/lib/server/function.ts
97
+ import { invoke } from "@awsless/lambda";
98
+ import { WeakCache } from "@awsless/weak-cache";
60
99
  var cache = new WeakCache();
61
100
  var getFunctionName = bindLocalResourceName("function");
62
101
  var Function = /* @__PURE__ */ createProxy((stackName) => {
@@ -214,20 +253,20 @@ var mockTask = (cb) => {
214
253
  };
215
254
 
216
255
  // src/lib/mock/topic.ts
217
- import { mockSNS } from "@awsless/sns";
256
+ import { mockSNS as mockSNS2 } from "@awsless/sns";
218
257
 
219
258
  // src/lib/server/topic.ts
220
- import { stringify } from "@awsless/json";
221
- import { publish } from "@awsless/sns";
259
+ import { stringify as stringify2 } from "@awsless/json";
260
+ import { publish as publish2 } from "@awsless/sns";
222
261
  var getTopicName = bindGlobalResourceName("topic");
223
262
  var Topic = /* @__PURE__ */ createProxy((name) => {
224
263
  const topic = getTopicName(name);
225
264
  const ctx = {
226
265
  [topic]: async (payload, options = {}) => {
227
- await publish({
266
+ await publish2({
228
267
  ...options,
229
268
  topic,
230
- payload: stringify(payload)
269
+ payload: stringify2(payload)
231
270
  });
232
271
  }
233
272
  };
@@ -245,31 +284,12 @@ var mockTopic = (cb) => {
245
284
  };
246
285
  });
247
286
  cb(mock);
248
- const result = mockSNS(list);
287
+ const result = mockSNS2(list);
249
288
  return createProxy((name) => {
250
289
  return result[getTopicName(name)];
251
290
  });
252
291
  };
253
292
 
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
293
  // src/lib/server/auth.ts
274
294
  import { constantCase as constantCase2 } from "change-case";
275
295
  var getAuthProps = (name) => {
@@ -385,7 +405,7 @@ var Config = /* @__PURE__ */ new Proxy(
385
405
  // src/lib/server/pubsub.ts
386
406
  import { hours, toSeconds } from "@awsless/duration";
387
407
  import { publish as publish3, QoS } from "@awsless/iot";
388
- import { stringify as stringify2 } from "@awsless/json";
408
+ import { stringify as stringify3 } from "@awsless/json";
389
409
  var getPubSubTopic = (name) => {
390
410
  return `${APP}/pubsub/${name}`;
391
411
  };
@@ -393,7 +413,7 @@ var PubSub = {
393
413
  async publish(topic, event, payload, opts = {}) {
394
414
  await publish3({
395
415
  topic: getPubSubTopic(topic),
396
- payload: Buffer.from(stringify2([event, payload])),
416
+ payload: Buffer.from(stringify3([event, payload])),
397
417
  ...opts
398
418
  });
399
419
  }
@@ -573,6 +593,7 @@ export {
573
593
  getTableName,
574
594
  getTaskName,
575
595
  getTopicName,
596
+ mockAlert,
576
597
  mockFunction,
577
598
  mockPubSub,
578
599
  mockQueue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.414",
3
+ "version": "0.0.416",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -29,17 +29,17 @@
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@awsless/lambda": "^0.0.30",
32
+ "@awsless/open-search": "^0.0.15",
33
+ "@awsless/redis": "^0.0.13",
32
34
  "@awsless/s3": "^0.0.18",
33
- "@awsless/sns": "^0.0.8",
34
- "@awsless/mqtt": "^0.0.2",
35
- "@awsless/sqs": "^0.0.7",
36
- "@awsless/validate": "^0.0.16",
35
+ "@awsless/sns": "^0.0.9",
37
36
  "@awsless/json": "^0.0.6",
38
- "@awsless/weak-cache": "^0.0.1",
37
+ "@awsless/validate": "^0.0.16",
38
+ "@awsless/sqs": "^0.0.7",
39
39
  "@awsless/iot": "^0.0.2",
40
40
  "@awsless/ssm": "^0.0.7",
41
- "@awsless/open-search": "^0.0.15",
42
- "@awsless/redis": "^0.0.13"
41
+ "@awsless/weak-cache": "^0.0.1",
42
+ "@awsless/mqtt": "^0.0.2"
43
43
  },
44
44
  "dependencies": {
45
45
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -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/formation": "^0.0.57",
116
+ "@awsless/code": "^0.0.10",
117
117
  "@awsless/duration": "^0.0.1",
118
+ "@awsless/formation": "^0.0.57",
119
+ "@awsless/graphql": "^0.0.9",
118
120
  "@awsless/size": "^0.0.1",
119
121
  "@awsless/ts-file-cache": "^0.0.10",
120
122
  "@awsless/json": "^0.0.6",
121
- "@awsless/validate": "^0.0.16",
122
- "@awsless/code": "^0.0.10",
123
- "@awsless/graphql": "^0.0.9"
123
+ "@awsless/validate": "^0.0.16"
124
124
  },
125
125
  "devDependencies": {
126
126
  "@node-rs/bcrypt": "^1.10.5"