@awsless/cli 0.1.8 → 0.1.9

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
@@ -108408,6 +108408,7 @@ import { join, normalize, relative } from "path";
108408
108408
  var root = process.cwd();
108409
108409
  var directories = {
108410
108410
  root,
108411
+ buildFolder: "build",
108411
108412
  get output() {
108412
108413
  return join(this.root, ".awsless");
108413
108414
  },
@@ -108418,7 +108419,7 @@ var directories = {
108418
108419
  return join(this.output, "state");
108419
108420
  },
108420
108421
  get build() {
108421
- return join(this.output, "build");
108422
+ return join(this.output, this.buildFolder);
108422
108423
  },
108423
108424
  get types() {
108424
108425
  return join(this.output, "types");
@@ -108433,6 +108434,9 @@ var directories = {
108433
108434
  var setRoot = (path = root) => {
108434
108435
  directories.root = path;
108435
108436
  };
108437
+ var useDevBuildDir = () => {
108438
+ directories.buildFolder = "build-dev";
108439
+ };
108436
108440
  var findRootDir = async (path, configFiles, level = 5) => {
108437
108441
  if (!level) {
108438
108442
  throw new TypeError("No awsless project found");
@@ -143971,6 +143975,14 @@ var createOpenSearchProvider = ({ credentials: credentials2, region }) => {
143971
143975
  async updateResource(props) {
143972
143976
  return apply(props.proposedState);
143973
143977
  },
143978
+ async planResourceChange(props) {
143979
+ const prior = props.priorState;
143980
+ const proposed = props.proposedState;
143981
+ return {
143982
+ state: props.proposedState,
143983
+ requiresReplacement: !!prior && (prior.endpoint !== proposed?.endpoint || prior.index !== proposed?.index)
143984
+ };
143985
+ },
143974
143986
  async deleteResource(props) {
143975
143987
  const state = inputSchema.parse(props.state);
143976
143988
  await getClient(state.endpoint).indices.delete({ index: state.index }, { ignore: [404] });
@@ -151140,7 +151152,7 @@ var JobDefaultSchema = exports_external.object({
151140
151152
 
151141
151153
  // src/feature/search/schema.ts
151142
151154
  var VersionSchema = exports_external.union([
151143
- exports_external.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
151155
+ exports_external.enum(["3.7", "3.5", "3.3", "3.1", "2.19", "2.17", "2.15", "2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]),
151144
151156
  exports_external.string()
151145
151157
  ]).describe("Specify the OpenSearch engine version.");
151146
151158
  var TypeSchema = exports_external.union([
@@ -151182,7 +151194,7 @@ var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes(10)), "Minimum stora
151182
151194
  var SearchDefaultSchema = exports_external.object({
151183
151195
  type: TypeSchema.default("t3.small"),
151184
151196
  count: CountSchema.default(1),
151185
- version: VersionSchema.default("2.13"),
151197
+ version: VersionSchema.default("3.7"),
151186
151198
  storage: StorageSizeSchema.default("10 GB")
151187
151199
  }).strict().default({}).describe("Configure the shared OpenSearch domain that backs every search index in your app.");
151188
151200
  var IndexNameSchema = exports_external.string().regex(/^[a-z0-9][a-z0-9\-_.]*$/, 'Index names must be lowercase & start with a letter or number, like "users" or "game-events".');
@@ -155701,7 +155713,8 @@ var createDnsValidatedCertificate = (group4, id, props) => {
155701
155713
  }, {
155702
155714
  ...props.dependsOn ? { dependsOn: props.dependsOn } : {},
155703
155715
  ...props.provider ? { provider: props.provider } : {},
155704
- replaceOnChanges: ["certificateArn", "validationRecordFqdns"]
155716
+ replaceOnChanges: ["certificateArn", "validationRecordFqdns"],
155717
+ createBeforeReplace: true
155705
155718
  });
155706
155719
  return validation;
155707
155720
  };
@@ -158963,7 +158976,8 @@ var searchFeature = defineFeature({
158963
158976
  })
158964
158977
  }, {
158965
158978
  retainOnDelete: ctx.appConfig.removal === "retain",
158966
- import: ctx.import ? name : undefined
158979
+ import: ctx.import ? name : undefined,
158980
+ replaceOnChanges: ["engineVersion", "domainName"]
158967
158981
  });
158968
158982
  ctx.addEnv("SEARCH_DOMAIN", openSearch.endpointV2);
158969
158983
  ctx.addPermission({
@@ -158977,7 +158991,8 @@ var searchFeature = defineFeature({
158977
158991
  mappings: JSON.stringify(resolveSearchMappings(indexProps) ?? {}),
158978
158992
  settings: JSON.stringify(indexProps.settings ?? {})
158979
158993
  }, {
158980
- retainOnDelete: ctx.appConfig.removal === "retain"
158994
+ retainOnDelete: ctx.appConfig.removal === "retain",
158995
+ replaceOnChanges: ["endpoint", "index"]
158981
158996
  });
158982
158997
  }
158983
158998
  }
@@ -164714,11 +164729,16 @@ var startTest = async (props) => {
164714
164729
  }
164715
164730
  for (const error3 of module.errors()) {
164716
164731
  const stack = error3.stacks?.[0];
164732
+ const { code, syscall, address, port } = error3;
164717
164733
  errors3.push({
164718
164734
  type: error3.name,
164719
164735
  message: error3.message,
164720
164736
  location: stack ? { line: stack.line, column: stack.column } : undefined,
164721
- stack: error3.stack
164737
+ stack: error3.stack,
164738
+ code,
164739
+ syscall,
164740
+ address,
164741
+ port
164722
164742
  });
164723
164743
  }
164724
164744
  }
@@ -164814,6 +164834,11 @@ var logTestErrors = (event) => {
164814
164834
  }
164815
164835
  }
164816
164836
  };
164837
+ var formatModuleError = (error3) => {
164838
+ const syscall = [error3.syscall, error3.address, error3.port && `port ${error3.port}`].filter(Boolean).join(" ");
164839
+ return [error3.message, syscall && `(${syscall})`, `
164840
+ `, error3.stack ?? "(no stack captured)"].filter(Boolean).join(" ");
164841
+ };
164817
164842
  var runTest = async (stack, dir, filters, workspace, opts) => {
164818
164843
  await mkdir8(directories.test, { recursive: true });
164819
164844
  const file2 = join49(directories.test, `${stack}.json`);
@@ -164841,15 +164866,26 @@ var runTest = async (stack, dir, filters, workspace, opts) => {
164841
164866
  initialMessage: `Run tests for the ${color2.info(stack)} stack`,
164842
164867
  errorMessage: `Running tests for the ${color2.info(stack)} stack failed`,
164843
164868
  async task(ctx) {
164844
- const result2 = await startTest({
164869
+ const transient = (error3) => ["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EPIPE"].includes(error3.code ?? "") || ["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EPIPE"].some((code) => error3.message.includes(code));
164870
+ let result2 = await startTest({
164845
164871
  dir,
164846
164872
  filters,
164847
164873
  env: opts.env
164848
164874
  });
164875
+ if (result2.errors.length > 0 && result2.errors.every(transient)) {
164876
+ for (const error3 of result2.errors) {
164877
+ debug(`Transient module error in ${stack} tests, retrying once: ${formatModuleError(error3)}`);
164878
+ }
164879
+ await new Promise((resolve5) => setTimeout(resolve5, 1000));
164880
+ result2 = await startTest({
164881
+ dir,
164882
+ filters,
164883
+ env: opts.env
164884
+ });
164885
+ }
164849
164886
  if (result2.errors.length > 0) {
164850
164887
  for (const error3 of result2.errors) {
164851
- debug(`Module error in ${stack} tests: ${error3.message}
164852
- ${error3.stack ?? "(no stack captured)"}`);
164888
+ debug(`Module error in ${stack} tests: ${formatModuleError(error3)}`);
164853
164889
  }
164854
164890
  throw result2.errors.map((error3) => new ExpectedError(error3.type && error3.type !== "Error" ? `${error3.type}: ${error3.message}` : error3.message));
164855
164891
  }
@@ -167897,7 +167933,7 @@ const ICONS = {
167897
167933
  route: svg('<circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>'),
167898
167934
  site: svg('<rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/>'),
167899
167935
  seed: svg('<path d="M12 22V8"/><path d="M12 8C12 5 9 2 5 2c0 4 3 6 7 6z"/><path d="M12 12c0-3 3-6 7-6 0 4-3 6-7 6z"/>'),
167900
- auth: svg('<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>'),
167936
+ auth: svg('<rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>'),
167901
167937
  worker: svg('<polyline points="4 17 10 11 4 5"/><line x1="12" y1="19" x2="20" y2="19"/>'),
167902
167938
  }
167903
167939
 
@@ -169924,6 +169960,7 @@ var startDev = async (props) => {
169924
169960
  const phase = props.phase ?? (async ({ start }, fn) => (log(start), fn(() => {})));
169925
169961
  const { appConfig, stackConfigs } = props;
169926
169962
  const startedAt = Date.now();
169963
+ useDevBuildDir();
169927
169964
  const { builders, appId, ready: ready2 } = createApp({
169928
169965
  appConfig,
169929
169966
  stackConfigs,
@@ -9934,19 +9934,25 @@ import { stringify } from "@awsless/json";
9934
9934
  import { lambda } from "@awsless/lambda";
9935
9935
  import { maxLength, minLength, object, optional, pipe, string, unknown } from "@awsless/validate";
9936
9936
  import { getRouteEnv } from "awsless";
9937
- var createClient = () => {
9938
- return new import_ioredis.Redis({
9939
- host: getRouteEnv("REDIS_HOST"),
9940
- port: Number(getRouteEnv("REDIS_PORT") ?? 6379),
9941
- tls: getRouteEnv("REDIS_TLS") === "disabled" ? undefined : {},
9942
- lazyConnect: true,
9943
- keepAlive: 0,
9944
- noDelay: true,
9945
- enableReadyCheck: false,
9946
- maxRetriesPerRequest: 3,
9947
- connectTimeout: 5000,
9948
- commandTimeout: 5000
9949
- });
9937
+ var client;
9938
+ var getClient = () => {
9939
+ if (!client || client.status === "end") {
9940
+ client = new import_ioredis.Redis({
9941
+ host: getRouteEnv("REDIS_HOST"),
9942
+ port: Number(getRouteEnv("REDIS_PORT") ?? 6379),
9943
+ tls: getRouteEnv("REDIS_TLS") === "disabled" ? undefined : {},
9944
+ lazyConnect: true,
9945
+ keepAlive: 0,
9946
+ noDelay: true,
9947
+ enableReadyCheck: false,
9948
+ maxRetriesPerRequest: 10,
9949
+ retryStrategy: (times) => times > 20 ? null : Math.min(times * 250, 2000),
9950
+ connectTimeout: 1e4,
9951
+ commandTimeout: 1e4
9952
+ });
9953
+ client.on("error", () => {});
9954
+ }
9955
+ return client;
9950
9956
  };
9951
9957
  var handle_default = lambda({
9952
9958
  schema: object({
@@ -9954,14 +9960,8 @@ var handle_default = lambda({
9954
9960
  event: pipe(string(), minLength(1), maxLength(64)),
9955
9961
  payload: optional(unknown())
9956
9962
  }),
9957
- async handle({ topic, event, payload }, ctx) {
9958
- const redis = createClient();
9959
- ctx.onFinally(() => {
9960
- return redis.quit().catch(() => {
9961
- redis.disconnect();
9962
- });
9963
- });
9964
- await redis.publish(getRouteEnv("CHANNEL"), stringify({
9963
+ async handle({ topic, event, payload }) {
9964
+ await getClient().publish(getRouteEnv("CHANNEL"), stringify({
9965
9965
  topic,
9966
9966
  event,
9967
9967
  payload: typeof payload === "undefined" ? undefined : stringify(payload)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -43,14 +43,14 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@awsless/big-float": "^0.1.7",
46
- "@awsless/duration": "^0.0.4",
47
46
  "@awsless/dynamodb": "^0.3.23",
48
47
  "@awsless/json": "^0.0.11",
49
48
  "@awsless/lambda": "^0.0.48",
49
+ "@awsless/duration": "^0.0.4",
50
+ "@awsless/weak-cache": "^0.0.1",
50
51
  "@awsless/s3": "^0.0.22",
51
- "@awsless/validate": "^0.2.0",
52
52
  "awsless": "^0.1.4",
53
- "@awsless/weak-cache": "^0.0.1"
53
+ "@awsless/validate": "^0.2.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@aws-sdk/client-cloudformation": "^3.369.0",
@@ -115,18 +115,18 @@
115
115
  "@awsless/dynamodb": "^0.3.23",
116
116
  "@awsless/iot": "^0.0.5",
117
117
  "@awsless/json": "^0.0.11",
118
- "@awsless/lambda": "^0.0.48",
119
118
  "@awsless/open-search": "^0.0.28",
119
+ "@awsless/lambda": "^0.0.48",
120
120
  "@awsless/s3": "^0.0.22",
121
121
  "@awsless/redis": "^0.1.13",
122
+ "@awsless/scheduler": "^0.0.5",
122
123
  "@awsless/size": "^0.0.2",
123
124
  "@awsless/sns": "^0.0.11",
124
- "@awsless/weak-cache": "^0.0.1",
125
125
  "@awsless/sqs": "^0.0.24",
126
- "awsless": "^0.1.4",
127
126
  "@awsless/ssm": "^0.0.8",
128
- "@awsless/scheduler": "^0.0.5",
129
- "@awsless/validate": "^0.2.0"
127
+ "@awsless/validate": "^0.2.0",
128
+ "awsless": "^0.1.4",
129
+ "@awsless/weak-cache": "^0.0.1"
130
130
  },
131
131
  "scripts": {
132
132
  "test": "bun cli/build-handlers.ts && pnpm vitest",