@awsless/awsless 0.0.42 → 0.0.44

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.cjs DELETED
@@ -1,235 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- APP: () => APP,
24
- Cache: () => Cache,
25
- Function: () => Function,
26
- Queue: () => Queue,
27
- STACK: () => STACK,
28
- Search: () => Search,
29
- Store: () => Store,
30
- Table: () => Table,
31
- Topic: () => Topic,
32
- defineAppConfig: () => defineAppConfig,
33
- definePlugin: () => definePlugin,
34
- defineStackConfig: () => defineStackConfig,
35
- getCacheProps: () => getCacheProps,
36
- getFunctionName: () => getFunctionName,
37
- getGlobalResourceName: () => getGlobalResourceName,
38
- getLocalResourceName: () => getLocalResourceName,
39
- getQueueName: () => getQueueName,
40
- getSearchName: () => getSearchName,
41
- getSecretName: () => getSecretName,
42
- getStoreName: () => getStoreName,
43
- getTableName: () => getTableName,
44
- getTopicName: () => getTopicName
45
- });
46
- module.exports = __toCommonJS(src_exports);
47
-
48
- // src/plugin.ts
49
- var definePlugin = (plugin) => plugin;
50
-
51
- // src/node/resource.ts
52
- var import_change_case = require("change-case");
53
- var APP = process.env.APP || "app";
54
- var STACK = process.env.STACK || "stack";
55
- var getLocalResourceName = (name, stack = STACK) => {
56
- return `${APP}-${(0, import_change_case.paramCase)(stack)}-${(0, import_change_case.paramCase)(name)}`;
57
- };
58
- var getGlobalResourceName = (name) => {
59
- return `${APP}-${(0, import_change_case.paramCase)(name)}`;
60
- };
61
- var getSecretName = (name) => {
62
- return `/.awsless/${APP}/${name}`;
63
- };
64
-
65
- // src/node/function.ts
66
- var import_lambda = require("@awsless/lambda");
67
-
68
- // src/node/util.ts
69
- var createProxy = (cb) => {
70
- const cache = /* @__PURE__ */ new Map();
71
- return new Proxy({}, {
72
- get(_, name) {
73
- if (!cache.has(name)) {
74
- cache.set(name, cb(name));
75
- }
76
- return cache.get(name);
77
- }
78
- });
79
- };
80
-
81
- // src/node/function.ts
82
- var getFunctionName = (stack, name) => {
83
- return getLocalResourceName(name, stack);
84
- };
85
- var Function = createProxy((stackName) => {
86
- return createProxy((funcName) => {
87
- const name = getFunctionName(stackName, funcName);
88
- const call = (payload, options = {}) => {
89
- return (0, import_lambda.invoke)({
90
- ...options,
91
- name,
92
- payload
93
- });
94
- };
95
- call.name = name;
96
- call.async = (payload, options = {}) => {
97
- return (0, import_lambda.invoke)({
98
- ...options,
99
- type: "Event",
100
- name,
101
- payload
102
- });
103
- };
104
- return call;
105
- });
106
- });
107
-
108
- // src/node/table.ts
109
- var getTableName = getLocalResourceName;
110
- var Table = createProxy((stack) => {
111
- return createProxy((name) => {
112
- return {
113
- name: getTableName(name, stack)
114
- };
115
- });
116
- });
117
-
118
- // src/node/topic.ts
119
- var import_sns = require("@awsless/sns");
120
- var getTopicName = getGlobalResourceName;
121
- var Topic = createProxy((topic) => {
122
- const name = getTopicName(topic);
123
- const call = (payload, options = {}) => {
124
- return (0, import_sns.publish)({
125
- ...options,
126
- topic: name,
127
- payload
128
- });
129
- };
130
- call.name = name;
131
- return call;
132
- });
133
-
134
- // src/node/queue.ts
135
- var import_sqs = require("@awsless/sqs");
136
- var import_change_case2 = require("change-case");
137
- var getQueueName = getLocalResourceName;
138
- var getQueueUrl = (name, stack = STACK) => {
139
- return process.env[`QUEUE_${(0, import_change_case2.constantCase)(stack)}_${(0, import_change_case2.constantCase)(name)}_URL`];
140
- };
141
- var Queue = createProxy((stack) => {
142
- return createProxy((queue) => {
143
- const url = getQueueUrl(queue, stack);
144
- const send = (payload, options = {}) => {
145
- return (0, import_sqs.sendMessage)({
146
- ...options,
147
- queue: url,
148
- payload
149
- });
150
- };
151
- send.url = url;
152
- send.name = getQueueName(queue, stack);
153
- send.batch = (items, options = {}) => {
154
- return (0, import_sqs.sendMessageBatch)({
155
- ...options,
156
- queue: url,
157
- items
158
- });
159
- };
160
- return send;
161
- });
162
- });
163
-
164
- // src/node/cache.ts
165
- var import_change_case3 = require("change-case");
166
- var getCacheProps = (name, stack = STACK) => {
167
- const prefix = `CACHE_${(0, import_change_case3.constantCase)(stack)}_${(0, import_change_case3.constantCase)(name)}`;
168
- return {
169
- host: process.env[`${prefix}_HOST`],
170
- port: parseInt(process.env[`${prefix}_PORT`], 10)
171
- };
172
- };
173
- var Cache = createProxy((stack) => {
174
- return createProxy((name) => {
175
- const call = () => {
176
- };
177
- const { host, port } = getCacheProps(name, stack);
178
- call.host = host;
179
- call.port = port;
180
- return call;
181
- });
182
- });
183
-
184
- // src/node/store.ts
185
- var getStoreName = getLocalResourceName;
186
- var Store = createProxy((stack) => {
187
- return createProxy((name) => {
188
- return {
189
- name: getStoreName(name, stack)
190
- };
191
- });
192
- });
193
-
194
- // src/node/search.ts
195
- var getSearchName = getLocalResourceName;
196
- var Search = createProxy((stack) => {
197
- return createProxy((name) => {
198
- return {
199
- name: getSearchName(name, stack)
200
- };
201
- });
202
- });
203
-
204
- // src/index.ts
205
- var defineStackConfig = (config) => {
206
- return config;
207
- };
208
- var defineAppConfig = (config) => {
209
- return config;
210
- };
211
- // Annotate the CommonJS export names for ESM import in node:
212
- 0 && (module.exports = {
213
- APP,
214
- Cache,
215
- Function,
216
- Queue,
217
- STACK,
218
- Search,
219
- Store,
220
- Table,
221
- Topic,
222
- defineAppConfig,
223
- definePlugin,
224
- defineStackConfig,
225
- getCacheProps,
226
- getFunctionName,
227
- getGlobalResourceName,
228
- getLocalResourceName,
229
- getQueueName,
230
- getSearchName,
231
- getSecretName,
232
- getStoreName,
233
- getTableName,
234
- getTopicName
235
- });