@awsless/awsless 0.0.195 → 0.0.198
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 +29 -5
- package/dist/server.js +32 -1
- package/package.json +6 -5
package/dist/bin.js
CHANGED
|
@@ -3626,6 +3626,25 @@ var httpFeature = defineFeature({
|
|
|
3626
3626
|
|
|
3627
3627
|
// src/feature/search/index.ts
|
|
3628
3628
|
import { Node as Node16, aws as aws16 } from "@awsless/formation";
|
|
3629
|
+
import { constantCase as constantCase5 } from "change-case";
|
|
3630
|
+
var typeGenCode6 = `
|
|
3631
|
+
import {
|
|
3632
|
+
migrate as sMigrate,
|
|
3633
|
+
search as sSearch,
|
|
3634
|
+
indexItem as sIndexItem,
|
|
3635
|
+
updateItem as sUpdateItem,
|
|
3636
|
+
deleteItem as sDeleteItem,
|
|
3637
|
+
} from '@awsless/open-search'
|
|
3638
|
+
|
|
3639
|
+
type Store<Name extends string> = {
|
|
3640
|
+
readonly name: Name
|
|
3641
|
+
readonly migrate: (...args: Parameters<typeof sMigrate>) => ReturnType<typeof sMigrate>
|
|
3642
|
+
readonly search: (...args: Parameters<typeof sMigrate>) => ReturnType<typeof sSearch>
|
|
3643
|
+
readonly indexItem: (...args: Parameters<typeof sIndexItem>) => ReturnType<typeof sIndexItem>
|
|
3644
|
+
readonly updateItem: (...args: Parameters<typeof sUpdateItem>) => ReturnType<typeof sUpdateItem>
|
|
3645
|
+
readonly deleteItem: (...args: Parameters<typeof sDeleteItem>) => ReturnType<typeof sDeleteItem>
|
|
3646
|
+
}
|
|
3647
|
+
`;
|
|
3629
3648
|
var searchFeature = defineFeature({
|
|
3630
3649
|
name: "search",
|
|
3631
3650
|
async onTypeGen(ctx) {
|
|
@@ -3639,13 +3658,14 @@ var searchFeature = defineFeature({
|
|
|
3639
3658
|
}
|
|
3640
3659
|
resources.addType(stack.name, list4);
|
|
3641
3660
|
}
|
|
3661
|
+
gen.addCode(typeGenCode6);
|
|
3642
3662
|
gen.addInterface("SearchResources", resources);
|
|
3643
3663
|
await ctx.write("search.d.ts", gen, true);
|
|
3644
3664
|
},
|
|
3645
3665
|
onStack(ctx) {
|
|
3646
3666
|
for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
|
|
3647
3667
|
const group = new Node16(ctx.stack, "search", id);
|
|
3648
|
-
const
|
|
3668
|
+
const openSearch = new aws16.openSearch.Domain(group, "domain", {
|
|
3649
3669
|
// name: formatLocalResourceName(ctx.app.name, ctx.stack.name, this.name, id),
|
|
3650
3670
|
version: props.version,
|
|
3651
3671
|
storageSize: props.storage,
|
|
@@ -3657,13 +3677,13 @@ var searchFeature = defineFeature({
|
|
|
3657
3677
|
statements: [
|
|
3658
3678
|
{
|
|
3659
3679
|
principal: "lambda.amazonaws.com",
|
|
3660
|
-
sourceArn: `arn:aws:
|
|
3680
|
+
sourceArn: `arn:aws:lambda:${ctx.appConfig.region}:${ctx.accountId}:function:${ctx.app.name}--${ctx.stack.name}--*`
|
|
3661
3681
|
}
|
|
3662
3682
|
]
|
|
3663
3683
|
}
|
|
3664
3684
|
});
|
|
3665
3685
|
if (props.vpc) {
|
|
3666
|
-
|
|
3686
|
+
openSearch.setVpc({
|
|
3667
3687
|
securityGroupIds: [ctx.shared.get(`vpc-security-group-id`)],
|
|
3668
3688
|
subnetIds: [
|
|
3669
3689
|
ctx.shared.get("vpc-private-subnet-id-1"),
|
|
@@ -3671,10 +3691,14 @@ var searchFeature = defineFeature({
|
|
|
3671
3691
|
]
|
|
3672
3692
|
});
|
|
3673
3693
|
}
|
|
3674
|
-
ctx.onFunction(({ policy }) => {
|
|
3694
|
+
ctx.onFunction(({ lambda, policy }) => {
|
|
3695
|
+
lambda.addEnvironment(
|
|
3696
|
+
`SEARCH_${constantCase5(ctx.stack.name)}_${constantCase5(id)}_DOMAIN`,
|
|
3697
|
+
openSearch.domainEndpoint
|
|
3698
|
+
);
|
|
3675
3699
|
policy.addStatement({
|
|
3676
3700
|
actions: ["es:*"],
|
|
3677
|
-
resources: [
|
|
3701
|
+
resources: [openSearch.arn]
|
|
3678
3702
|
});
|
|
3679
3703
|
});
|
|
3680
3704
|
}
|
package/dist/server.js
CHANGED
|
@@ -262,11 +262,42 @@ var Config = /* @__PURE__ */ new Proxy(
|
|
|
262
262
|
);
|
|
263
263
|
|
|
264
264
|
// src/lib/resource/search.ts
|
|
265
|
+
import { constantCase as constantCase4 } from "change-case";
|
|
266
|
+
import {
|
|
267
|
+
searchClient,
|
|
268
|
+
migrate as sMigrate,
|
|
269
|
+
search as sSearch,
|
|
270
|
+
indexItem as sIndexItem,
|
|
271
|
+
updateItem as sUpdateItem,
|
|
272
|
+
deleteItem as sDeleteItem
|
|
273
|
+
} from "@awsless/open-search";
|
|
265
274
|
var getSearchName = bindLocalResourceName("search");
|
|
275
|
+
var getSearchProps = (name, stack = STACK) => {
|
|
276
|
+
return {
|
|
277
|
+
domain: process.env[`CACHE_${constantCase4(stack)}_${constantCase4(name)}_DOMAIN`]
|
|
278
|
+
};
|
|
279
|
+
};
|
|
266
280
|
var Search = /* @__PURE__ */ createProxy((stack) => {
|
|
267
281
|
return createProxy((name) => {
|
|
282
|
+
const { domain } = getSearchProps(name, stack);
|
|
283
|
+
const client = searchClient({ node: domain });
|
|
268
284
|
return {
|
|
269
|
-
name: getSearchName(name, stack)
|
|
285
|
+
name: getSearchName(name, stack),
|
|
286
|
+
migrate(...args) {
|
|
287
|
+
return sMigrate(args[0], { client });
|
|
288
|
+
},
|
|
289
|
+
search(...args) {
|
|
290
|
+
return sSearch(args[0], { client, ...args[1] });
|
|
291
|
+
},
|
|
292
|
+
indexItem(...args) {
|
|
293
|
+
return sIndexItem(args[0], args[1], args[2], { client, ...args[3] });
|
|
294
|
+
},
|
|
295
|
+
updateItem(...args) {
|
|
296
|
+
return sUpdateItem(args[0], args[1], args[2], { client, ...args[3] });
|
|
297
|
+
},
|
|
298
|
+
deleteItem(...args) {
|
|
299
|
+
return sDeleteItem(args[0], args[1], { client, ...args[2] });
|
|
300
|
+
}
|
|
270
301
|
};
|
|
271
302
|
});
|
|
272
303
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.198",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@awsless/lambda": "^0.0.18",
|
|
32
|
+
"@awsless/open-search": "^0.0.11",
|
|
32
33
|
"@awsless/redis": "^0.0.12",
|
|
34
|
+
"@awsless/s3": "^0.0.10",
|
|
33
35
|
"@awsless/sns": "^0.0.7",
|
|
34
36
|
"@awsless/sqs": "^0.0.7",
|
|
35
|
-
"@awsless/s3": "^0.0.10",
|
|
36
37
|
"@awsless/validate": "^0.0.13",
|
|
37
|
-
"@awsless/
|
|
38
|
-
"@awsless/
|
|
38
|
+
"@awsless/ssm": "^0.0.7",
|
|
39
|
+
"@awsless/weak-cache": "^0.0.1"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
42
|
"@aws-appsync/utils": "^1.5.0",
|
|
@@ -98,9 +99,9 @@
|
|
|
98
99
|
"zod-to-json-schema": "^3.22.3",
|
|
99
100
|
"@awsless/duration": "^0.0.1",
|
|
100
101
|
"@awsless/size": "^0.0.1",
|
|
101
|
-
"@awsless/formation": "^0.0.15",
|
|
102
102
|
"@awsless/graphql": "^0.0.9",
|
|
103
103
|
"@awsless/validate": "^0.0.13",
|
|
104
|
+
"@awsless/formation": "^0.0.15",
|
|
104
105
|
"@awsless/code": "^0.0.10"
|
|
105
106
|
},
|
|
106
107
|
"scripts": {
|