@gahojin-inc/middy-appsync 2026.4.0 → 2026.5.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,23 +1,19 @@
1
- import middy from "@middy/core";
2
- import { AppSyncResolverEvent } from "aws-lambda";
3
-
4
- //#region src/index.d.ts
5
- declare class AppSyncError extends Error {
6
- readonly type: string;
7
- constructor(message: string, type?: string);
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);
8
6
  }
9
- type AppSyncBatchResponse<TData = any> = {
10
- data?: TData | null;
11
- errorMessage?: string;
12
- errorType?: string;
7
+ export type AppSyncBatchResponse<TData = any> = {
8
+ data?: TData | null;
9
+ errorMessage?: string;
10
+ errorType?: string;
13
11
  };
14
- type AppSyncResolverEvents<TArguments, TSource = Record<string, any> | null> = AppSyncResolverEvent<TArguments, TSource> | AppSyncResolverEvent<TArguments, TSource>[];
15
- type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined;
16
- type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
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>;
17
15
  type Options<TData = any> = {
18
- buildResponse?: BuildResponseFn<TData>;
16
+ buildResponse?: BuildResponseFn<TData>;
19
17
  };
20
18
  declare const _default: <TArguments = any, TData = any, TSource = Record<string, any> | null>(opts?: Options<TData>) => middy.MiddlewareObj<AppSyncResolverEvents<TArguments, TSource>, AppSyncResponse<TData>>;
21
- //#endregion
22
- export { AppSyncBatchResponse, AppSyncError, AppSyncResolverEvents, AppSyncResponse, BuildResponseFn, _default as default };
23
- //# sourceMappingURL=index.d.ts.map
19
+ export default _default;
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var AppSyncError = class extends Error {
6
6
  this.type = type;
7
7
  }
8
8
  };
9
- const defaultBuildResponse = (response, batchInvoke) => {
9
+ var 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,MAAM,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,WADI,IAAI,MAAM,MAAM,OAAO,CACZ,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;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gahojin-inc/middy-appsync",
3
- "version": "2026.4.0",
3
+ "version": "2026.5.0",
4
4
  "description": "Middy appsync",
5
5
  "author": "GAHOJIN, Inc.",
6
6
  "license": "Apache-2.0",
@@ -37,15 +37,15 @@
37
37
  }
38
38
  },
39
39
  "devDependencies": {
40
- "@gahojin-inc/aws-lambda-mock-context": "2026.2.0",
41
- "@middy/core": "7.2.1",
40
+ "@gahojin-inc/aws-lambda-mock-context": "2026.4.0",
41
+ "@middy/core": "7.3.3",
42
42
  "@types/aws-lambda": "8.10.161"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@middy/core": "^5 || ^6 || ^7"
46
46
  },
47
47
  "scripts": {
48
- "build": "rolldown -c",
48
+ "build": "vite build",
49
49
  "lint": "biome check --write .",
50
50
  "lint:ci": "biome ci .",
51
51
  "check": "tsc --noEmit",