ts-ag 1.1.25 → 1.2.0

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.
@@ -1,7 +1,5 @@
1
- import { styleText } from "util";
1
+ import { styleText } from "node:util";
2
2
  //#region src/utils/cli.ts
3
3
  const colorText = (format, text) => styleText(format, String(text), { validateStream: false });
4
4
  //#endregion
5
5
  export { colorText as t };
6
-
7
- //# sourceMappingURL=cli-CoTTeqrl.mjs.map
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ import { AdminGetUserCommandOutput, AttributeType, CognitoIdentityProviderClient
7
7
  import { S3Client } from "@aws-sdk/client-s3";
8
8
  import { DynamoDBToolboxError } from "dynamodb-toolbox";
9
9
  import { Plugin } from "unified";
10
- import { styleText } from "util";
10
+ import { styleText } from "node:util";
11
11
  import { APIGatewayProxyEventV2WithLambdaAuthorizer, APIGatewayProxyResultV2, APIGatewayRequestAuthorizerEventV2, Context } from "aws-lambda";
12
12
  import * as _$_smithy_types0 from "@smithy/types";
13
13
  import { PackageJson } from "type-fest";
package/dist/index.mjs CHANGED
@@ -1,17 +1,19 @@
1
- import { n as readPackageJson, r as writeIfDifferent, t as exists } from "./fs-y6bE7U3-.mjs";
2
- import { t as colorText } from "./cli-CoTTeqrl.mjs";
3
1
  import { parse, stringify } from "devalue";
4
2
  import * as v from "valibot";
5
3
  import { parse as parse$1 } from "cookie";
6
4
  import { Result, ResultAsync } from "neverthrow";
7
5
  import { AdminGetUserCommand, AdminInitiateAuthCommand, AdminListGroupsForUserCommand, ChangePasswordCommand, CognitoIdentityProviderClient, ConfirmForgotPasswordCommand, ConfirmSignUpCommand, ForgotPasswordCommand, GlobalSignOutCommand, RespondToAuthChallengeCommand, SignUpCommand } from "@aws-sdk/client-cognito-identity-provider";
8
- import { createHmac } from "crypto";
6
+ import { createHmac } from "node:crypto";
9
7
  import { GetObjectCommand, HeadObjectCommand, S3Client } from "@aws-sdk/client-s3";
10
8
  import { getSignedUrl as getSignedUrl$1 } from "@aws-sdk/s3-request-presigner";
11
9
  import { DynamoDBToolboxError } from "dynamodb-toolbox";
12
10
  import rehypeParse from "rehype-parse";
13
11
  import { unified } from "unified";
14
12
  import { isEqual, isObject } from "radash";
13
+ import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
14
+ import { dirname } from "node:path";
15
+ import chalk from "chalk";
16
+ import { styleText } from "node:util";
15
17
  //#region src/lambda/client-types.ts
16
18
  const HTTPMethods = [
17
19
  "GET",
@@ -1563,6 +1565,43 @@ function pruneToShape(source, shape) {
1563
1565
  }
1564
1566
  }
1565
1567
  //#endregion
1568
+ //#region src/utils/fs.ts
1569
+ /**
1570
+ * @returns true if a filepath exists
1571
+ */
1572
+ async function exists(filePath) {
1573
+ try {
1574
+ await lstat(filePath);
1575
+ return true;
1576
+ } catch {
1577
+ return false;
1578
+ }
1579
+ }
1580
+ /**
1581
+ * Writes data to a filepath if it is different
1582
+ * @returns true if the file is written to
1583
+ */
1584
+ async function writeIfDifferent(filePath, newData) {
1585
+ const directory = dirname(filePath);
1586
+ if (!await exists(directory)) await mkdir(directory, { recursive: true });
1587
+ if (await exists(filePath)) {
1588
+ if (await readFile(filePath, "utf8") === newData) return false;
1589
+ }
1590
+ await writeFile(filePath, newData, "utf8");
1591
+ console.log(chalk.green("Writing to"), filePath);
1592
+ return true;
1593
+ }
1594
+ /**
1595
+ * @returns the json object packageJson or undefined if it doesnt exist
1596
+ */
1597
+ async function readPackageJson(filePath) {
1598
+ if (!await exists(filePath)) return void 0;
1599
+ return JSON.parse(await readFile(filePath, { encoding: "utf-8" }));
1600
+ }
1601
+ //#endregion
1602
+ //#region src/utils/cli.ts
1603
+ const colorText = (format, text) => styleText(format, String(text), { validateStream: false });
1604
+ //#endregion
1566
1605
  export { HTTPMethods, changePassword, colorText, computeSecretHash, confirmForgotPassword, confirmSignup, createApiRequest, deepDiff, error_cognito, error_dynamo, error_lambda_badRequest, error_lambda_conflict, error_lambda_forbidden, error_lambda_fromCognito, error_lambda_fromDynamo, error_lambda_fromS3, error_lambda_fromSes, error_lambda_internal, error_lambda_notFound, error_lambda_unauthorized, error_s3, error_ses, exists, extractAttributes, extractToc, forgotPassword, getByPath, getCognitoClient, getCookies, getErrorName, getObject, getObjectString, getS3, getSchemaByPath, getSignedUrl, getUserDetails, getUserGroups, isRecord, isSchema, is_s3_notFound, login, logout, objectExists, parseRaw, pruneToShape, readPackageJson, refreshOAuthToken, refreshTokens, resetPassword, response_error, response_ok, response_valibotError, setByPath, signUp, unwrap, verifyOAuthToken, wrapHandler, writeIfDifferent };
1567
1606
 
1568
1607
  //# sourceMappingURL=index.mjs.map