ts-ag 1.0.9 → 1.0.11

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.
Files changed (55) hide show
  1. package/dist/cognito/password.d.ts +1 -1
  2. package/dist/cognito/password.d.ts.map +1 -1
  3. package/dist/cognito/password.js +3 -3
  4. package/dist/cognito/user.d.ts.map +1 -1
  5. package/dist/cognito/user.js +1 -1
  6. package/dist/dynamo/errors.d.ts +1 -1
  7. package/dist/dynamo/errors.d.ts.map +1 -1
  8. package/dist/dynamo/errors.js +1 -1
  9. package/dist/lambda/browser.d.ts +0 -2
  10. package/dist/lambda/browser.d.ts.map +1 -1
  11. package/dist/lambda/browser.js +0 -2
  12. package/dist/lambda/client.d.ts.map +1 -1
  13. package/dist/lambda/client.js +2 -1
  14. package/dist/lambda/response.d.ts.map +1 -1
  15. package/dist/lambda/server/authentication.d.ts.map +1 -1
  16. package/dist/lambda/server/authentication.js +2 -2
  17. package/dist/rehype/flat-toc.d.ts.map +1 -1
  18. package/dist/rehype/flat-toc.js +1 -1
  19. package/dist/s3/object.d.ts.map +1 -1
  20. package/dist/s3/object.js +1 -1
  21. package/dist/s3/signedUrl.d.ts.map +1 -1
  22. package/dist/s3/signedUrl.js +1 -1
  23. package/dist/scripts/ts-alias.js +2 -2
  24. package/dist/utils/fs.d.ts.map +1 -1
  25. package/dist/utils/object.d.ts +24 -0
  26. package/dist/utils/object.d.ts.map +1 -1
  27. package/dist/utils/object.js +62 -0
  28. package/package.json +27 -37
  29. package/src/cognito/password.ts +5 -3
  30. package/src/cognito/user.ts +2 -1
  31. package/src/dynamo/errors.ts +1 -1
  32. package/src/dynamo/errors.unit.test.ts +1 -0
  33. package/src/lambda/browser.ts +0 -2
  34. package/src/lambda/client.ts +3 -1
  35. package/src/lambda/errors.unit.test.ts +1 -0
  36. package/src/lambda/handlerUtils.unit.test.ts +2 -1
  37. package/src/lambda/response.ts +1 -0
  38. package/src/lambda/server/authentication.ts +2 -2
  39. package/src/rehype/flat-toc.ts +2 -2
  40. package/src/s3/object.ts +2 -1
  41. package/src/s3/signedUrl.ts +1 -1
  42. package/src/scripts/clean-dist.ts +1 -0
  43. package/src/scripts/ts-alias.ts +3 -2
  44. package/src/types/deep.ts +2 -2
  45. package/src/utils/fs.ts +1 -0
  46. package/src/utils/object.ts +66 -0
  47. package/src/utils/object.unit.test.ts +104 -1
  48. package/dist/lambda/deserializer.d.ts +0 -2
  49. package/dist/lambda/deserializer.d.ts.map +0 -1
  50. package/dist/lambda/deserializer.js +0 -12
  51. package/dist/lambda/serializer.d.ts +0 -2
  52. package/dist/lambda/serializer.d.ts.map +0 -1
  53. package/dist/lambda/serializer.js +0 -15
  54. package/src/lambda/deserializer.ts +0 -11
  55. package/src/lambda/serializer.ts +0 -14
@@ -1,5 +1,5 @@
1
- import type { type_error_cognito } from './errors.js';
2
1
  import { ResultAsync } from 'neverthrow';
2
+ import type { type_error_cognito } from './errors.js';
3
3
  /**
4
4
  * Computes Cognito secret hash used for client-side authentication flows.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/cognito/password.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAKlG;AAID;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,qLAe1B,CAAC;AAIF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;;;;;;6HAiBjC,CAAC;AAIF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;qHAgBzB,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;sHAe1B,CAAC;AAIF;;;;;;;;GAQ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;;;;;8HAoBzB,CAAC;AAGF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;wIAqBlB,CAAC;AAGF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAmC5B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;EAgC7B,CAAC"}
@@ -1,8 +1,8 @@
1
+ import { createHmac } from 'crypto';
1
2
  import { AdminInitiateAuthCommand, ChangePasswordCommand, ConfirmForgotPasswordCommand, ConfirmSignUpCommand, ForgotPasswordCommand, GlobalSignOutCommand, RespondToAuthChallengeCommand, SignUpCommand } from '@aws-sdk/client-cognito-identity-provider';
2
- import { error_cognito, error_cognito_auth } from './errors.js';
3
- import { getCognitoClient } from './client.js';
4
3
  import { ResultAsync } from 'neverthrow';
5
- import { createHmac } from 'crypto';
4
+ import { getCognitoClient } from './client.js';
5
+ import { error_cognito, error_cognito_auth } from './errors.js';
6
6
  /**
7
7
  * Computes Cognito secret hash used for client-side authentication flows.
8
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/cognito/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EAEd,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,GAAG;IAClF,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;8EAW1B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,0BAUnE;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;oJAazB,CAAC"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/cognito/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,aAAa,EAEd,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAKzC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,GAAG;IAClF,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;;;8EAW1B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,0BAUnE;AAED;;GAEG;AACH,eAAO,MAAM,aAAa;;;oJAazB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { AdminGetUserCommand, AdminListGroupsForUserCommand } from '@aws-sdk/client-cognito-identity-provider';
2
- import { getCognitoClient } from './client.js';
3
2
  import { ResultAsync } from 'neverthrow';
3
+ import { getCognitoClient } from './client.js';
4
4
  import { error_cognito } from './errors.js';
5
5
  /**
6
6
  * Performs an AdminGetUserCommand and extracts the user attributes into an object
@@ -2,7 +2,7 @@ export declare const error_dynamo: {
2
2
  type: "dynamo";
3
3
  };
4
4
  export type type_error_dynamo = typeof error_dynamo;
5
- export declare function error_lambda_fromDynamo(e: type_error_dynamo): {
5
+ export declare function error_lambda_fromDynamo(_e: type_error_dynamo): {
6
6
  type: "lambda_internal";
7
7
  message: string;
8
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/dynamo/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;CAA8B,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC;AAEpD,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,iBAAiB;;;EAE3D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/dynamo/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;;CAA8B,CAAC;AAExD,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC;AAEpD,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,iBAAiB;;;EAE5D"}
@@ -1,5 +1,5 @@
1
1
  import { error_lambda_internal } from '../lambda/errors.js';
2
2
  export const error_dynamo = { type: 'dynamo' };
3
- export function error_lambda_fromDynamo(e) {
3
+ export function error_lambda_fromDynamo(_e) {
4
4
  return error_lambda_internal('Internal server error');
5
5
  }
@@ -1,6 +1,4 @@
1
1
  export * from './client-types.js';
2
2
  export * from './client.js';
3
3
  export * from './handlerUtils.js';
4
- export * from './serializer.js';
5
- export * from './deserializer.js';
6
4
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/lambda/browser.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/lambda/browser.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
@@ -1,5 +1,3 @@
1
1
  export * from './client-types.js';
2
2
  export * from './client.js';
3
3
  export * from './handlerUtils.js';
4
- export * from './serializer.js';
5
- export * from './deserializer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lambda/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA0D7E,QAAA,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B,CAAC,GAAG,SAAS,YAAY,IAAI,CACzD,IAAI,SAAS,GAAG,CAAC,MAAM,CAAC,EACxB,MAAM,SAAS,OAAO,CAAC,GAAG,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,EAErD,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,WAAW,KAClB,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,aAAa,GAAG,CAAC,CAAC,kBAAkB,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,YAAY,EACvD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7E,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,kBAAkB,CAAC,GAAG,CAAC,CAmBzB"}
@@ -27,10 +27,11 @@ environment, apiUrl, headers) {
27
27
  if (queryString)
28
28
  url += `?${queryString}`;
29
29
  }
30
- headers = { 'Content-Type': 'application/json', ...(headers || {}) };
30
+ headers = { 'Content-Type': 'application/json', ...headers };
31
31
  const response = await fetch(url, {
32
32
  method,
33
33
  headers,
34
+ // oxlint-disable-next-line
34
35
  body: bodyMethods.includes(method) ? JSON.stringify(input) : undefined,
35
36
  credentials: 'include'
36
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/lambda/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAA2B,KAAK,iBAAiB,EAAE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,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,EAAE,OAAO,EAAE,GAAG,uCAQzG;AAED,wBAAgB,WAAW,CAAC,IAAI,SAAS;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS;;;;;EAG/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../../src/lambda/server/authentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0CAA0C,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIpC;;GAEG;AACH,eAAO,MAAM,UAAU;;;EAuBtB,CAAC"}
1
+ {"version":3,"file":"authentication.d.ts","sourceRoot":"","sources":["../../../src/lambda/server/authentication.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0CAA0C,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AAEjH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,UAAU;;;EAuBtB,CAAC"}
@@ -1,6 +1,6 @@
1
- import { Result } from 'neverthrow';
2
- import { parse } from 'cookie';
3
1
  import { error_lambda_unauthorized } from '../errors.js';
2
+ import { parse } from 'cookie';
3
+ import { Result } from 'neverthrow';
4
4
  /**
5
5
  * Wraps cookies parse along with the api gateway event with neverthrow
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"flat-toc.d.ts","sourceRoot":"","sources":["../../src/rehype/flat-toc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAe,OAAO,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAKtC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CAOvC,CAAC;AACF,MAAM,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;AAC7B,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBpE;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAoB/C"}
1
+ {"version":3,"file":"flat-toc.d.ts","sourceRoot":"","sources":["../../src/rehype/flat-toc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAe,OAAO,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CAOvC,CAAC;AACF,MAAM,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;AAC7B,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBpE;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAoB/C"}
@@ -1,5 +1,5 @@
1
- import { unified } from 'unified';
2
1
  import rehypeParse from 'rehype-parse';
2
+ import { unified } from 'unified';
3
3
  /**
4
4
  * This rehype plugin extracts the headings from the markdown elements but also the raw elements.
5
5
  * So we get html headings in the TOC as well
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/s3/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;EAiBrB,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,YAAY,CAAC,CAEzG"}
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/s3/object.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;;GAMG;AACH,eAAO,MAAM,SAAS;;EAiBrB,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,OAAO,YAAY,CAAC,CAEzG"}
package/dist/s3/object.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { GetObjectCommand } from '@aws-sdk/client-s3';
1
2
  import { ResultAsync } from 'neverthrow';
2
3
  import { getS3 } from './client.js';
3
- import { GetObjectCommand } from '@aws-sdk/client-s3';
4
4
  import { error_s3_get } from './errors.js';
5
5
  /**
6
6
  * Retrieves an object from an S3 bucket.
@@ -1 +1 @@
1
- {"version":3,"file":"signedUrl.d.ts","sourceRoot":"","sources":["../../src/s3/signedUrl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,eAAO,MAAM,YAAY,wjBAAwD,CAAC"}
1
+ {"version":3,"file":"signedUrl.d.ts","sourceRoot":"","sources":["../../src/s3/signedUrl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,YAAY,wjBAAwD,CAAC"}
@@ -1,3 +1,3 @@
1
- import { ResultAsync } from 'neverthrow';
2
1
  import { getSignedUrl as baseGetSignedUrl } from '@aws-sdk/s3-request-presigner';
2
+ import { ResultAsync } from 'neverthrow';
3
3
  export const getSignedUrl = ResultAsync.fromThrowable(baseGetSignedUrl, (e) => e);
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import console from 'console';
2
3
  // NOTE: dont use aliases here cause this file needs to be compiled first
3
4
  import { existsSync, statSync, readFileSync } from 'fs';
4
5
  import { dirname, join, basename } from 'path';
5
6
  import { watch } from 'chokidar';
6
- import { replaceTscAliasPaths } from 'tsc-alias';
7
7
  import { glob } from 'glob';
8
- import console from 'console';
8
+ import { replaceTscAliasPaths } from 'tsc-alias';
9
9
  // Cache for tsconfig.json files
10
10
  const tsconfigCache = new Map();
11
11
  // Parse command-line arguments
@@ -1 +1 @@
1
- {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB1F;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGxF"}
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB1F;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAGxF"}
@@ -35,4 +35,28 @@ export declare function getByPath<T extends object>(obj: T, path: string): any;
35
35
  * @returns {DeepPartial<B>} Deep partial of `b` containing only differences vs `a`.
36
36
  */
37
37
  export declare const deepDiff: <A extends object, B extends object>(a: A, b: B) => DeepPartial<B>;
38
+ /**
39
+ * Deeply prunes `source` to match the *shape* of `shape`.
40
+ *
41
+ * Rules:
42
+ * - Only keys that exist on `shape` are kept.
43
+ * - Pruning is deep for nested plain objects.
44
+ * - Arrays are supported by using the first element of `shape` as the element-shape.
45
+ * - If `shape` is `[]`, returns `[]` (drops all elements).
46
+ * - Primitive values are kept as-is (no type coercion) if the key exists in `shape`.
47
+ * - If `shape` expects an object/array but `source` is not compatible, returns an empty object/array of that shape.
48
+ *
49
+ * @typeParam S - Source object type.
50
+ * @typeParam Sh - Shape object type.
51
+ * @param source - The object to prune.
52
+ * @param shape - The object whose keys/structure are the allowlist.
53
+ * @returns A new value derived from `source`, containing only fields present in `shape`, pruned deeply.
54
+ *
55
+ * @example
56
+ * const source = { a: 1, b: { c: 2, d: 3 }, e: [ { x: 1, y: 2 }, { x: 3, y: 4 } ], z: 9 };
57
+ * const shape = { a: 0, b: { c: 0 }, e: [ { x: 0 } ] };
58
+ * // => { a: 1, b: { c: 2 }, e: [ { x: 1 }, { x: 3 } ] }
59
+ * const out = pruneToShape(source, shape);
60
+ */
61
+ export declare function pruneToShape<S, Sh>(source: S, shape: Sh): Sh;
38
62
  //# sourceMappingURL=object.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAkB/E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAWrE;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,iBAAiB,CAAC,8CAsB3C,CAAC"}
1
+ {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAkB/E;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAWrE;AAID;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,iBAAiB,CAAC,8CAsB3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAwC5D"}
@@ -83,3 +83,65 @@ export const deepDiff = (a, b) => {
83
83
  }
84
84
  return out;
85
85
  };
86
+ /**
87
+ * Deeply prunes `source` to match the *shape* of `shape`.
88
+ *
89
+ * Rules:
90
+ * - Only keys that exist on `shape` are kept.
91
+ * - Pruning is deep for nested plain objects.
92
+ * - Arrays are supported by using the first element of `shape` as the element-shape.
93
+ * - If `shape` is `[]`, returns `[]` (drops all elements).
94
+ * - Primitive values are kept as-is (no type coercion) if the key exists in `shape`.
95
+ * - If `shape` expects an object/array but `source` is not compatible, returns an empty object/array of that shape.
96
+ *
97
+ * @typeParam S - Source object type.
98
+ * @typeParam Sh - Shape object type.
99
+ * @param source - The object to prune.
100
+ * @param shape - The object whose keys/structure are the allowlist.
101
+ * @returns A new value derived from `source`, containing only fields present in `shape`, pruned deeply.
102
+ *
103
+ * @example
104
+ * const source = { a: 1, b: { c: 2, d: 3 }, e: [ { x: 1, y: 2 }, { x: 3, y: 4 } ], z: 9 };
105
+ * const shape = { a: 0, b: { c: 0 }, e: [ { x: 0 } ] };
106
+ * // => { a: 1, b: { c: 2 }, e: [ { x: 1 }, { x: 3 } ] }
107
+ * const out = pruneToShape(source, shape);
108
+ */
109
+ export function pruneToShape(source, shape) {
110
+ return pruneAny(source, shape);
111
+ function pruneAny(src, sh) {
112
+ // Arrays: use first element as the "element shape"
113
+ if (Array.isArray(sh)) {
114
+ if (!Array.isArray(src))
115
+ return [];
116
+ if (sh.length === 0)
117
+ return [];
118
+ const elemShape = sh[0];
119
+ return src.map((v) => pruneAny(v, elemShape));
120
+ }
121
+ // Plain objects: keep only keys present on shape, recursively.
122
+ if (isPlainObject(sh)) {
123
+ const out = {};
124
+ const srcObj = isPlainObject(src) ? src : undefined;
125
+ for (const key of Object.keys(sh)) {
126
+ const shVal = sh[key];
127
+ const srcVal = srcObj ? srcObj[key] : undefined;
128
+ if (Array.isArray(shVal) || isPlainObject(shVal)) {
129
+ out[key] = pruneAny(srcVal, shVal);
130
+ }
131
+ else {
132
+ // Primitive (or function/date/etc in shape): key exists => keep source value as-is
133
+ out[key] = srcVal;
134
+ }
135
+ }
136
+ return out;
137
+ }
138
+ // Non-object shape => allowed leaf; just return source leaf as-is.
139
+ return src;
140
+ }
141
+ function isPlainObject(v) {
142
+ if (v === null || typeof v !== 'object')
143
+ return false;
144
+ const proto = Object.getPrototypeOf(v);
145
+ return proto === Object.prototype || proto === null;
146
+ }
147
+ }
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "ts-ag",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Useful TS stuff",
5
5
  "bugs": "https://github.com/ageorgeh/ts-ag/issues",
6
+ "author": "Alexander Hornung",
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/ageorgeh/ts-ag.git"
9
10
  },
10
- "author": "Alexander Hornung",
11
+ "bin": {
12
+ "clean-dist": "dist/scripts/clean-dist.js",
13
+ "ts-alias": "dist/scripts/ts-alias.js"
14
+ },
15
+ "files": [
16
+ "./src",
17
+ "./dist"
18
+ ],
11
19
  "type": "module",
12
20
  "exports": {
13
21
  "./package.json": "./package.json",
@@ -22,33 +30,20 @@
22
30
  }
23
31
  }
24
32
  },
25
- "bin": {
26
- "clean-dist": "dist/scripts/clean-dist.js",
27
- "ts-alias": "dist/scripts/ts-alias.js"
28
- },
29
- "files": [
30
- "./src",
31
- "./dist"
32
- ],
33
33
  "scripts": {
34
34
  "build": "tsgo && node dist/scripts/ts-alias.js",
35
- "deps:bump": "pnpm dlx npm-check-updates -u --target minor",
36
- "deps:refresh": "pnpm deps:bump && pnpm install",
37
- "deps:update": "pnpm -r update",
38
- "login": "npm login --registry=https://registry.npmjs.org/",
35
+ "fmt": "oxfmt",
36
+ "fmt:check": "oxfmt --check",
37
+ "lint": "oxlint",
38
+ "lint:fix": "oxlint --fix",
39
39
  "prepare": "husky",
40
- "publish:local": "pnpm version prerelease --preid dev --no-git-tag-version && pnpm publish --registry http://localhost:4873 --tag dev --access public --no-git-checks --json > ./publishLocal.json",
41
- "publish:prerelease": "pnpm publish --tag dev --access public --no-git-checks --registry=https://registry.npmjs.org/ --json > ./publish.json",
42
- "run-publish": "pnpm publish --access public --no-git-checks --registry=https://registry.npmjs.org/ --json > ./publish.json",
43
- "run-version": "pnpm version patch --no-git-tag-version",
44
40
  "test": "vitest --run",
45
- "tsc:watch": "concurrently \" npx tsc -w \" \" npx ts-alias -w \"",
46
- "version:prerelease": "pnpm version prerelease --preid dev --no-git-tag-version"
41
+ "tsc:watch": "concurrently \" npx tsc -w \" \" npx ts-alias -w \""
47
42
  },
48
43
  "dependencies": {
49
- "@aws-sdk/client-cognito-identity-provider": "3.983.0",
50
- "@aws-sdk/client-s3": "3.983.0",
51
- "@aws-sdk/s3-request-presigner": "3.983.0",
44
+ "@aws-sdk/client-cognito-identity-provider": "3.993.0",
45
+ "@aws-sdk/client-s3": "3.993.0",
46
+ "@aws-sdk/s3-request-presigner": "3.993.0",
52
47
  "@types/aws-lambda": "8.10.160",
53
48
  "@ungap/structured-clone": "1.3.0",
54
49
  "chalk": "5.6.2",
@@ -56,40 +51,35 @@
56
51
  "cookie": "1.1.1",
57
52
  "cycle": "1.0.3",
58
53
  "dequal": "^2.0.3",
59
- "devalue": "5.6.2",
60
- "get-tsconfig": "^4.13.1",
61
- "glob": "13.0.1",
54
+ "devalue": "^5.6.3",
55
+ "get-tsconfig": "^4.13.6",
56
+ "glob": "^13.0.6",
62
57
  "jose": "6.1.3",
63
58
  "neverthrow": "8.2.0",
64
59
  "radash": "^12.1.1",
65
60
  "rehype-parse": "9.0.1",
66
61
  "tsc-alias": "1.8.16",
67
62
  "tsconfck": "3.1.6",
68
- "type-fest": "5.4.3",
63
+ "type-fest": "^5.4.4",
69
64
  "unified": "11.0.5",
70
65
  "valibot": "1.2.0",
71
66
  "vfile": "6.0.3"
72
67
  },
73
68
  "devDependencies": {
74
69
  "@actions/languageserver": "^0.3.44",
75
- "@eslint/js": "^9.39.2",
76
70
  "@types/hast": "3.0.4",
77
- "@types/node": "^24.10.10",
71
+ "@types/node": "^24.10.13",
78
72
  "@types/ungap__structured-clone": "1.2.0",
79
- "@typescript/native-preview": "7.0.0-dev.20260204.1",
73
+ "@typescript/native-preview": "7.0.0-dev.20260218.1",
80
74
  "concurrently": "^9.2.1",
81
- "eslint": "^9.39.2",
82
- "eslint-plugin-import": "^2.32.0",
83
- "globals": "^16.5.0",
75
+ "globals": "^17.3.0",
84
76
  "husky": "^9.1.7",
85
77
  "jiti": "2.6.1",
86
78
  "lint-staged": "^16.2.7",
87
- "npm-check-updates": "^18.3.1",
88
- "prettier": "^3.8.1",
89
- "prettier-plugin-packagejson": "^3.0.0",
79
+ "oxfmt": "^0.33.0",
80
+ "oxlint": "^1.49.0",
90
81
  "semantic-release": "^25.0.3",
91
82
  "typescript": "^5.9.3",
92
- "typescript-eslint": "^8.54.0",
93
83
  "typescript-svelte-plugin": "0.3.50",
94
84
  "vite-tsconfig-paths": "^6.1.1",
95
85
  "vitest": "^4.0.18"
@@ -1,3 +1,5 @@
1
+ import { createHmac } from 'crypto';
2
+
1
3
  import {
2
4
  AdminInitiateAuthCommand,
3
5
  ChangePasswordCommand,
@@ -8,11 +10,11 @@ import {
8
10
  RespondToAuthChallengeCommand,
9
11
  SignUpCommand
10
12
  } from '@aws-sdk/client-cognito-identity-provider';
13
+ import { ResultAsync } from 'neverthrow';
14
+
15
+ import { getCognitoClient } from './client.js';
11
16
  import type { type_error_cognito } from './errors.js';
12
17
  import { error_cognito, error_cognito_auth } from './errors.js';
13
- import { getCognitoClient } from './client.js';
14
- import { ResultAsync } from 'neverthrow';
15
- import { createHmac } from 'crypto';
16
18
 
17
19
  /**
18
20
  * Computes Cognito secret hash used for client-side authentication flows.
@@ -4,8 +4,9 @@ import type {
4
4
  CognitoIdentityProviderServiceException
5
5
  } from '@aws-sdk/client-cognito-identity-provider';
6
6
  import { AdminGetUserCommand, AdminListGroupsForUserCommand } from '@aws-sdk/client-cognito-identity-provider';
7
- import { getCognitoClient } from './client.js';
8
7
  import { ResultAsync } from 'neverthrow';
8
+
9
+ import { getCognitoClient } from './client.js';
9
10
  import { error_cognito } from './errors.js';
10
11
 
11
12
  export type type_userResponse = Omit<AdminGetUserCommandOutput, 'UserAttributes'> & {
@@ -4,6 +4,6 @@ export const error_dynamo = { type: 'dynamo' as const };
4
4
 
5
5
  export type type_error_dynamo = typeof error_dynamo;
6
6
 
7
- export function error_lambda_fromDynamo(e: type_error_dynamo) {
7
+ export function error_lambda_fromDynamo(_e: type_error_dynamo) {
8
8
  return error_lambda_internal('Internal server error');
9
9
  }
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
+
2
3
  import { error_dynamo, error_lambda_fromDynamo } from './errors.js';
3
4
 
4
5
  describe('dynamo errors', () => {
@@ -1,5 +1,3 @@
1
1
  export * from './client-types.js';
2
2
  export * from './client.js';
3
3
  export * from './handlerUtils.js';
4
- export * from './serializer.js';
5
- export * from './deserializer.js';
@@ -1,6 +1,7 @@
1
1
  // import { deserialize } from './deserializer.js';
2
2
  import { parse } from 'devalue';
3
3
  import * as v from 'valibot';
4
+
4
5
  import type { ApiEndpoints, ApiInput, ApiResponse } from './client-types.js';
5
6
 
6
7
  const bodyMethods = ['POST', 'PUT', 'PATCH'] as const;
@@ -41,10 +42,11 @@ async function _apiRequest<T = Response>(
41
42
  if (queryString) url += `?${queryString}`;
42
43
  }
43
44
 
44
- headers = { 'Content-Type': 'application/json', ...(headers || {}) };
45
+ headers = { 'Content-Type': 'application/json', ...headers };
45
46
  const response = await fetch(url, {
46
47
  method,
47
48
  headers,
49
+ // oxlint-disable-next-line
48
50
  body: bodyMethods.includes(method as any) ? JSON.stringify(input) : undefined,
49
51
  credentials: 'include'
50
52
  });
@@ -1,4 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
+
2
3
  import {
3
4
  error_lambda_badRequest,
4
5
  error_lambda_conflict,
@@ -1,5 +1,6 @@
1
- import { describe, expect, it } from 'vitest';
2
1
  import { parse } from 'devalue';
2
+ import { describe, expect, it } from 'vitest';
3
+
3
4
  import { wrapHandler } from './handlerUtils.js';
4
5
 
5
6
  describe('wrapHandler', () => {
@@ -1,4 +1,5 @@
1
1
  import type { BaseIssue, SafeParseResult } from 'valibot';
2
+
2
3
  import { error_lambda_badRequest, type type_error_lambda } from './errors.js';
3
4
  import type { ErrorRawProxyResultV2, OkRawProxyResultV2 } from './handlerUtils.js';
4
5
 
@@ -1,7 +1,7 @@
1
+ import { error_lambda_unauthorized } from '$lambda/errors.js';
1
2
  import type { APIGatewayProxyEventV2WithLambdaAuthorizer, APIGatewayRequestAuthorizerEventV2 } from 'aws-lambda';
2
- import { Result } from 'neverthrow';
3
3
  import { parse } from 'cookie';
4
- import { error_lambda_unauthorized } from '$lambda/errors.js';
4
+ import { Result } from 'neverthrow';
5
5
 
6
6
  /**
7
7
  * Wraps cookies parse along with the api gateway event with neverthrow
@@ -1,8 +1,8 @@
1
1
  import type { Root, RootContent, Element } from 'hast';
2
+ import rehypeParse from 'rehype-parse';
2
3
  import type { Plugin } from 'unified';
3
- import type { VFile } from 'vfile';
4
4
  import { unified } from 'unified';
5
- import rehypeParse from 'rehype-parse';
5
+ import type { VFile } from 'vfile';
6
6
 
7
7
  /**
8
8
  * This rehype plugin extracts the headings from the markdown elements but also the raw elements.
package/src/s3/object.ts CHANGED
@@ -1,6 +1,7 @@
1
+ import { GetObjectCommand } from '@aws-sdk/client-s3';
1
2
  import { ResultAsync } from 'neverthrow';
3
+
2
4
  import { getS3 } from './client.js';
3
- import { GetObjectCommand } from '@aws-sdk/client-s3';
4
5
  import { error_s3_get } from './errors.js';
5
6
 
6
7
  /**
@@ -1,4 +1,4 @@
1
- import { ResultAsync } from 'neverthrow';
2
1
  import { getSignedUrl as baseGetSignedUrl } from '@aws-sdk/s3-request-presigner';
2
+ import { ResultAsync } from 'neverthrow';
3
3
 
4
4
  export const getSignedUrl = ResultAsync.fromThrowable(baseGetSignedUrl, (e) => e);
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { rmSync } from 'fs';
4
4
  import { resolve, dirname, join } from 'path';
5
+
5
6
  import { getTsconfig } from 'get-tsconfig';
6
7
 
7
8
  async function listReferences(tsconfigPath: string, visited = new Set<string>()) {
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import console from 'console';
3
4
  // NOTE: dont use aliases here cause this file needs to be compiled first
4
5
  import { existsSync, statSync, readFileSync } from 'fs';
5
6
  import { dirname, join, basename } from 'path';
7
+
6
8
  import type { FSWatcher } from 'chokidar';
7
9
  import { watch } from 'chokidar';
8
- import { replaceTscAliasPaths } from 'tsc-alias';
9
10
  import { glob } from 'glob';
10
- import console from 'console';
11
+ import { replaceTscAliasPaths } from 'tsc-alias';
11
12
 
12
13
  // Cache for tsconfig.json files
13
14
  const tsconfigCache: Map<string, { config: any; mtime: number }> = new Map();
package/src/types/deep.ts CHANGED
@@ -25,7 +25,7 @@ export type DeepOverride<T, R> = {
25
25
  : T[K]; // Keep original type if not overridden
26
26
  };
27
27
 
28
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
28
+ // oxlint-disable-next-line @typescript-eslint/no-unsafe-function-type
29
29
  type Primitive = string | number | boolean | bigint | symbol | null | undefined | Date | RegExp | Function;
30
30
 
31
31
  export type DeepPartial<T> = T extends Primitive
@@ -37,6 +37,6 @@ export type DeepPartial<T> = T extends Primitive
37
37
  : T;
38
38
 
39
39
  export type DeepRequired<T> = {
40
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
40
+ // oxlint-disable-next-line @typescript-eslint/no-unsafe-function-type
41
41
  [P in keyof T]-?: NonNullable<T[P] extends object ? (T[P] extends Function ? T[P] : DeepRequired<T[P]>) : T[P]>;
42
42
  };
package/src/utils/fs.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { lstat, mkdir, readFile, writeFile } from 'fs/promises';
2
2
  import { dirname } from 'path';
3
+
3
4
  import chalk from 'chalk';
4
5
  import type { PackageJson } from 'type-fest';
5
6
 
@@ -1,4 +1,5 @@
1
1
  import { isEqual, isObject } from 'radash';
2
+
2
3
  import type { DeepPartial } from '../types/deep.js';
3
4
 
4
5
  /**
@@ -92,3 +93,68 @@ export const deepDiff = <A extends object, B extends object>(a: A, b: B): DeepPa
92
93
 
93
94
  return out as DeepPartial<B>;
94
95
  };
96
+
97
+ /**
98
+ * Deeply prunes `source` to match the *shape* of `shape`.
99
+ *
100
+ * Rules:
101
+ * - Only keys that exist on `shape` are kept.
102
+ * - Pruning is deep for nested plain objects.
103
+ * - Arrays are supported by using the first element of `shape` as the element-shape.
104
+ * - If `shape` is `[]`, returns `[]` (drops all elements).
105
+ * - Primitive values are kept as-is (no type coercion) if the key exists in `shape`.
106
+ * - If `shape` expects an object/array but `source` is not compatible, returns an empty object/array of that shape.
107
+ *
108
+ * @typeParam S - Source object type.
109
+ * @typeParam Sh - Shape object type.
110
+ * @param source - The object to prune.
111
+ * @param shape - The object whose keys/structure are the allowlist.
112
+ * @returns A new value derived from `source`, containing only fields present in `shape`, pruned deeply.
113
+ *
114
+ * @example
115
+ * const source = { a: 1, b: { c: 2, d: 3 }, e: [ { x: 1, y: 2 }, { x: 3, y: 4 } ], z: 9 };
116
+ * const shape = { a: 0, b: { c: 0 }, e: [ { x: 0 } ] };
117
+ * // => { a: 1, b: { c: 2 }, e: [ { x: 1 }, { x: 3 } ] }
118
+ * const out = pruneToShape(source, shape);
119
+ */
120
+ export function pruneToShape<S, Sh>(source: S, shape: Sh): Sh {
121
+ return pruneAny(source as unknown, shape as unknown) as Sh;
122
+
123
+ function pruneAny(src: unknown, sh: unknown): unknown {
124
+ // Arrays: use first element as the "element shape"
125
+ if (Array.isArray(sh)) {
126
+ if (!Array.isArray(src)) return [];
127
+ if (sh.length === 0) return [];
128
+ const elemShape = sh[0];
129
+ return src.map((v) => pruneAny(v, elemShape));
130
+ }
131
+
132
+ // Plain objects: keep only keys present on shape, recursively.
133
+ if (isPlainObject(sh)) {
134
+ const out: Record<string, unknown> = {};
135
+ const srcObj = isPlainObject(src) ? (src as Record<string, unknown>) : undefined;
136
+
137
+ for (const key of Object.keys(sh as Record<string, unknown>)) {
138
+ const shVal = (sh as Record<string, unknown>)[key];
139
+ const srcVal = srcObj ? srcObj[key] : undefined;
140
+
141
+ if (Array.isArray(shVal) || isPlainObject(shVal)) {
142
+ out[key] = pruneAny(srcVal, shVal);
143
+ } else {
144
+ // Primitive (or function/date/etc in shape): key exists => keep source value as-is
145
+ out[key] = srcVal;
146
+ }
147
+ }
148
+ return out;
149
+ }
150
+
151
+ // Non-object shape => allowed leaf; just return source leaf as-is.
152
+ return src;
153
+ }
154
+
155
+ function isPlainObject(v: unknown): v is Record<string, unknown> {
156
+ if (v === null || typeof v !== 'object') return false;
157
+ const proto = Object.getPrototypeOf(v);
158
+ return proto === Object.prototype || proto === null;
159
+ }
160
+ }
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { deepDiff, getByPath, setByPath } from './object.js';
2
+
3
+ import { deepDiff, getByPath, pruneToShape, setByPath } from './object.js';
3
4
 
4
5
  describe('deepDiff', () => {
5
6
  it('returns an empty object when values are deeply equal', () => {
@@ -58,3 +59,105 @@ describe('setByPath/getByPath', () => {
58
59
  expect(getByPath(target, 'rows.1.value')).toBeUndefined();
59
60
  });
60
61
  });
62
+
63
+ describe('pruneToShape', () => {
64
+ it('drops top-level keys not in shape', () => {
65
+ const source = { a: 1, b: 2, c: 3 };
66
+ const shape = { a: 0, c: 0 };
67
+ expect(pruneToShape(source, shape)).toEqual({ a: 1, c: 3 });
68
+ });
69
+
70
+ it('prunes deeply nested objects', () => {
71
+ const source = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 9 };
72
+ const shape = { a: { b: { c: 0 } } };
73
+ expect(pruneToShape(source, shape)).toEqual({ a: { b: { c: 1 } } });
74
+ });
75
+
76
+ it('keeps keys present in shape even if source value is undefined', () => {
77
+ const source = { a: 1 };
78
+ const shape = { a: 0, b: 0 };
79
+ expect(pruneToShape(source, shape)).toEqual({ a: 1, b: undefined });
80
+ });
81
+
82
+ it('arrays: prunes each element using first shape element', () => {
83
+ const source = {
84
+ items: [
85
+ { x: 1, y: 2, z: 3 },
86
+ { x: 4, y: 5, extra: true }
87
+ ],
88
+ extra: 'drop'
89
+ };
90
+ const shape = { items: [{ x: 0, y: 0 }] };
91
+
92
+ expect(pruneToShape(source, shape)).toEqual({
93
+ items: [
94
+ { x: 1, y: 2 },
95
+ { x: 4, y: 5 }
96
+ ]
97
+ });
98
+ });
99
+
100
+ it('arrays: empty shape array returns empty array (drops all elements)', () => {
101
+ const source = { items: [{ x: 1 }, { x: 2 }] };
102
+ const shape = { items: [] as unknown[] };
103
+ expect(pruneToShape(source, shape)).toEqual({ items: [] });
104
+ });
105
+
106
+ it('arrays: if source is not an array, returns empty array for that field', () => {
107
+ const source = { items: { x: 1 } as unknown };
108
+ const shape = { items: [{ x: 0 }] };
109
+ expect(pruneToShape(source, shape)).toEqual({ items: [] });
110
+ });
111
+
112
+ it('object expected but source has non-object: returns empty object of that shape', () => {
113
+ const source = { a: 123 as unknown };
114
+ const shape = { a: { b: 0, c: { d: 0 } } };
115
+ expect(pruneToShape(source, shape)).toEqual({ a: { b: undefined, c: { d: undefined } } });
116
+ });
117
+
118
+ it('keeps leaf values as-is (no coercion) when key exists in shape', () => {
119
+ const source = { a: '1', b: { c: '2' } };
120
+ const shape = { a: 0, b: { c: 0 } };
121
+ expect(pruneToShape(source, shape)).toEqual({ a: '1', b: { c: '2' } });
122
+ });
123
+
124
+ it('does not mutate source or shape', () => {
125
+ const source = { a: { b: 1, drop: 2 }, arr: [{ x: 1, y: 2 }] };
126
+ const shape = { a: { b: 0 }, arr: [{ x: 0 }] };
127
+
128
+ const sourceBefore = structuredClone(source);
129
+ const shapeBefore = structuredClone(shape);
130
+
131
+ pruneToShape(source, shape);
132
+
133
+ expect(source).toEqual(sourceBefore);
134
+ expect(shape).toEqual(shapeBefore);
135
+ });
136
+
137
+ it('treats non-plain objects in shape as leaf (e.g. Date)', () => {
138
+ const source = { a: { b: 1, c: 2 } };
139
+ const shape = { a: new Date(0) }; // leaf => keep source.a as-is (even though it's an object)
140
+ expect(pruneToShape(source, shape)).toEqual({ a: { b: 1, c: 2 } });
141
+ });
142
+
143
+ it('treats non-plain objects in source as incompatible when shape expects plain object', () => {
144
+ class Foo {
145
+ constructor(
146
+ public x: number,
147
+ public y: number
148
+ ) {}
149
+ }
150
+ const source = { a: new Foo(1, 2) as unknown };
151
+ const shape = { a: { x: 0 } };
152
+
153
+ // Foo isn't "plain", so it's treated as incompatible => build object using shape keys with undefined leaves
154
+ expect(pruneToShape(source, shape)).toEqual({ a: { x: undefined } });
155
+ });
156
+
157
+ it('handles mixed nesting of objects and arrays', () => {
158
+ const source = { a: [{ b: { c: 1, d: 2 }, drop: true }], dropTop: 1 };
159
+ const shape = { a: [{ b: { c: 0 } }] };
160
+
161
+ expect(pruneToShape(source, shape)).toEqual({ a: [{ b: { c: 1 } }] });
162
+ });
163
+ });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=deserializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deserializer.d.ts","sourceRoot":"","sources":["../../src/lambda/deserializer.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- export {};
2
- // async function deserialize(data: string, env: string | 'production'): Promise<any> {
3
- // if (env === 'production') {
4
- // const { parse: prodParse } = await import('@ungap/structured-clone/json');
5
- // return prodParse(data);
6
- // } else {
7
- // const cycle = await import('cycle');
8
- // return JSON.parse(cycle.default.retrocycle(data));
9
- // }
10
- // }
11
- //
12
- // export { deserialize };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=serializer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializer.d.ts","sourceRoot":"","sources":["../../src/lambda/serializer.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- export {};
2
- // /**
3
- // * Turns object into string.
4
- // *
5
- // * Uses different methods in production and otherwise for more readable output
6
- // */
7
- // export async function stringify(data: any) {
8
- // if (process.env.PUBLIC_ENVIRONMENT === 'production') {
9
- // const { stringify: prodStrigify } = await import('@ungap/structured-clone/json');
10
- // return prodStrigify(data);
11
- // } else {
12
- // const { decycle } = (await import('cycle')).default;
13
- // return JSON.stringify(decycle(data), null);
14
- // }
15
- // }
@@ -1,11 +0,0 @@
1
- // async function deserialize(data: string, env: string | 'production'): Promise<any> {
2
- // if (env === 'production') {
3
- // const { parse: prodParse } = await import('@ungap/structured-clone/json');
4
- // return prodParse(data);
5
- // } else {
6
- // const cycle = await import('cycle');
7
- // return JSON.parse(cycle.default.retrocycle(data));
8
- // }
9
- // }
10
- //
11
- // export { deserialize };
@@ -1,14 +0,0 @@
1
- // /**
2
- // * Turns object into string.
3
- // *
4
- // * Uses different methods in production and otherwise for more readable output
5
- // */
6
- // export async function stringify(data: any) {
7
- // if (process.env.PUBLIC_ENVIRONMENT === 'production') {
8
- // const { stringify: prodStrigify } = await import('@ungap/structured-clone/json');
9
- // return prodStrigify(data);
10
- // } else {
11
- // const { decycle } = (await import('cycle')).default;
12
- // return JSON.stringify(decycle(data), null);
13
- // }
14
- // }