@awsless/awsless 0.0.580 → 0.0.582

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
@@ -1,7 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- shortId
4
- } from "./chunk-W4ED7XCC.js";
5
2
 
6
3
  // src/cli/program.ts
7
4
  import { Command } from "commander";
@@ -874,6 +871,10 @@ var FileCodeSchema = z14.object({
874
871
  });
875
872
  var BundleCodeSchema = z14.object({
876
873
  bundle: LocalDirectorySchema.describe("The directory that needs to be bundled.")
874
+ // dir: z.string(),
875
+ // build: z.string(),
876
+ // run: z.string(),
877
+ // cacheKey:
877
878
  });
878
879
  var CodeSchema = z14.union([
879
880
  LocalFileSchema.transform((file) => ({
@@ -993,36 +994,38 @@ var OnLogDefaultSchema = z17.union([
993
994
  })
994
995
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
995
996
 
996
- // src/feature/pubsub/appsync/schema.ts
997
+ // src/feature/pubsub/schema.ts
997
998
  import { z as z18 } from "zod";
998
999
  var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
999
1000
  var PubSubDefaultSchema = z18.record(
1000
1001
  ResourceIdSchema,
1001
1002
  z18.object({
1002
- auth: FunctionSchema.describe("The authentication function for the pubsub API."),
1003
+ auth: FunctionSchema,
1003
1004
  domain: DomainSchema.optional(),
1004
- subDomain: z18.string().optional(),
1005
- namespaces: z18.array(z18.string()).optional().describe('The namespaces for the PubSub API. If not set, a single "default" namespace is created.'),
1006
- logLevel: z18.enum(["none", "info", "error", "debug", "all"]).optional().describe("The logging level for AppSync API. When set, logging is enabled.")
1005
+ subDomain: z18.string().optional()
1006
+ // auth: z.union([
1007
+ // ResourceIdSchema,
1008
+ // z.object({
1009
+ // authorizer: FunctionSchema,
1010
+ // // ttl: AuthorizerTtl.default('1 hour'),
1011
+ // }),
1012
+ // ]),
1013
+ // policy: z
1014
+ // .object({
1015
+ // publish: z.array(z.string()).optional(),
1016
+ // subscribe: z.array(z.string()).optional(),
1017
+ // })
1018
+ // .optional(),
1007
1019
  })
1008
- ).optional().describe("Define the pubsub API configuration in your stack.");
1020
+ ).optional().describe("Define the pubsub subscriber in your stack.");
1009
1021
  var PubSubSchema = z18.record(
1010
1022
  ResourceIdSchema,
1011
1023
  z18.object({
1012
- channels: z18.array(z18.string()).describe("The event channels this subscriber listens to."),
1013
- filter: z18.object({
1014
- eventType: z18.string().optional().describe("Filter events by event type.")
1015
- // Add more filter options as needed
1016
- // userId: z.string().optional(),
1017
- // custom: z.record(z.string(), z.any()).optional(),
1018
- }).optional().describe("Event filtering options."),
1019
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
1020
- batchSize: z18.number().int().min(1).max(100).default(1).describe("Number of events to batch before invoking the consumer function."),
1021
- retryPolicy: z18.object({
1022
- maxRetries: z18.number().int().min(0).max(3).default(2).describe("Maximum number of retry attempts.")
1023
- }).optional().describe("Retry policy for failed event processing.")
1024
+ sql: z18.string().describe("The SQL statement used to query the IOT topic."),
1025
+ sqlVersion: z18.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
1026
+ consumer: FunctionSchema.describe("The consuming lambda function properties.")
1024
1027
  })
1025
- ).optional().describe("Define the pubsub event subscribers in your stack.");
1028
+ ).optional().describe("Define the pubsub subscriber in your stack.");
1026
1029
 
1027
1030
  // src/feature/queue/schema.ts
1028
1031
  import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
@@ -3028,6 +3031,7 @@ var bundleTypeScript = async ({
3028
3031
  }
3029
3032
  const code = Buffer.from(item.code, "utf8");
3030
3033
  const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
3034
+ item.map?.version;
3031
3035
  hash.update(code);
3032
3036
  files.push({
3033
3037
  name: item.fileName,
@@ -3105,6 +3109,12 @@ var listAllFiles = async (list3) => {
3105
3109
  return files;
3106
3110
  };
3107
3111
 
3112
+ // src/util/id.ts
3113
+ import { createHash as createHash3 } from "crypto";
3114
+ var shortId = (ns) => {
3115
+ return createHash3("md5").update(ns).digest("hex").substring(0, 10);
3116
+ };
3117
+
3108
3118
  // src/util/temp.ts
3109
3119
  import { mkdir as mkdir3, readdir as readdir2, rm as rm2 } from "fs/promises";
3110
3120
  import { join as join8 } from "path";
@@ -3992,8 +4002,7 @@ var pubsubFeature = defineFeature({
3992
4002
  ctx.addGlobalPermission({
3993
4003
  actions: ["iot:Publish"],
3994
4004
  resources: [
3995
- //
3996
- `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`,
4005
+ // `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`,
3997
4006
  `arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/${ctx.app.name}/pubsub/*`
3998
4007
  ]
3999
4008
  });
@@ -5093,7 +5102,7 @@ var execCommand = async ({ cwd, env, command }) => {
5093
5102
  };
5094
5103
 
5095
5104
  // src/feature/site/index.ts
5096
- import { createHash as createHash3 } from "crypto";
5105
+ import { createHash as createHash4 } from "crypto";
5097
5106
  import { Future as Future3 } from "@awsless/formation";
5098
5107
  var siteFeature = defineFeature({
5099
5108
  name: "site",
@@ -5398,7 +5407,7 @@ var siteFeature = defineFeature({
5398
5407
  version: new Future3((resolve) => {
5399
5408
  $combine(...versions).then((versions2) => {
5400
5409
  const combined = versions2.filter((v) => !!v).sort().join(",");
5401
- const version = createHash3("sha1").update(combined).digest("hex");
5410
+ const version = createHash4("sha1").update(combined).digest("hex");
5402
5411
  resolve(version);
5403
5412
  });
5404
5413
  })
@@ -6897,7 +6906,7 @@ import deepmerge4 from "deepmerge";
6897
6906
  import { join as join16 } from "path";
6898
6907
 
6899
6908
  // src/feature/instance/build/executable.ts
6900
- import { createHash as createHash4 } from "crypto";
6909
+ import { createHash as createHash5 } from "crypto";
6901
6910
  import { readFile as readFile4 } from "fs/promises";
6902
6911
  import { join as join15 } from "path";
6903
6912
  import { exec as exec2 } from "promisify-child-process";
@@ -6912,7 +6921,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
6912
6921
  }
6913
6922
  const file = await readFile4(filePath);
6914
6923
  return {
6915
- hash: createHash4("sha1").update(file).update("x86_64").digest("hex"),
6924
+ hash: createHash5("sha1").update(file).update("x86_64").digest("hex"),
6916
6925
  file
6917
6926
  };
6918
6927
  };
@@ -8024,6 +8033,7 @@ var createApp = (props) => {
8024
8033
  };
8025
8034
  return {
8026
8035
  app,
8036
+ appId,
8027
8037
  base,
8028
8038
  zones,
8029
8039
  ready,
@@ -8312,7 +8322,7 @@ import { join as join19 } from "path";
8312
8322
  import wildstring3 from "wildstring";
8313
8323
 
8314
8324
  // src/build/__fingerprint.ts
8315
- import { createHash as createHash5 } from "crypto";
8325
+ import { createHash as createHash6 } from "crypto";
8316
8326
  import { readdir as readdir4, readFile as readFile5, stat as stat4 } from "fs/promises";
8317
8327
  import { basename as basename4, dirname as dirname10, extname as extname4, join as join17 } from "path";
8318
8328
  import parseStaticImports from "parse-static-imports";
@@ -8323,7 +8333,7 @@ var generateFileHashes = async (file, hashes) => {
8323
8333
  }
8324
8334
  const code = await readModuleFile(file);
8325
8335
  const deps = await findDependencies(file, code);
8326
- const hash = createHash5("sha1").update(code).digest();
8336
+ const hash = createHash6("sha1").update(code).digest();
8327
8337
  hashes.set(file, hash);
8328
8338
  for (const dep of deps) {
8329
8339
  if (dep.startsWith("/")) {
@@ -8340,7 +8350,7 @@ var fingerprintFromDirectory = async (dir) => {
8340
8350
  }
8341
8351
  }
8342
8352
  const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
8343
- return createHash5("sha1").update(merge2).digest("hex");
8353
+ return createHash6("sha1").update(merge2).digest("hex");
8344
8354
  };
8345
8355
  var readModuleFile = (file) => {
8346
8356
  if (file.endsWith(".js")) {
@@ -9049,7 +9059,7 @@ var run = (program2) => {
9049
9059
  const region = appConfig.region;
9050
9060
  const credentials = getCredentials(appConfig.profile);
9051
9061
  const accountId = await getAccountId(credentials, region);
9052
- const { commands: commands9 } = createApp({ appConfig, stackConfigs, accountId });
9062
+ const { commands: commands9, appId } = createApp({ appConfig, stackConfigs, accountId });
9053
9063
  let command;
9054
9064
  if (selected) {
9055
9065
  command = commands9.find((cmd) => {
@@ -9070,6 +9080,7 @@ var run = (program2) => {
9070
9080
  throw new ExpectedError(`The provided command doesn't exist.`);
9071
9081
  }
9072
9082
  process.env.APP = appConfig.name;
9083
+ process.env.APP_ID = appId;
9073
9084
  process.env.AWS_REGION = region;
9074
9085
  process.env.AWS_ACCOUNT_ID = accountId;
9075
9086
  const module = await tsImport(command.file, {
@@ -266,6 +266,10 @@ var FileCodeSchema = z11.object({
266
266
  });
267
267
  var BundleCodeSchema = z11.object({
268
268
  bundle: LocalDirectorySchema.describe("The directory that needs to be bundled.")
269
+ // dir: z.string(),
270
+ // build: z.string(),
271
+ // run: z.string(),
272
+ // cacheKey:
269
273
  });
270
274
  var CodeSchema = z11.union([
271
275
  LocalFileSchema.transform((file) => ({
@@ -385,36 +389,38 @@ var OnLogDefaultSchema = z14.union([
385
389
  })
386
390
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
387
391
 
388
- // src/feature/pubsub/appsync/schema.ts
392
+ // src/feature/pubsub/schema.ts
389
393
  import { z as z15 } from "zod";
390
394
  var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
391
395
  var PubSubDefaultSchema = z15.record(
392
396
  ResourceIdSchema,
393
397
  z15.object({
394
- auth: FunctionSchema.describe("The authentication function for the pubsub API."),
398
+ auth: FunctionSchema,
395
399
  domain: DomainSchema.optional(),
396
- subDomain: z15.string().optional(),
397
- namespaces: z15.array(z15.string()).optional().describe('The namespaces for the PubSub API. If not set, a single "default" namespace is created.'),
398
- logLevel: z15.enum(["none", "info", "error", "debug", "all"]).optional().describe("The logging level for AppSync API. When set, logging is enabled.")
400
+ subDomain: z15.string().optional()
401
+ // auth: z.union([
402
+ // ResourceIdSchema,
403
+ // z.object({
404
+ // authorizer: FunctionSchema,
405
+ // // ttl: AuthorizerTtl.default('1 hour'),
406
+ // }),
407
+ // ]),
408
+ // policy: z
409
+ // .object({
410
+ // publish: z.array(z.string()).optional(),
411
+ // subscribe: z.array(z.string()).optional(),
412
+ // })
413
+ // .optional(),
399
414
  })
400
- ).optional().describe("Define the pubsub API configuration in your stack.");
415
+ ).optional().describe("Define the pubsub subscriber in your stack.");
401
416
  var PubSubSchema = z15.record(
402
417
  ResourceIdSchema,
403
418
  z15.object({
404
- channels: z15.array(z15.string()).describe("The event channels this subscriber listens to."),
405
- filter: z15.object({
406
- eventType: z15.string().optional().describe("Filter events by event type.")
407
- // Add more filter options as needed
408
- // userId: z.string().optional(),
409
- // custom: z.record(z.string(), z.any()).optional(),
410
- }).optional().describe("Event filtering options."),
411
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
412
- batchSize: z15.number().int().min(1).max(100).default(1).describe("Number of events to batch before invoking the consumer function."),
413
- retryPolicy: z15.object({
414
- maxRetries: z15.number().int().min(0).max(3).default(2).describe("Maximum number of retry attempts.")
415
- }).optional().describe("Retry policy for failed event processing.")
419
+ sql: z15.string().describe("The SQL statement used to query the IOT topic."),
420
+ sqlVersion: z15.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
421
+ consumer: FunctionSchema.describe("The consuming lambda function properties.")
416
422
  })
417
- ).optional().describe("Define the pubsub event subscribers in your stack.");
423
+ ).optional().describe("Define the pubsub subscriber in your stack.");
418
424
 
419
425
  // src/feature/queue/schema.ts
420
426
  import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
Binary file
Binary file
@@ -1 +1 @@
1
- 67cc66902e9b4f4a3b10b94784c0f0f88f247ce1
1
+ f5dbbf3d9b5e37eda3a77bbec4453130ace93efd
Binary file
package/dist/prebuild.js CHANGED
@@ -118,6 +118,7 @@ var bundleTypeScript = async ({
118
118
  }
119
119
  const code = Buffer.from(item.code, "utf8");
120
120
  const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
121
+ item.map?.version;
121
122
  hash.update(code);
122
123
  files.push({
123
124
  name: item.fileName,
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
2
2
  import * as vitest from 'vitest';
3
- import { Duration, DurationFormat } from '@awsless/duration';
3
+ import { Duration } from '@awsless/duration';
4
4
  import { QoS } from '@awsless/iot';
5
5
  export { QoS } from '@awsless/iot';
6
6
  import { IoTCustomAuthorizerResult } from 'aws-lambda';
@@ -87,10 +87,6 @@ interface FunctionResources {
87
87
  declare const Function: FunctionResources;
88
88
  declare const Fn: FunctionResources;
89
89
 
90
- interface InstanceResources {
91
- }
92
- declare const Instance: InstanceResources;
93
-
94
90
  declare const getMetricName: (name: string) => string;
95
91
  declare const getMetricNamespace: (stack?: string, app?: string) => string;
96
92
  interface MetricResources {
@@ -135,7 +131,7 @@ type RpcAuthorizerResponse = {
135
131
  authorized: true;
136
132
  context?: unknown;
137
133
  lockKey?: string;
138
- ttl: DurationFormat;
134
+ ttl: Duration;
139
135
  };
140
136
 
141
137
  declare const getSearchName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--search--${N}`;
@@ -146,9 +142,9 @@ interface SearchResources {
146
142
  }
147
143
  declare const Search: SearchResources;
148
144
 
149
- declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--${string}`;
145
+ declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--app-id`;
150
146
 
151
- declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--${string}`;
147
+ declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--app-id`;
152
148
  interface StoreResources {
153
149
  }
154
150
  declare const Store: StoreResources;
@@ -171,4 +167,4 @@ declare const Topic: TopicResources;
171
167
  declare const APP: "app";
172
168
  declare const STACK: "stack";
173
169
 
174
- export { APP, Alert, type AlertMock, type AlertMockResponse, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, Instance, type InstanceResources, Metric, type MetricResources, 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, getMetricName, getMetricNamespace, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockAlert, mockCache, mockFunction, mockMetric, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
170
+ export { APP, Alert, type AlertMock, type AlertMockResponse, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, Metric, type MetricResources, 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, getMetricName, getMetricNamespace, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockAlert, mockCache, mockFunction, mockMetric, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
package/dist/server.js CHANGED
@@ -1,6 +1,3 @@
1
- import {
2
- shortId
3
- } from "./chunk-W4ED7XCC.js";
4
1
  import {
5
2
  createProxy
6
3
  } from "./chunk-2LRBH7VV.js";
@@ -15,6 +12,7 @@ import { publish } from "@awsless/sns";
15
12
  // src/lib/server/util.ts
16
13
  import { kebabCase } from "change-case";
17
14
  var APP = process.env.APP ?? "app";
15
+ var APP_ID = process.env.APP_ID ?? "app-id";
18
16
  var STACK = process.env.STACK ?? "stack";
19
17
  var IS_TEST = process.env.NODE_ENV === "test";
20
18
  var build = (opt) => {
@@ -456,13 +454,6 @@ var Config = /* @__PURE__ */ new Proxy(
456
454
  }
457
455
  );
458
456
 
459
- // src/lib/server/instance.ts
460
- var Instance = /* @__PURE__ */ createProxy((stack) => {
461
- return createProxy((name) => {
462
- return `http://${shortId(`${stack}:${name}`)}.${APP}`;
463
- });
464
- });
465
-
466
457
  // src/lib/server/metric.ts
467
458
  import {
468
459
  batchPutData,
@@ -627,11 +618,11 @@ var Search = /* @__PURE__ */ createProxy((stack) => {
627
618
  });
628
619
 
629
620
  // src/lib/server/site.ts
630
- var getSiteBucketName = bindPostfixedLocalResourceName("site", process.env.APP_ID);
621
+ var getSiteBucketName = bindPostfixedLocalResourceName("site", APP_ID);
631
622
 
632
623
  // src/lib/server/store.ts
633
624
  import { deleteObject, getObject, headObject, putObject } from "@awsless/s3";
634
- var getStoreName = bindPostfixedLocalResourceName("store", process.env.APP_ID);
625
+ var getStoreName = bindPostfixedLocalResourceName("store", APP_ID);
635
626
  var Store = /* @__PURE__ */ createProxy((stack) => {
636
627
  return createProxy((name) => {
637
628
  const bucket = getStoreName(name, stack);
@@ -678,7 +669,6 @@ export {
678
669
  Config,
679
670
  Fn,
680
671
  Function,
681
- Instance,
682
672
  Metric,
683
673
  PubSub,
684
674
  QoS,