@gahojin-inc/middy-appsync 2026.5.1 → 2026.7.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.
package/dist/index.d.ts CHANGED
@@ -1,19 +1,22 @@
1
- import { default as middy } from '@middy/core';
2
- import { AppSyncResolverEvent } from 'aws-lambda';
3
- export declare class AppSyncError extends Error {
4
- readonly type: string;
5
- constructor(message: string, type?: string);
1
+ import middy from "@middy/core";
2
+ import { AppSyncResolverEvent } from "aws-lambda";
3
+ //#region src/index.d.ts
4
+ declare class AppSyncError extends Error {
5
+ readonly type: string;
6
+ constructor(message: string, type?: string);
6
7
  }
7
- export type AppSyncBatchResponse<TData = any> = {
8
- data?: TData | null;
9
- errorMessage?: string;
10
- errorType?: string;
8
+ type AppSyncBatchResponse<TData = any> = {
9
+ data?: TData | null;
10
+ errorMessage?: string;
11
+ errorType?: string;
11
12
  };
12
- export type AppSyncResolverEvents<TArguments, TSource = Record<string, any> | null> = AppSyncResolverEvent<TArguments, TSource> | AppSyncResolverEvent<TArguments, TSource>[];
13
- export type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined;
14
- export type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
13
+ type AppSyncResolverEvents<TArguments, TSource = Record<string, any> | null> = AppSyncResolverEvent<TArguments, TSource> | AppSyncResolverEvent<TArguments, TSource>[];
14
+ type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined;
15
+ type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
15
16
  type Options<TData = any> = {
16
- buildResponse?: BuildResponseFn<TData>;
17
+ buildResponse?: BuildResponseFn<TData>;
17
18
  };
18
19
  declare const _default: <TArguments = any, TData = any, TSource = Record<string, any> | null>(opts?: Options<TData>) => middy.MiddlewareObj<AppSyncResolverEvents<TArguments, TSource>, AppSyncResponse<TData>>;
19
- export default _default;
20
+ //#endregion
21
+ export { AppSyncBatchResponse, AppSyncError, AppSyncResolverEvents, AppSyncResponse, BuildResponseFn, _default as default };
22
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var AppSyncError = class extends Error {
6
6
  this.type = type;
7
7
  }
8
8
  };
9
- var defaultBuildResponse = (response, batchInvoke) => {
9
+ const defaultBuildResponse = (response, batchInvoke) => {
10
10
  if (batchInvoke) {
11
11
  if (response instanceof AppSyncError) return {
12
12
  errorMessage: response.message,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type middy from '@middy/core'\nimport type { AppSyncResolverEvent } from 'aws-lambda'\n\nexport class AppSyncError extends Error {\n readonly type: string\n\n constructor(message: string, type = 'UnknownError') {\n super(message)\n this.type = type\n }\n}\n\nexport type AppSyncBatchResponse<TData = any> = {\n data?: TData | null\n errorMessage?: string\n errorType?: string\n}\n\nexport type AppSyncResolverEvents<TArguments, TSource = Record<string, any> | null> =\n | AppSyncResolverEvent<TArguments, TSource>\n | AppSyncResolverEvent<TArguments, TSource>[]\n\nexport type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined\n\nexport type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>\n\ntype Options<TData = any> = {\n buildResponse?: BuildResponseFn<TData>\n}\n\nconst defaultBuildResponse = <TData>(response: TData | Error | null | undefined, batchInvoke: boolean): AppSyncResponse<TData> => {\n if (batchInvoke) {\n if (response instanceof AppSyncError) {\n return {\n errorMessage: response.message,\n errorType: response.type,\n }\n }\n if (response instanceof Error) {\n return {\n errorMessage: response.message,\n }\n }\n return {\n data: response,\n }\n }\n return response\n}\n\nexport default <TArguments = any, TData = any, TSource = Record<string, any> | null>(\n opts: Options<TData> = {},\n): middy.MiddlewareObj<AppSyncResolverEvents<TArguments, TSource>, AppSyncResponse<TData>> => {\n const buildResponse: BuildResponseFn<TData> = opts.buildResponse ?? defaultBuildResponse\n\n const afterFn: middy.MiddlewareFn = (request) => {\n const { event, response } = request\n\n if (Array.isArray(event)) {\n // for BatchInvoke\n if (!Array.isArray(response) || event.length !== response.length) {\n throw new Error('BatchInvoke: The response does not match the request payload')\n }\n request.response = response.map((r) => buildResponse(r, true))\n } else {\n const resp = buildResponse(response, false)\n if (resp instanceof Error) {\n throw resp\n }\n request.response = resp\n }\n }\n\n const onErrorFn: middy.MiddlewareFn = (request) => {\n const { event, error, response } = request\n\n if (response !== undefined) {\n return\n }\n\n const isBatchInvoke = Array.isArray(event)\n const resp = buildResponse(error, isBatchInvoke)\n if (isBatchInvoke) {\n // 全てエラー扱いにする\n const tmp = new Array(event.length)\n request.response = tmp.fill(resp)\n } else if (!(resp instanceof Error)) {\n request.response = resp\n }\n }\n\n return {\n after: afterFn,\n onError: onErrorFn,\n }\n}\n"],"mappings":";AAGA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,SAAiB,OAAO,gBAAgB;AAClD,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAsBhB,IAAM,wBAA+B,UAA4C,gBAAiD;AAChI,KAAI,aAAa;AACf,MAAI,oBAAoB,aACtB,QAAO;GACL,cAAc,SAAS;GACvB,WAAW,SAAS;GACrB;AAEH,MAAI,oBAAoB,MACtB,QAAO,EACL,cAAc,SAAS,SACxB;AAEH,SAAO,EACL,MAAM,UACP;;AAEH,QAAO;;AAGT,IAAA,eACE,OAAuB,EAAE,KACmE;CAC5F,MAAM,gBAAwC,KAAK,iBAAiB;CAEpE,MAAM,WAA+B,YAAY;EAC/C,MAAM,EAAE,OAAO,aAAa;AAE5B,MAAI,MAAM,QAAQ,MAAM,EAAE;AAExB,OAAI,CAAC,MAAM,QAAQ,SAAS,IAAI,MAAM,WAAW,SAAS,OACxD,OAAM,IAAI,MAAM,+DAA+D;AAEjF,WAAQ,WAAW,SAAS,KAAK,MAAM,cAAc,GAAG,KAAK,CAAC;SACzD;GACL,MAAM,OAAO,cAAc,UAAU,MAAM;AAC3C,OAAI,gBAAgB,MAClB,OAAM;AAER,WAAQ,WAAW;;;CAIvB,MAAM,aAAiC,YAAY;EACjD,MAAM,EAAE,OAAO,OAAO,aAAa;AAEnC,MAAI,aAAa,KAAA,EACf;EAGF,MAAM,gBAAgB,MAAM,QAAQ,MAAM;EAC1C,MAAM,OAAO,cAAc,OAAO,cAAc;AAChD,MAAI,cAGF,SAAQ,WAAW,IADH,MAAM,MAAM,OACT,CAAI,KAAK,KAAK;WACxB,EAAE,gBAAgB,OAC3B,SAAQ,WAAW;;AAIvB,QAAO;EACL,OAAO;EACP,SAAS;EACV"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type middy from '@middy/core'\nimport type { AppSyncResolverEvent } from 'aws-lambda'\n\nexport class AppSyncError extends Error {\n readonly type: string\n\n constructor(message: string, type = 'UnknownError') {\n super(message)\n this.type = type\n }\n}\n\nexport type AppSyncBatchResponse<TData = any> = {\n data?: TData | null\n errorMessage?: string\n errorType?: string\n}\n\nexport type AppSyncResolverEvents<TArguments, TSource = Record<string, any> | null> =\n | AppSyncResolverEvent<TArguments, TSource>\n | AppSyncResolverEvent<TArguments, TSource>[]\n\nexport type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined\n\nexport type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>\n\ntype Options<TData = any> = {\n buildResponse?: BuildResponseFn<TData>\n}\n\nconst defaultBuildResponse = <TData>(response: TData | Error | null | undefined, batchInvoke: boolean): AppSyncResponse<TData> => {\n if (batchInvoke) {\n if (response instanceof AppSyncError) {\n return {\n errorMessage: response.message,\n errorType: response.type,\n }\n }\n if (response instanceof Error) {\n return {\n errorMessage: response.message,\n }\n }\n return {\n data: response,\n }\n }\n return response\n}\n\nexport default <TArguments = any, TData = any, TSource = Record<string, any> | null>(\n opts: Options<TData> = {},\n): middy.MiddlewareObj<AppSyncResolverEvents<TArguments, TSource>, AppSyncResponse<TData>> => {\n const buildResponse: BuildResponseFn<TData> = opts.buildResponse ?? defaultBuildResponse\n\n const afterFn: middy.MiddlewareFn = (request) => {\n const { event, response } = request\n\n if (Array.isArray(event)) {\n // for BatchInvoke\n if (!Array.isArray(response) || event.length !== response.length) {\n throw new Error('BatchInvoke: The response does not match the request payload')\n }\n request.response = response.map((r) => buildResponse(r, true))\n } else {\n const resp = buildResponse(response, false)\n if (resp instanceof Error) {\n throw resp\n }\n request.response = resp\n }\n }\n\n const onErrorFn: middy.MiddlewareFn = (request) => {\n const { event, error, response } = request\n\n if (response !== undefined) {\n return\n }\n\n const isBatchInvoke = Array.isArray(event)\n const resp = buildResponse(error, isBatchInvoke)\n if (isBatchInvoke) {\n // 全てエラー扱いにする\n const tmp = new Array(event.length)\n request.response = tmp.fill(resp)\n } else if (!(resp instanceof Error)) {\n request.response = resp\n }\n }\n\n return {\n after: afterFn,\n onError: onErrorFn,\n }\n}\n"],"mappings":";AAGA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,SAAiB,OAAO,gBAAgB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAoBA,MAAM,wBAA+B,UAA4C,gBAAiD;CAChI,IAAI,aAAa;EACf,IAAI,oBAAoB,cACtB,OAAO;GACL,cAAc,SAAS;GACvB,WAAW,SAAS;EACtB;EAEF,IAAI,oBAAoB,OACtB,OAAO,EACL,cAAc,SAAS,QACzB;EAEF,OAAO,EACL,MAAM,SACR;CACF;CACA,OAAO;AACT;AAEA,IAAA,eACE,OAAuB,CAAC,MACoE;CAC5F,MAAM,gBAAwC,KAAK,iBAAiB;CAEpE,MAAM,WAA+B,YAAY;EAC/C,MAAM,EAAE,OAAO,aAAa;EAE5B,IAAI,MAAM,QAAQ,KAAK,GAAG;GAExB,IAAI,CAAC,MAAM,QAAQ,QAAQ,KAAK,MAAM,WAAW,SAAS,QACxD,MAAM,IAAI,MAAM,8DAA8D;GAEhF,QAAQ,WAAW,SAAS,KAAK,MAAM,cAAc,GAAG,IAAI,CAAC;EAC/D,OAAO;GACL,MAAM,OAAO,cAAc,UAAU,KAAK;GAC1C,IAAI,gBAAgB,OAClB,MAAM;GAER,QAAQ,WAAW;EACrB;CACF;CAEA,MAAM,aAAiC,YAAY;EACjD,MAAM,EAAE,OAAO,OAAO,aAAa;EAEnC,IAAI,aAAa,KAAA,GACf;EAGF,MAAM,gBAAgB,MAAM,QAAQ,KAAK;EACzC,MAAM,OAAO,cAAc,OAAO,aAAa;EAC/C,IAAI,eAGF,QAAQ,WAAW,IADH,MAAM,MAAM,MACP,CAAC,CAAC,KAAK,IAAI;OAC3B,IAAI,EAAE,gBAAgB,QAC3B,QAAQ,WAAW;CAEvB;CAEA,OAAO;EACL,OAAO;EACP,SAAS;CACX;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gahojin-inc/middy-appsync",
3
- "version": "2026.5.1",
3
+ "version": "2026.7.0",
4
4
  "description": "Middy appsync",
5
5
  "author": "GAHOJIN, Inc.",
6
6
  "license": "Apache-2.0",
@@ -37,19 +37,18 @@
37
37
  }
38
38
  },
39
39
  "devDependencies": {
40
- "@gahojin-inc/aws-lambda-mock-context": "2026.4.0",
41
- "@middy/core": "7.4.0",
42
- "@types/aws-lambda": "8.10.161"
40
+ "@gahojin-inc/aws-lambda-mock-context": "2026.5.1",
41
+ "@middy/core": "7.7.0",
42
+ "@types/aws-lambda": "8.10.162"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@middy/core": "^5 || ^6 || ^7"
46
46
  },
47
47
  "scripts": {
48
- "build": "vite build",
48
+ "build": "rolldown -c",
49
49
  "lint": "biome check --write .",
50
50
  "lint:ci": "biome ci .",
51
51
  "check": "tsc --noEmit",
52
- "check:packagejson": "attw --pack --profile esm-only .",
53
52
  "test": "vitest --watch",
54
53
  "test:unit": "vitest --passWithNoTests --run --coverage"
55
54
  }