@adobe/aio-commerce-lib-core 0.6.0 → 0.6.1
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/CHANGELOG.md +10 -0
- package/dist/cjs/headers/index.d.cts +1 -1
- package/dist/cjs/{index-DmOFyyVg.d.cts → index-2lCdMqhT.d.cts} +18 -2
- package/dist/cjs/params/index.d.cts +2 -2
- package/dist/cjs/responses/index.cjs +1 -1
- package/dist/cjs/responses/index.d.cts +35 -2
- package/dist/es/headers/index.d.mts +1 -1
- package/dist/es/{index-D8edNAiU.d.mts → index-CPYhPt8X.d.mts} +18 -2
- package/dist/es/params/index.d.mts +2 -2
- package/dist/es/responses/index.d.mts +35 -2
- package/dist/es/responses/index.mjs +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @adobe/aio-commerce-lib-core
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#246](https://github.com/adobe/aio-commerce-sdk/pull/246) [`b3b41f5`](https://github.com/adobe/aio-commerce-sdk/commit/b3b41f576cf0341bbb4a19bb534bfe35fb562aad) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Add new `noContent` and `conflict` response presets
|
|
8
|
+
|
|
9
|
+
- [#246](https://github.com/adobe/aio-commerce-sdk/pull/246) [`b3b41f5`](https://github.com/adobe/aio-commerce-sdk/commit/b3b41f576cf0341bbb4a19bb534bfe35fb562aad) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Split generics on `ActionResponse` type for appropriate inference
|
|
10
|
+
|
|
11
|
+
- [#245](https://github.com/adobe/aio-commerce-sdk/pull/245) [`b7fb4da`](https://github.com/adobe/aio-commerce-sdk/commit/b7fb4da5b8a9f468d4c33a25194dcc0a6e4d16a1) Thanks [@iivvaannxx](https://github.com/iivvaannxx)! - Enhance core type definitions.
|
|
12
|
+
|
|
3
13
|
## 0.6.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -15,13 +15,29 @@ declare function nonEmpty(name: string, value: unknown): boolean;
|
|
|
15
15
|
declare function allNonEmpty<const T extends string[]>(params: Record<string, unknown>, required: T): params is Record<string, unknown> & Record<T[number], unknown>;
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region source/params/types.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Standard HTTP methods supported by Adobe I/O Runtime.
|
|
20
|
+
* These are the methods that can be used when invoking runtime actions via HTTP.
|
|
21
|
+
*/
|
|
22
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
23
|
+
/**
|
|
24
|
+
* Lowercase HTTP method as sent by OpenWhisk/Adobe I/O Runtime.
|
|
25
|
+
* OpenWhisk sends methods in lowercase (e.g., "get", "post").
|
|
26
|
+
*/
|
|
27
|
+
type HttpMethodLowercase = Lowercase<HttpMethod>;
|
|
18
28
|
/** The type of the runtime action parameters. */
|
|
19
29
|
type RuntimeActionParams = {
|
|
20
30
|
/** If the runtime action is invoked via HTTP, this will be the headers of the request. */
|
|
21
31
|
__ow_headers?: Record<string, string | undefined>;
|
|
22
32
|
/** If the runtime action is invoked via HTTP, this will be the HTTP method of the request. */
|
|
23
|
-
__ow_method?:
|
|
33
|
+
__ow_method?: HttpMethodLowercase;
|
|
34
|
+
/** If the runtime action is invoked via HTTP, this will be the unmatched path of the request (matching stops after consuming the action extension) */
|
|
35
|
+
__ow_path?: string;
|
|
36
|
+
/** If the runtime action is invoked via HTTP, this will be the request body entity, as a base64-encoded string when its content is binary or JSON object/array, or as a plain string otherwise */
|
|
37
|
+
__ow_body?: string;
|
|
38
|
+
/** If the runtime action is invoked via HTTP, this will be the query parameters of the request, as an unparsed string. */
|
|
39
|
+
__ow_query?: string;
|
|
24
40
|
[key: string]: unknown;
|
|
25
41
|
};
|
|
26
42
|
//#endregion
|
|
27
|
-
export { allNonEmpty as n,
|
|
43
|
+
export { nonEmpty as a, allNonEmpty as i, HttpMethodLowercase as n, RuntimeActionParams as r, HttpMethod as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { RuntimeActionParams, allNonEmpty, nonEmpty };
|
|
1
|
+
import { a as nonEmpty, i as allNonEmpty, n as HttpMethodLowercase, r as RuntimeActionParams, t as HttpMethod } from "../index-2lCdMqhT.cjs";
|
|
2
|
+
export { HttpMethod, HttpMethodLowercase, RuntimeActionParams, allNonEmpty, nonEmpty };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function buildErrorResponse(statusCode,payload){return{type:`error`,error:{...payload?.headers&&{headers:payload.headers},statusCode,body:payload.body}}}function buildSuccessResponse(statusCode,payload){return{type:`success`,statusCode,...payload?.headers&&{headers:payload.headers},...payload?.body&&{body:payload.body}}}const HTTP_OK=200,HTTP_CREATED=201,HTTP_NON_AUTHORITATIVE_INFORMATION=203,HTTP_BAD_REQUEST=400,HTTP_UNAUTHORIZED=401,HTTP_FORBIDDEN=403,HTTP_NOT_FOUND=404,HTTP_INTERNAL_SERVER_ERROR=500;function curryBuildSuccessResponse(code){return payload=>buildSuccessResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}function curryBuildErrorResponse(code){return payload=>buildErrorResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}const ok=curryBuildSuccessResponse(200),created=curryBuildSuccessResponse(201),nonAuthoritativeInformation=curryBuildSuccessResponse(203),badRequest=curryBuildErrorResponse(400),unauthorized=curryBuildErrorResponse(401),forbidden=curryBuildErrorResponse(403),notFound=curryBuildErrorResponse(404),internalServerError=curryBuildErrorResponse(500);exports.HTTP_BAD_REQUEST=400,exports.HTTP_CREATED=201,exports.HTTP_FORBIDDEN=403,exports.HTTP_INTERNAL_SERVER_ERROR=500,exports.HTTP_NON_AUTHORITATIVE_INFORMATION=203,exports.HTTP_NOT_FOUND=404,exports.HTTP_OK=200,exports.HTTP_UNAUTHORIZED=401,exports.badRequest=badRequest,exports.buildErrorResponse=buildErrorResponse,exports.buildSuccessResponse=buildSuccessResponse,exports.created=created,exports.forbidden=forbidden,exports.internalServerError=internalServerError,exports.nonAuthoritativeInformation=nonAuthoritativeInformation,exports.notFound=notFound,exports.ok=ok,exports.unauthorized=unauthorized;
|
|
1
|
+
function buildErrorResponse(statusCode,payload){return{type:`error`,error:{...payload?.headers&&{headers:payload.headers},statusCode,body:payload.body}}}function buildSuccessResponse(statusCode,payload){return{type:`success`,statusCode,...payload?.headers&&{headers:payload.headers},...payload?.body&&{body:payload.body}}}const HTTP_OK=200,HTTP_CREATED=201,HTTP_ACCEPTED=202,HTTP_NON_AUTHORITATIVE_INFORMATION=203,HTTP_NO_CONTENT=204,HTTP_BAD_REQUEST=400,HTTP_UNAUTHORIZED=401,HTTP_FORBIDDEN=403,HTTP_NOT_FOUND=404,HTTP_METHOD_NOT_ALLOWED=405,HTTP_CONFLICT=409,HTTP_INTERNAL_SERVER_ERROR=500;function curryBuildSuccessResponse(code){return payload=>buildSuccessResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}function curryBuildErrorResponse(code){return payload=>buildErrorResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}const ok=curryBuildSuccessResponse(200),created=curryBuildSuccessResponse(201),accepted=curryBuildSuccessResponse(202),nonAuthoritativeInformation=curryBuildSuccessResponse(203),noContent=()=>buildSuccessResponse(204),badRequest=curryBuildErrorResponse(400),unauthorized=curryBuildErrorResponse(401),forbidden=curryBuildErrorResponse(403),notFound=curryBuildErrorResponse(404),methodNotAllowed=curryBuildErrorResponse(405),conflict=curryBuildErrorResponse(409),internalServerError=curryBuildErrorResponse(500);exports.HTTP_ACCEPTED=202,exports.HTTP_BAD_REQUEST=400,exports.HTTP_CONFLICT=409,exports.HTTP_CREATED=201,exports.HTTP_FORBIDDEN=403,exports.HTTP_INTERNAL_SERVER_ERROR=500,exports.HTTP_METHOD_NOT_ALLOWED=405,exports.HTTP_NON_AUTHORITATIVE_INFORMATION=203,exports.HTTP_NOT_FOUND=404,exports.HTTP_NO_CONTENT=204,exports.HTTP_OK=200,exports.HTTP_UNAUTHORIZED=401,exports.accepted=accepted,exports.badRequest=badRequest,exports.buildErrorResponse=buildErrorResponse,exports.buildSuccessResponse=buildSuccessResponse,exports.conflict=conflict,exports.created=created,exports.forbidden=forbidden,exports.internalServerError=internalServerError,exports.methodNotAllowed=methodNotAllowed,exports.noContent=noContent,exports.nonAuthoritativeInformation=nonAuthoritativeInformation,exports.notFound=notFound,exports.ok=ok,exports.unauthorized=unauthorized;
|
|
@@ -36,7 +36,7 @@ type SuccessResponse<TBody extends BodyRecord = BodyRecord, THeaders extends Hea
|
|
|
36
36
|
* @template TBody - Response/error body properties
|
|
37
37
|
* @template THeaders - Custom response headers
|
|
38
38
|
*/
|
|
39
|
-
type ActionResponse<
|
|
39
|
+
type ActionResponse<TSuccessBody extends BodyRecord = BodyRecord, TErrorBody extends BodyRecordWithMessage = BodyRecordWithMessage, THeaders extends HeadersRecord = HeadersRecord> = SuccessResponse<TSuccessBody, THeaders> | ErrorResponse<TErrorBody, THeaders>;
|
|
40
40
|
/**
|
|
41
41
|
* Creates a standardized error response for runtime actions
|
|
42
42
|
* @see https://developer.adobe.com/app-builder/docs/guides/runtime_guides/creating-actions#unsuccessful-response
|
|
@@ -114,11 +114,15 @@ declare function buildSuccessResponse<TBody extends BodyRecord = BodyRecord, THe
|
|
|
114
114
|
//#region source/responses/presets.d.ts
|
|
115
115
|
declare const HTTP_OK = 200;
|
|
116
116
|
declare const HTTP_CREATED = 201;
|
|
117
|
+
declare const HTTP_ACCEPTED = 202;
|
|
117
118
|
declare const HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
|
|
119
|
+
declare const HTTP_NO_CONTENT = 204;
|
|
118
120
|
declare const HTTP_BAD_REQUEST = 400;
|
|
119
121
|
declare const HTTP_UNAUTHORIZED = 401;
|
|
120
122
|
declare const HTTP_FORBIDDEN = 403;
|
|
121
123
|
declare const HTTP_NOT_FOUND = 404;
|
|
124
|
+
declare const HTTP_METHOD_NOT_ALLOWED = 405;
|
|
125
|
+
declare const HTTP_CONFLICT = 409;
|
|
122
126
|
declare const HTTP_INTERNAL_SERVER_ERROR = 500;
|
|
123
127
|
/**
|
|
124
128
|
* Creates a success response with the HTTP status code 200.
|
|
@@ -136,6 +140,14 @@ declare const created: (payload?: string | {
|
|
|
136
140
|
body?: BodyRecord;
|
|
137
141
|
headers?: HeadersRecord;
|
|
138
142
|
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
143
|
+
/**
|
|
144
|
+
* Creates a success response with the HTTP status code 202.
|
|
145
|
+
* See {@link buildSuccessResponse} for details on the response payload.
|
|
146
|
+
*/
|
|
147
|
+
declare const accepted: (payload?: string | {
|
|
148
|
+
body?: BodyRecord;
|
|
149
|
+
headers?: HeadersRecord;
|
|
150
|
+
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
139
151
|
/**
|
|
140
152
|
* Creates a success response with the HTTP status code 203.
|
|
141
153
|
* See {@link buildSuccessResponse} for details on the response payload.
|
|
@@ -144,6 +156,11 @@ declare const nonAuthoritativeInformation: (payload?: string | {
|
|
|
144
156
|
body?: BodyRecord;
|
|
145
157
|
headers?: HeadersRecord;
|
|
146
158
|
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a success response with the HTTP status code 204 (No Content).
|
|
161
|
+
* This response has no body.
|
|
162
|
+
*/
|
|
163
|
+
declare const noContent: () => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
147
164
|
/**
|
|
148
165
|
* Creates an error response with the HTTP status code 400.
|
|
149
166
|
* See {@link buildErrorResponse} for details on the response payload.
|
|
@@ -176,6 +193,22 @@ declare const notFound: (payload: string | {
|
|
|
176
193
|
body: BodyRecordWithMessage;
|
|
177
194
|
headers?: HeadersRecord;
|
|
178
195
|
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
196
|
+
/**
|
|
197
|
+
* Creates an error response with the HTTP status code 405.
|
|
198
|
+
* See {@link buildErrorResponse} for details on the response payload.
|
|
199
|
+
*/
|
|
200
|
+
declare const methodNotAllowed: (payload: string | {
|
|
201
|
+
body: BodyRecordWithMessage;
|
|
202
|
+
headers?: HeadersRecord;
|
|
203
|
+
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
204
|
+
/**
|
|
205
|
+
* Creates an error response with the HTTP status code 409.
|
|
206
|
+
* See {@link buildErrorResponse} for details on the response payload.
|
|
207
|
+
*/
|
|
208
|
+
declare const conflict: (payload: string | {
|
|
209
|
+
body: BodyRecordWithMessage;
|
|
210
|
+
headers?: HeadersRecord;
|
|
211
|
+
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
179
212
|
/**
|
|
180
213
|
* Creates an error response with the HTTP status code 500.
|
|
181
214
|
* See {@link buildErrorResponse} for details on the response payload.
|
|
@@ -185,4 +218,4 @@ declare const internalServerError: (payload: string | {
|
|
|
185
218
|
headers?: HeadersRecord;
|
|
186
219
|
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
187
220
|
//#endregion
|
|
188
|
-
export { type ActionResponse, type ErrorResponse, HTTP_BAD_REQUEST, HTTP_CREATED, HTTP_FORBIDDEN, HTTP_INTERNAL_SERVER_ERROR, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_FOUND, HTTP_OK, HTTP_UNAUTHORIZED, type SuccessResponse, badRequest, buildErrorResponse, buildSuccessResponse, created, forbidden, internalServerError, nonAuthoritativeInformation, notFound, ok, unauthorized };
|
|
221
|
+
export { type ActionResponse, type ErrorResponse, HTTP_ACCEPTED, HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_CREATED, HTTP_FORBIDDEN, HTTP_INTERNAL_SERVER_ERROR, HTTP_METHOD_NOT_ALLOWED, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_FOUND, HTTP_NO_CONTENT, HTTP_OK, HTTP_UNAUTHORIZED, type SuccessResponse, accepted, badRequest, buildErrorResponse, buildSuccessResponse, conflict, created, forbidden, internalServerError, methodNotAllowed, noContent, nonAuthoritativeInformation, notFound, ok, unauthorized };
|
|
@@ -15,13 +15,29 @@ declare function nonEmpty(name: string, value: unknown): boolean;
|
|
|
15
15
|
declare function allNonEmpty<const T extends string[]>(params: Record<string, unknown>, required: T): params is Record<string, unknown> & Record<T[number], unknown>;
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region source/params/types.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Standard HTTP methods supported by Adobe I/O Runtime.
|
|
20
|
+
* These are the methods that can be used when invoking runtime actions via HTTP.
|
|
21
|
+
*/
|
|
22
|
+
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
23
|
+
/**
|
|
24
|
+
* Lowercase HTTP method as sent by OpenWhisk/Adobe I/O Runtime.
|
|
25
|
+
* OpenWhisk sends methods in lowercase (e.g., "get", "post").
|
|
26
|
+
*/
|
|
27
|
+
type HttpMethodLowercase = Lowercase<HttpMethod>;
|
|
18
28
|
/** The type of the runtime action parameters. */
|
|
19
29
|
type RuntimeActionParams = {
|
|
20
30
|
/** If the runtime action is invoked via HTTP, this will be the headers of the request. */
|
|
21
31
|
__ow_headers?: Record<string, string | undefined>;
|
|
22
32
|
/** If the runtime action is invoked via HTTP, this will be the HTTP method of the request. */
|
|
23
|
-
__ow_method?:
|
|
33
|
+
__ow_method?: HttpMethodLowercase;
|
|
34
|
+
/** If the runtime action is invoked via HTTP, this will be the unmatched path of the request (matching stops after consuming the action extension) */
|
|
35
|
+
__ow_path?: string;
|
|
36
|
+
/** If the runtime action is invoked via HTTP, this will be the request body entity, as a base64-encoded string when its content is binary or JSON object/array, or as a plain string otherwise */
|
|
37
|
+
__ow_body?: string;
|
|
38
|
+
/** If the runtime action is invoked via HTTP, this will be the query parameters of the request, as an unparsed string. */
|
|
39
|
+
__ow_query?: string;
|
|
24
40
|
[key: string]: unknown;
|
|
25
41
|
};
|
|
26
42
|
//#endregion
|
|
27
|
-
export { allNonEmpty as n,
|
|
43
|
+
export { nonEmpty as a, allNonEmpty as i, HttpMethodLowercase as n, RuntimeActionParams as r, HttpMethod as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { RuntimeActionParams, allNonEmpty, nonEmpty };
|
|
1
|
+
import { a as nonEmpty, i as allNonEmpty, n as HttpMethodLowercase, r as RuntimeActionParams, t as HttpMethod } from "../index-CPYhPt8X.mjs";
|
|
2
|
+
export { HttpMethod, HttpMethodLowercase, RuntimeActionParams, allNonEmpty, nonEmpty };
|
|
@@ -36,7 +36,7 @@ type SuccessResponse<TBody extends BodyRecord = BodyRecord, THeaders extends Hea
|
|
|
36
36
|
* @template TBody - Response/error body properties
|
|
37
37
|
* @template THeaders - Custom response headers
|
|
38
38
|
*/
|
|
39
|
-
type ActionResponse<
|
|
39
|
+
type ActionResponse<TSuccessBody extends BodyRecord = BodyRecord, TErrorBody extends BodyRecordWithMessage = BodyRecordWithMessage, THeaders extends HeadersRecord = HeadersRecord> = SuccessResponse<TSuccessBody, THeaders> | ErrorResponse<TErrorBody, THeaders>;
|
|
40
40
|
/**
|
|
41
41
|
* Creates a standardized error response for runtime actions
|
|
42
42
|
* @see https://developer.adobe.com/app-builder/docs/guides/runtime_guides/creating-actions#unsuccessful-response
|
|
@@ -114,11 +114,15 @@ declare function buildSuccessResponse<TBody extends BodyRecord = BodyRecord, THe
|
|
|
114
114
|
//#region source/responses/presets.d.ts
|
|
115
115
|
declare const HTTP_OK = 200;
|
|
116
116
|
declare const HTTP_CREATED = 201;
|
|
117
|
+
declare const HTTP_ACCEPTED = 202;
|
|
117
118
|
declare const HTTP_NON_AUTHORITATIVE_INFORMATION = 203;
|
|
119
|
+
declare const HTTP_NO_CONTENT = 204;
|
|
118
120
|
declare const HTTP_BAD_REQUEST = 400;
|
|
119
121
|
declare const HTTP_UNAUTHORIZED = 401;
|
|
120
122
|
declare const HTTP_FORBIDDEN = 403;
|
|
121
123
|
declare const HTTP_NOT_FOUND = 404;
|
|
124
|
+
declare const HTTP_METHOD_NOT_ALLOWED = 405;
|
|
125
|
+
declare const HTTP_CONFLICT = 409;
|
|
122
126
|
declare const HTTP_INTERNAL_SERVER_ERROR = 500;
|
|
123
127
|
/**
|
|
124
128
|
* Creates a success response with the HTTP status code 200.
|
|
@@ -136,6 +140,14 @@ declare const created: (payload?: string | {
|
|
|
136
140
|
body?: BodyRecord;
|
|
137
141
|
headers?: HeadersRecord;
|
|
138
142
|
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
143
|
+
/**
|
|
144
|
+
* Creates a success response with the HTTP status code 202.
|
|
145
|
+
* See {@link buildSuccessResponse} for details on the response payload.
|
|
146
|
+
*/
|
|
147
|
+
declare const accepted: (payload?: string | {
|
|
148
|
+
body?: BodyRecord;
|
|
149
|
+
headers?: HeadersRecord;
|
|
150
|
+
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
139
151
|
/**
|
|
140
152
|
* Creates a success response with the HTTP status code 203.
|
|
141
153
|
* See {@link buildSuccessResponse} for details on the response payload.
|
|
@@ -144,6 +156,11 @@ declare const nonAuthoritativeInformation: (payload?: string | {
|
|
|
144
156
|
body?: BodyRecord;
|
|
145
157
|
headers?: HeadersRecord;
|
|
146
158
|
}) => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a success response with the HTTP status code 204 (No Content).
|
|
161
|
+
* This response has no body.
|
|
162
|
+
*/
|
|
163
|
+
declare const noContent: () => SuccessResponse<BodyRecord, HeadersRecord>;
|
|
147
164
|
/**
|
|
148
165
|
* Creates an error response with the HTTP status code 400.
|
|
149
166
|
* See {@link buildErrorResponse} for details on the response payload.
|
|
@@ -176,6 +193,22 @@ declare const notFound: (payload: string | {
|
|
|
176
193
|
body: BodyRecordWithMessage;
|
|
177
194
|
headers?: HeadersRecord;
|
|
178
195
|
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
196
|
+
/**
|
|
197
|
+
* Creates an error response with the HTTP status code 405.
|
|
198
|
+
* See {@link buildErrorResponse} for details on the response payload.
|
|
199
|
+
*/
|
|
200
|
+
declare const methodNotAllowed: (payload: string | {
|
|
201
|
+
body: BodyRecordWithMessage;
|
|
202
|
+
headers?: HeadersRecord;
|
|
203
|
+
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
204
|
+
/**
|
|
205
|
+
* Creates an error response with the HTTP status code 409.
|
|
206
|
+
* See {@link buildErrorResponse} for details on the response payload.
|
|
207
|
+
*/
|
|
208
|
+
declare const conflict: (payload: string | {
|
|
209
|
+
body: BodyRecordWithMessage;
|
|
210
|
+
headers?: HeadersRecord;
|
|
211
|
+
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
179
212
|
/**
|
|
180
213
|
* Creates an error response with the HTTP status code 500.
|
|
181
214
|
* See {@link buildErrorResponse} for details on the response payload.
|
|
@@ -185,4 +218,4 @@ declare const internalServerError: (payload: string | {
|
|
|
185
218
|
headers?: HeadersRecord;
|
|
186
219
|
}) => ErrorResponse<BodyRecordWithMessage, HeadersRecord>;
|
|
187
220
|
//#endregion
|
|
188
|
-
export { type ActionResponse, type ErrorResponse, HTTP_BAD_REQUEST, HTTP_CREATED, HTTP_FORBIDDEN, HTTP_INTERNAL_SERVER_ERROR, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_FOUND, HTTP_OK, HTTP_UNAUTHORIZED, type SuccessResponse, badRequest, buildErrorResponse, buildSuccessResponse, created, forbidden, internalServerError, nonAuthoritativeInformation, notFound, ok, unauthorized };
|
|
221
|
+
export { type ActionResponse, type ErrorResponse, HTTP_ACCEPTED, HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_CREATED, HTTP_FORBIDDEN, HTTP_INTERNAL_SERVER_ERROR, HTTP_METHOD_NOT_ALLOWED, HTTP_NON_AUTHORITATIVE_INFORMATION, HTTP_NOT_FOUND, HTTP_NO_CONTENT, HTTP_OK, HTTP_UNAUTHORIZED, type SuccessResponse, accepted, badRequest, buildErrorResponse, buildSuccessResponse, conflict, created, forbidden, internalServerError, methodNotAllowed, noContent, nonAuthoritativeInformation, notFound, ok, unauthorized };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function buildErrorResponse(statusCode,payload){return{type:`error`,error:{...payload?.headers&&{headers:payload.headers},statusCode,body:payload.body}}}function buildSuccessResponse(statusCode,payload){return{type:`success`,statusCode,...payload?.headers&&{headers:payload.headers},...payload?.body&&{body:payload.body}}}const HTTP_OK=200,HTTP_CREATED=201,HTTP_NON_AUTHORITATIVE_INFORMATION=203,HTTP_BAD_REQUEST=400,HTTP_UNAUTHORIZED=401,HTTP_FORBIDDEN=403,HTTP_NOT_FOUND=404,HTTP_INTERNAL_SERVER_ERROR=500;function curryBuildSuccessResponse(code){return payload=>buildSuccessResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}function curryBuildErrorResponse(code){return payload=>buildErrorResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}const ok=curryBuildSuccessResponse(200),created=curryBuildSuccessResponse(201),nonAuthoritativeInformation=curryBuildSuccessResponse(203),badRequest=curryBuildErrorResponse(400),unauthorized=curryBuildErrorResponse(401),forbidden=curryBuildErrorResponse(403),notFound=curryBuildErrorResponse(404),internalServerError=curryBuildErrorResponse(500);export{HTTP_BAD_REQUEST,HTTP_CREATED,HTTP_FORBIDDEN,HTTP_INTERNAL_SERVER_ERROR,HTTP_NON_AUTHORITATIVE_INFORMATION,HTTP_NOT_FOUND,HTTP_OK,HTTP_UNAUTHORIZED,badRequest,buildErrorResponse,buildSuccessResponse,created,forbidden,internalServerError,nonAuthoritativeInformation,notFound,ok,unauthorized};
|
|
1
|
+
function buildErrorResponse(statusCode,payload){return{type:`error`,error:{...payload?.headers&&{headers:payload.headers},statusCode,body:payload.body}}}function buildSuccessResponse(statusCode,payload){return{type:`success`,statusCode,...payload?.headers&&{headers:payload.headers},...payload?.body&&{body:payload.body}}}const HTTP_OK=200,HTTP_CREATED=201,HTTP_ACCEPTED=202,HTTP_NON_AUTHORITATIVE_INFORMATION=203,HTTP_NO_CONTENT=204,HTTP_BAD_REQUEST=400,HTTP_UNAUTHORIZED=401,HTTP_FORBIDDEN=403,HTTP_NOT_FOUND=404,HTTP_METHOD_NOT_ALLOWED=405,HTTP_CONFLICT=409,HTTP_INTERNAL_SERVER_ERROR=500;function curryBuildSuccessResponse(code){return payload=>buildSuccessResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}function curryBuildErrorResponse(code){return payload=>buildErrorResponse(code,typeof payload==`string`?{body:{message:payload}}:payload)}const ok=curryBuildSuccessResponse(200),created=curryBuildSuccessResponse(201),accepted=curryBuildSuccessResponse(202),nonAuthoritativeInformation=curryBuildSuccessResponse(203),noContent=()=>buildSuccessResponse(204),badRequest=curryBuildErrorResponse(400),unauthorized=curryBuildErrorResponse(401),forbidden=curryBuildErrorResponse(403),notFound=curryBuildErrorResponse(404),methodNotAllowed=curryBuildErrorResponse(405),conflict=curryBuildErrorResponse(409),internalServerError=curryBuildErrorResponse(500);export{HTTP_ACCEPTED,HTTP_BAD_REQUEST,HTTP_CONFLICT,HTTP_CREATED,HTTP_FORBIDDEN,HTTP_INTERNAL_SERVER_ERROR,HTTP_METHOD_NOT_ALLOWED,HTTP_NON_AUTHORITATIVE_INFORMATION,HTTP_NOT_FOUND,HTTP_NO_CONTENT,HTTP_OK,HTTP_UNAUTHORIZED,accepted,badRequest,buildErrorResponse,buildSuccessResponse,conflict,created,forbidden,internalServerError,methodNotAllowed,noContent,nonAuthoritativeInformation,notFound,ok,unauthorized};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@adobe/aio-commerce-lib-core",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Adobe Inc.",
|
|
5
|
-
"version": "0.6.
|
|
5
|
+
"version": "0.6.1",
|
|
6
6
|
"private": false,
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20 <=24"
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"sideEffects": false,
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|
|
67
|
+
"pack": "pnpm pack",
|
|
67
68
|
"publint": "publint",
|
|
68
69
|
"docs": "typedoc && prettier --write '**/*.md'",
|
|
69
70
|
"assist": "biome check --formatter-enabled=false --linter-enabled=false --assist-enabled=true --no-errors-on-unmatched",
|