@awsless/awsless 0.0.475 → 0.0.477

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.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/bin.js CHANGED
@@ -4305,7 +4305,14 @@ var getForwardHostFunctionCode = () => {
4305
4305
 
4306
4306
  // src/feature/site/index.ts
4307
4307
  import { camelCase as camelCase6, constantCase as constantCase10 } from "change-case";
4308
+
4309
+ // src/util/exec.ts
4308
4310
  import { exec } from "promisify-child-process";
4311
+ var execCommand = async ({ cwd, command }) => {
4312
+ await exec(command, { cwd });
4313
+ };
4314
+
4315
+ // src/feature/site/index.ts
4309
4316
  var siteFeature = defineFeature({
4310
4317
  name: "site",
4311
4318
  onStack(ctx) {
@@ -4323,7 +4330,10 @@ var siteFeature = defineFeature({
4323
4330
  const fingerprint = await generateCacheKey(buildProps.cacheKey);
4324
4331
  return build3(fingerprint, async (write) => {
4325
4332
  const cwd = join11(directories.root, dirname7(ctx.stackConfig.file));
4326
- await exec(buildProps.command, { cwd });
4333
+ await execCommand({
4334
+ cwd,
4335
+ command: buildProps.command
4336
+ });
4327
4337
  await write("HASH", fingerprint);
4328
4338
  return {
4329
4339
  size: "n/a"
@@ -4418,24 +4428,26 @@ var siteFeature = defineFeature({
4418
4428
  signingBehavior: "always",
4419
4429
  signingProtocol: "sigv4"
4420
4430
  });
4421
- if (typeof props.static === "string") {
4422
- const files = glob2.sync("**", {
4423
- cwd: props.static,
4424
- nodir: true
4425
- });
4426
- for (const file of files) {
4427
- const object = new $15.aws.s3.BucketObject(group, file, {
4428
- bucket: bucket.bucket,
4429
- key: file,
4430
- cacheControl: getCacheControl(file),
4431
- contentType: getContentType(file),
4432
- source: join11(props.static, file),
4433
- sourceHash: $hash(join11(props.static, file))
4431
+ ctx.onReady(() => {
4432
+ if (typeof props.static === "string") {
4433
+ const files = glob2.sync("**", {
4434
+ cwd: props.static,
4435
+ nodir: true
4434
4436
  });
4435
- versions.push(object.key);
4436
- versions.push(object.etag);
4437
+ for (const file of files) {
4438
+ const object = new $15.aws.s3.BucketObject(group, file, {
4439
+ bucket: bucket.bucket,
4440
+ key: file,
4441
+ cacheControl: getCacheControl(file),
4442
+ contentType: getContentType(file),
4443
+ source: join11(props.static, file),
4444
+ sourceHash: $hash(join11(props.static, file))
4445
+ });
4446
+ versions.push(object.key);
4447
+ versions.push(object.etag);
4448
+ }
4437
4449
  }
4438
- }
4450
+ });
4439
4451
  origins.push({
4440
4452
  originId: "static",
4441
4453
  domainName: bucket.bucketRegionalDomainName,
@@ -6013,13 +6025,16 @@ var createApp = (props) => {
6013
6025
  }
6014
6026
  }
6015
6027
  }
6016
- for (const listener of readyListeners) {
6017
- listener();
6018
- }
6028
+ const ready = () => {
6029
+ for (const listener of readyListeners) {
6030
+ listener();
6031
+ }
6032
+ };
6019
6033
  return {
6020
6034
  app,
6021
6035
  base,
6022
6036
  zones,
6037
+ ready,
6023
6038
  domainZones,
6024
6039
  tests,
6025
6040
  binds,
@@ -6239,7 +6254,8 @@ var del2 = (program2) => {
6239
6254
  const profile = appConfig.profile;
6240
6255
  const credentials = getCredentials(profile);
6241
6256
  const accountId = await getAccountId(credentials, region);
6242
- const { app } = createApp({ appConfig, stackConfigs, accountId });
6257
+ const { app, ready } = createApp({ appConfig, stackConfigs, accountId });
6258
+ ready();
6243
6259
  const stackNames = app.stacks.filter((stack) => {
6244
6260
  return !!filters.find((f) => wildstring2.match(f, stack.name));
6245
6261
  }).map((s) => s.name);
@@ -6621,7 +6637,7 @@ var deploy = (program2) => {
6621
6637
  const credentials = getCredentials(profile);
6622
6638
  const accountId = await getAccountId(credentials, region);
6623
6639
  await bootstrapAwsless({ credentials, region, accountId });
6624
- const { app, tests, builders } = createApp({
6640
+ const { app, tests, builders, ready } = createApp({
6625
6641
  appConfig,
6626
6642
  stackConfigs,
6627
6643
  accountId,
@@ -6649,6 +6665,7 @@ var deploy = (program2) => {
6649
6665
  }
6650
6666
  }
6651
6667
  await buildAssets(builders, filters);
6668
+ ready();
6652
6669
  const { workspace, state: state2 } = await createWorkSpace({
6653
6670
  credentials,
6654
6671
  accountId,
@@ -0,0 +1,75 @@
1
+ import * as _awsless_mqtt from '@awsless/mqtt';
2
+ import { QoS } from '@awsless/mqtt';
3
+
4
+ interface AuthResources {
5
+ }
6
+ declare const Auth: AuthResources;
7
+ declare const getAuthProps: (name: string) => {
8
+ readonly userPoolId: string;
9
+ readonly clientId: string;
10
+ };
11
+
12
+ interface GraphQLSchema {
13
+ }
14
+ interface GraphQLResources {
15
+ }
16
+ declare const GraphQL: GraphQLResources;
17
+ declare const getGraphQLProps: (name: string) => {
18
+ endpoint: string;
19
+ };
20
+
21
+ interface HTTP {
22
+ }
23
+ type Method = 'GET' | 'POST';
24
+ type Path = string;
25
+ type Params = Record<string, string | number>;
26
+ type Query = Record<string, string>;
27
+ type Body = unknown;
28
+ type Route = {
29
+ param?: Params;
30
+ query?: Query;
31
+ body?: Body;
32
+ response: unknown;
33
+ };
34
+ type Routes = Record<Path, Route>;
35
+ type Schema = Partial<Record<Method, Routes>>;
36
+ type GetRoute<S extends Schema, M extends keyof S, P extends keyof S[M]> = S[M] extends Routes ? S[M][P] : never;
37
+ type Props<R extends Route> = {
38
+ headers?: Record<string, string>;
39
+ params?: R['param'] extends Params ? R['param'] : never;
40
+ query?: R['query'] extends Query ? R['query'] : never;
41
+ body?: R['body'] extends Body ? R['body'] : never;
42
+ };
43
+ type HttpFetcher = (props: {
44
+ method: Method;
45
+ path: Path;
46
+ headers: Headers;
47
+ query?: Query;
48
+ body?: Body;
49
+ }) => unknown;
50
+ declare const createHttpFetcher: (host: string) => HttpFetcher;
51
+ declare const createHttpClient: <S extends Schema>(fetcher: HttpFetcher) => {
52
+ fetch: <M extends keyof S, P extends keyof S[M]>(method: M, routeKey: Extract<P, string>, props?: Props<GetRoute<S, M, P>>) => Promise<GetRoute<S, M, P>["response"]>;
53
+ get<P_1 extends keyof S["GET"]>(routeKey: Extract<P_1, string>, props?: Props<GetRoute<S, "GET", P_1>>): Promise<GetRoute<S, "GET", P_1>["response"]>;
54
+ post<P_1 extends keyof S["POST"]>(routeKey: Extract<P_1, string>, props?: Props<GetRoute<S, "POST", P_1>>): Promise<GetRoute<S, "POST", P_1>["response"]>;
55
+ };
56
+
57
+ type MessageCallback = (payload: any) => void;
58
+ type ClientProps = {
59
+ endpoint: string;
60
+ authorizer: string;
61
+ token?: string;
62
+ };
63
+ type ClientPropsProvider = () => Promise<ClientProps> | ClientProps;
64
+ declare const createPubSubClient: (app: string | (() => string), props: ClientProps | ClientPropsProvider) => {
65
+ connected: boolean;
66
+ topics: string[];
67
+ publish(topic: string, event: string, payload: unknown, qos: QoS): Promise<void>;
68
+ subscribe(topic: string, event: string, callback: MessageCallback): Promise<_awsless_mqtt.Unsubscribe>;
69
+ destroy(): Promise<void>;
70
+ };
71
+
72
+ interface RpcSchema {
73
+ }
74
+
75
+ export { Auth, type AuthResources, GraphQL, type GraphQLResources, type GraphQLSchema, type HTTP, type HttpFetcher, type RpcSchema, createHttpClient, createHttpFetcher, createPubSubClient, getAuthProps, getGraphQLProps };
package/dist/client.js CHANGED
@@ -89,13 +89,14 @@ var createPubSubClient = (app, props) => {
89
89
  password: config.token
90
90
  };
91
91
  });
92
+ const getApp = () => {
93
+ return typeof app === "string" ? app : app();
94
+ };
92
95
  const getPubSubTopic = (name) => {
93
- const appName = typeof app === "string" ? app : app();
94
- return `${appName}/pubsub/${name}`;
96
+ return `${getApp()}/pubsub/${name}`;
95
97
  };
96
98
  const fromPubSubTopic = (name) => {
97
- const appName = typeof app === "string" ? app : app();
98
- return name.replace(`${appName}/pubsub/`, "");
99
+ return name.replace(`${getApp()}/pubsub/`, "");
99
100
  };
100
101
  return {
101
102
  ...mqtt,
Binary file
@@ -0,0 +1,172 @@
1
+ import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
2
+ import { Mock } from 'vitest';
3
+ import { Duration, DurationFormat } from '@awsless/duration';
4
+ import { QoS } from '@awsless/iot';
5
+ export { QoS } from '@awsless/iot';
6
+ import { IoTCustomAuthorizerResult } from 'aws-lambda';
7
+
8
+ declare const regions: readonly ["us-east-2", "us-east-1", "us-west-1", "us-west-2", "af-south-1", "ap-east-1", "ap-south-2", "ap-southeast-3", "ap-southeast-4", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-south-1", "eu-west-3", "eu-south-2", "eu-north-1", "eu-central-2", "me-south-1", "me-central-1", "sa-east-1"];
9
+ type Region = (typeof regions)[number];
10
+
11
+ type Credentials = AwsCredentialIdentityProvider;
12
+
13
+ type CommandContext = {
14
+ region: Region;
15
+ credentials: Credentials;
16
+ accountId: string;
17
+ update: (msg: string) => void;
18
+ };
19
+ type CommandHandler = (options: CommandOptions, context: CommandContext) => Promise<string | undefined | void>;
20
+ declare class CommandOptions {
21
+ private opts;
22
+ constructor(args: string[]);
23
+ get(name: string): any;
24
+ private getAssertType;
25
+ number(name: string): number;
26
+ string(name: string): string;
27
+ boolean(name: string): boolean;
28
+ }
29
+
30
+ interface AlertMock {
31
+ }
32
+ interface AlertMockResponse {
33
+ }
34
+ declare const mockAlert: (cb: (mock: AlertMock) => void) => AlertMockResponse;
35
+
36
+ declare const mockCache: () => void;
37
+
38
+ interface FunctionMock {
39
+ }
40
+ interface FunctionMockResponse {
41
+ }
42
+ declare const mockFunction: (cb: (mock: FunctionMock) => void) => FunctionMockResponse;
43
+
44
+ declare const mockPubSub: () => Mock;
45
+
46
+ interface QueueMock {
47
+ }
48
+ interface QueueMockResponse {
49
+ }
50
+ declare const mockQueue: (cb: (mock: QueueMock) => void) => QueueMockResponse;
51
+
52
+ interface TaskMock {
53
+ }
54
+ interface TaskMockResponse {
55
+ }
56
+ declare const mockTask: (cb: (mock: TaskMock) => void) => TaskMockResponse;
57
+
58
+ interface TopicMock {
59
+ }
60
+ interface TopicMockResponse {
61
+ }
62
+ declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
63
+
64
+ declare const getAlertName: <N extends string>(resourceName: N) => `app--alert--${N}`;
65
+ interface AlertResources {
66
+ }
67
+ declare const Alert: AlertResources;
68
+
69
+ declare const getAuthProps: (name: string) => {
70
+ readonly userPoolId: string | undefined;
71
+ readonly clientId: string | undefined;
72
+ };
73
+ interface AuthResources {
74
+ }
75
+ declare const Auth: AuthResources;
76
+
77
+ declare const getCacheProps: (name: string, stack?: string) => {
78
+ readonly host: string;
79
+ readonly port: number;
80
+ };
81
+ interface CacheResources {
82
+ }
83
+ declare const Cache: CacheResources;
84
+
85
+ declare const getConfigName: (name: string) => string;
86
+ declare const getConfigValue: (name: string) => string;
87
+ declare const setConfigValue: (name: string, value: string) => void;
88
+ interface ConfigResources {
89
+ }
90
+ declare const Config: ConfigResources;
91
+
92
+ declare const getFunctionName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--function--${N}`;
93
+ interface FunctionResources {
94
+ }
95
+ declare const Function: FunctionResources;
96
+ declare const Fn: FunctionResources;
97
+
98
+ declare const getPubSubTopic: <N extends string>(name: N) => `app/pubsub/${N}`;
99
+
100
+ type PublishOptions = {
101
+ qos?: QoS;
102
+ };
103
+ declare const PubSub: {
104
+ publish(topic: string, event: string, payload: unknown, opts?: PublishOptions): Promise<void>;
105
+ };
106
+ type PubsubAuthorizerResponse = {
107
+ authorized: boolean;
108
+ principalId?: string;
109
+ publish?: string[];
110
+ subscribe?: string[];
111
+ disconnectAfter?: Duration;
112
+ refreshAfter?: Duration;
113
+ };
114
+ type PubsubAuthorizerEvent = {
115
+ protocolData: {
116
+ mqtt?: {
117
+ password?: string;
118
+ };
119
+ };
120
+ };
121
+ declare const pubsubAuthorizerHandle: (cb: (token: string) => PubsubAuthorizerResponse | Promise<PubsubAuthorizerResponse>) => Promise<(event: PubsubAuthorizerEvent) => Promise<IoTCustomAuthorizerResult>>;
122
+ declare const pubsubAuthorizerResponse: (props: PubsubAuthorizerResponse) => IoTCustomAuthorizerResult;
123
+
124
+ declare const getQueueName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--queue--${N}`;
125
+ declare const getQueueUrl: (name: string, stack?: string) => string | undefined;
126
+ interface QueueResources {
127
+ }
128
+ declare const Queue: QueueResources;
129
+
130
+ type RpcAuthorizerResponse = {
131
+ authorized: false;
132
+ } | {
133
+ authorized: true;
134
+ context?: unknown;
135
+ lockKey?: string;
136
+ ttl: DurationFormat;
137
+ };
138
+
139
+ declare const getSearchName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--search--${N}`;
140
+ declare const getSearchProps: (name: string, stack?: string) => {
141
+ readonly domain: string | undefined;
142
+ };
143
+ interface SearchResources {
144
+ }
145
+ declare const Search: SearchResources;
146
+
147
+ declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--${string}`;
148
+
149
+ declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--${string}`;
150
+ interface StoreResources {
151
+ }
152
+ declare const Store: StoreResources;
153
+
154
+ declare const getTableName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--table--${N}`;
155
+ interface TableResources {
156
+ }
157
+ declare const Table: TableResources;
158
+
159
+ declare const getTaskName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--task--${N}`;
160
+ interface TaskResources {
161
+ }
162
+ declare const Task: TaskResources;
163
+
164
+ declare const getTopicName: <N extends string>(resourceName: N) => `app--topic--${N}`;
165
+ interface TopicResources {
166
+ }
167
+ declare const Topic: TopicResources;
168
+
169
+ declare const APP: "app";
170
+ declare const STACK: "stack";
171
+
172
+ 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, mockCache, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.475",
3
+ "version": "0.0.477",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,19 +28,19 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/dynamodb": "^0.1.5",
32
31
  "@awsless/json": "^0.0.8",
33
- "@awsless/lambda": "^0.0.32",
34
- "@awsless/iot": "^0.0.3",
35
- "@awsless/mqtt": "^0.0.2",
36
- "@awsless/s3": "^0.0.20",
37
32
  "@awsless/open-search": "^0.0.17",
38
- "@awsless/sqs": "^0.0.8",
39
- "@awsless/ssm": "^0.0.7",
40
- "@awsless/sns": "^0.0.10",
33
+ "@awsless/redis": "^0.0.14",
34
+ "@awsless/dynamodb": "^0.1.5",
35
+ "@awsless/s3": "^0.0.20",
36
+ "@awsless/lambda": "^0.0.32",
41
37
  "@awsless/validate": "^0.0.19",
38
+ "@awsless/sns": "^0.0.10",
39
+ "@awsless/mqtt": "^0.0.2",
40
+ "@awsless/iot": "^0.0.3",
42
41
  "@awsless/weak-cache": "^0.0.1",
43
- "@awsless/redis": "^0.0.14"
42
+ "@awsless/ssm": "^0.0.7",
43
+ "@awsless/sqs": "^0.0.8"
44
44
  },
45
45
  "dependencies": {
46
46
  "@arcanyx/cidr-slicer": "^0.3.0",
@@ -124,9 +124,9 @@
124
124
  "@awsless/formation": "^0.0.73",
125
125
  "@awsless/graphql": "^0.0.9",
126
126
  "@awsless/json": "^0.0.8",
127
- "@awsless/ts-file-cache": "^0.0.12",
128
127
  "@awsless/size": "^0.0.2",
129
- "@awsless/validate": "^0.0.19"
128
+ "@awsless/validate": "^0.0.19",
129
+ "@awsless/ts-file-cache": "^0.0.12"
130
130
  },
131
131
  "devDependencies": {
132
132
  "@node-rs/bcrypt": "^1.10.5"