@gahojin-inc/middy-appsync 2026.3.0 → 2026.3.2
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.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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\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 | undefined\n\nexport type BuildResponseFn<TData = any> = (response: TData | Error | undefined, batchInvoke: boolean) => AppSyncResponse<TData>\n\ntype Options<TData = any> = {\n buildResponse?: BuildResponseFn<TData>\n}\n\nconst defaultBuildResponse = <TData>(response: TData | Error | 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,
|
|
1
|
+
{"version":3,"file":"index.cjs","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"}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class AppSyncError extends Error {
|
|
|
5
5
|
constructor(message: string, type?: string);
|
|
6
6
|
}
|
|
7
7
|
export type AppSyncBatchResponse<TData = any> = {
|
|
8
|
-
data?: TData;
|
|
8
|
+
data?: TData | null;
|
|
9
9
|
errorMessage?: string;
|
|
10
10
|
errorType?: string;
|
|
11
11
|
};
|
|
@@ -13,8 +13,8 @@ export type AppSyncResolverEvents<
|
|
|
13
13
|
TArguments,
|
|
14
14
|
TSource = Record<string, any> | null
|
|
15
15
|
> = AppSyncResolverEvent<TArguments, TSource> | AppSyncResolverEvent<TArguments, TSource>[];
|
|
16
|
-
export type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | undefined;
|
|
17
|
-
export type BuildResponseFn<TData = any> = (response: TData | Error | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
|
|
16
|
+
export type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined;
|
|
17
|
+
export type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
|
|
18
18
|
type Options<TData = any> = {
|
|
19
19
|
buildResponse?: BuildResponseFn<TData>;
|
|
20
20
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class AppSyncError extends Error {
|
|
|
5
5
|
constructor(message: string, type?: string);
|
|
6
6
|
}
|
|
7
7
|
export type AppSyncBatchResponse<TData = any> = {
|
|
8
|
-
data?: TData;
|
|
8
|
+
data?: TData | null;
|
|
9
9
|
errorMessage?: string;
|
|
10
10
|
errorType?: string;
|
|
11
11
|
};
|
|
@@ -13,8 +13,8 @@ export type AppSyncResolverEvents<
|
|
|
13
13
|
TArguments,
|
|
14
14
|
TSource = Record<string, any> | null
|
|
15
15
|
> = AppSyncResolverEvent<TArguments, TSource> | AppSyncResolverEvent<TArguments, TSource>[];
|
|
16
|
-
export type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | undefined;
|
|
17
|
-
export type BuildResponseFn<TData = any> = (response: TData | Error | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
|
|
16
|
+
export type AppSyncResponse<TData> = AppSyncBatchResponse<TData> | TData | Error | null | undefined;
|
|
17
|
+
export type BuildResponseFn<TData = any> = (response: TData | Error | null | undefined, batchInvoke: boolean) => AppSyncResponse<TData>;
|
|
18
18
|
type Options<TData = any> = {
|
|
19
19
|
buildResponse?: BuildResponseFn<TData>;
|
|
20
20
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","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\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 | undefined\n\nexport type BuildResponseFn<TData = any> = (response: TData | Error | undefined, batchInvoke: boolean) => AppSyncResponse<TData>\n\ntype Options<TData = any> = {\n buildResponse?: BuildResponseFn<TData>\n}\n\nconst defaultBuildResponse = <TData>(response: TData | Error | 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,
|
|
1
|
+
{"version":3,"file":"index.mjs","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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gahojin-inc/middy-appsync",
|
|
3
|
-
"version": "2026.3.
|
|
3
|
+
"version": "2026.3.2",
|
|
4
4
|
"description": "Middy appsync",
|
|
5
5
|
"author": "GAHOJIN, Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@gahojin-inc/aws-lambda-mock-context": "2026.2.0",
|
|
45
|
-
"@middy/core": "7.1.
|
|
45
|
+
"@middy/core": "7.1.7",
|
|
46
46
|
"@types/aws-lambda": "8.10.161"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|