@seamapi/nextlove-sdk-generator 1.15.0 → 1.15.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.
Files changed (34) hide show
  1. package/lib/generate-php-sdk/generate-php-sdk.js +5 -0
  2. package/lib/generate-php-sdk/generate-php-sdk.js.map +1 -1
  3. package/lib/generate-php-sdk/templates/composer.json.template.js +1 -1
  4. package/lib/generate-php-sdk/templates/exceptions/action-attempt-error.template.d.ts +2 -0
  5. package/lib/generate-php-sdk/templates/exceptions/action-attempt-error.template.js +24 -0
  6. package/lib/generate-php-sdk/templates/exceptions/action-attempt-error.template.js.map +1 -0
  7. package/lib/generate-php-sdk/templates/exceptions/action-attempt-failed-error.template.d.ts +2 -0
  8. package/lib/generate-php-sdk/templates/exceptions/action-attempt-failed-error.template.js +24 -0
  9. package/lib/generate-php-sdk/templates/exceptions/action-attempt-failed-error.template.js.map +1 -0
  10. package/lib/generate-php-sdk/templates/exceptions/action-attempt-timeout-error.template.d.ts +2 -0
  11. package/lib/generate-php-sdk/templates/exceptions/action-attempt-timeout-error.template.js +19 -0
  12. package/lib/generate-php-sdk/templates/exceptions/action-attempt-timeout-error.template.js.map +1 -0
  13. package/lib/generate-php-sdk/templates/exceptions/http-api-error.template.d.ts +2 -0
  14. package/lib/generate-php-sdk/templates/exceptions/http-api-error.template.js +43 -0
  15. package/lib/generate-php-sdk/templates/exceptions/http-api-error.template.js.map +1 -0
  16. package/lib/generate-php-sdk/templates/exceptions/http-invalid-input-error.template.d.ts +2 -0
  17. package/lib/generate-php-sdk/templates/exceptions/http-invalid-input-error.template.js +22 -0
  18. package/lib/generate-php-sdk/templates/exceptions/http-invalid-input-error.template.js.map +1 -0
  19. package/lib/generate-php-sdk/templates/exceptions/http-unauthorized-error.template.d.ts +2 -0
  20. package/lib/generate-php-sdk/templates/exceptions/http-unauthorized-error.template.js +17 -0
  21. package/lib/generate-php-sdk/templates/exceptions/http-unauthorized-error.template.js.map +1 -0
  22. package/lib/generate-php-sdk/utils/load-exception-templates.d.ts +1 -0
  23. package/lib/generate-php-sdk/utils/load-exception-templates.js +17 -0
  24. package/lib/generate-php-sdk/utils/load-exception-templates.js.map +1 -0
  25. package/package.json +1 -1
  26. package/src/lib/generate-php-sdk/generate-php-sdk.ts +6 -0
  27. package/src/lib/generate-php-sdk/templates/composer.json.template.ts +1 -1
  28. package/src/lib/generate-php-sdk/templates/exceptions/action-attempt-error.template.ts +23 -0
  29. package/src/lib/generate-php-sdk/templates/exceptions/action-attempt-failed-error.template.ts +23 -0
  30. package/src/lib/generate-php-sdk/templates/exceptions/action-attempt-timeout-error.template.ts +18 -0
  31. package/src/lib/generate-php-sdk/templates/exceptions/http-api-error.template.ts +42 -0
  32. package/src/lib/generate-php-sdk/templates/exceptions/http-invalid-input-error.template.ts +21 -0
  33. package/src/lib/generate-php-sdk/templates/exceptions/http-unauthorized-error.template.ts +16 -0
  34. package/src/lib/generate-php-sdk/utils/load-exception-templates.ts +17 -0
@@ -15,6 +15,7 @@ import smokeTestTemplate from "./templates/smoke-test.template.js";
15
15
  import PackageVersionTemplate from "./templates/PackageVersion.php.template.js";
16
16
  import mapParentToChildResources from "../../lib/openapi/map-parent-to-children-resource.js";
17
17
  import resolveOpenapiSpec from "../../lib/openapi/resolve-openapi-spec.js";
18
+ import { loadExceptionTemplates } from "./utils/load-exception-templates.js";
18
19
  export const generatePhpSDK = async (options = {}) => {
19
20
  const openapi = await resolveOpenapiSpec(options);
20
21
  const routes = Object.entries(openapi.paths).map(([path, v]) => ({
@@ -30,6 +31,10 @@ export const generatePhpSDK = async (options = {}) => {
30
31
  fs["tests/Fixture.php"] = testFixtureTemplate();
31
32
  fs["tests/SmokeTest.php"] = smokeTestTemplate();
32
33
  fs["src/Utils/PackageVersion.php"] = PackageVersionTemplate();
34
+ const exceptions = loadExceptionTemplates();
35
+ for (const [filename, content] of Object.entries(exceptions)) {
36
+ fs[`src/Exceptions/${filename}`] = content;
37
+ }
33
38
  const base_resource_object_names = [];
34
39
  for (const [schema_name, schema] of Object.entries(openapi.components.schemas)) {
35
40
  base_resource_object_names.push(pascalCase(schema_name));
@@ -1 +1 @@
1
- {"version":3,"file":"generate-php-sdk.js","sourceRoot":"","sources":["../../src/lib/generate-php-sdk/generate-php-sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAA;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,SAAS,EAA4B,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAA;AAClG,OAAO,gBAAgB,MAAM,mCAAmC,CAAA;AAChE,OAAO,mBAAmB,MAAM,sCAAsC,CAAA;AACtE,OAAO,oBAAoB,MAAM,uCAAuC,CAAA;AACxE,OAAO,iBAAiB,MAAM,mCAAmC,CAAA;AACjE,OAAO,kBAAkB,MAAM,qCAAqC,CAAA;AACpE,OAAO,mBAAmB,MAAM,sCAAsC,CAAA;AACtE,OAAO,iBAAiB,MAAM,oCAAoC,CAAA;AAClE,OAAO,sBAAsB,MAAM,4CAA4C,CAAA;AAC/E,OAAO,yBAAyB,MAAM,gDAAgD,CAAA;AACtF,OAAO,kBAAkB,MAAM,qCAAqC,CAAA;AAEpE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,UAA+B,EAAE,EAAE,EAAE;IACxE,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAA;IACjD,MAAM,MAAM,GAAY,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CA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,CAAC;YAClD,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC;YAC5C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,CAAC;SAC9C,CAAC,CAAA;KACH;IAED,EAAE,CAAC,oBAAoB,CAAC,GAAG,kBAAkB,CAAC;QAC5C,gBAAgB,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACxC,qBAAqB,EAAE,0BAA0B;KAClD,CAAC,CAAA;IAEF,OAAO,EAAE,CAAA;AACX,CAAC,CAAA"}
@@ -6,7 +6,7 @@ export default () => `{
6
6
  },
7
7
  "autoload": {
8
8
  "psr-4": {
9
- "Seam\\\\": "src/",
9
+ "Seam\\\\": ["src/", "src/Exceptions/"],
10
10
  "Tests\\\\": "tests/"
11
11
  }
12
12
  },
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,24 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptError extends \\Exception
8
+ {
9
+ private ActionAttempt $actionAttempt;
10
+
11
+ public function __construct(string $message, ActionAttempt $actionAttempt)
12
+ {
13
+ parent::__construct($message);
14
+ $this->name = get_class($this);
15
+ $this->actionAttempt = $actionAttempt;
16
+ }
17
+
18
+ public function getActionAttempt(): ActionAttempt
19
+ {
20
+ return $this->actionAttempt;
21
+ }
22
+ }
23
+ `;
24
+ //# sourceMappingURL=action-attempt-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-attempt-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/action-attempt-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,24 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptFailedError extends ActionAttemptError
8
+ {
9
+ private string $errorCode;
10
+
11
+ public function __construct(ActionAttempt $actionAttempt)
12
+ {
13
+ parent::__construct($actionAttempt->error->message, $actionAttempt);
14
+ $this->name = get_class($this);
15
+ $this->errorCode = $actionAttempt->error->type;
16
+ }
17
+
18
+ public function getErrorCode(): string
19
+ {
20
+ return $this->errorCode;
21
+ }
22
+ }
23
+ `;
24
+ //# sourceMappingURL=action-attempt-failed-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-attempt-failed-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/action-attempt-failed-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptTimeoutError extends ActionAttemptError
8
+ {
9
+ public function __construct(ActionAttempt $actionAttempt, float $timeout)
10
+ {
11
+ parent::__construct(
12
+ "Timed out waiting for action attempt after {$timeout}s",
13
+ $actionAttempt
14
+ );
15
+ $this->name = get_class($this);
16
+ }
17
+ }
18
+ `;
19
+ //# sourceMappingURL=action-attempt-timeout-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-attempt-timeout-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/action-attempt-timeout-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;CAiBpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,43 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpApiError extends \\Exception
6
+ {
7
+ private string $errorCode;
8
+ private int $statusCode;
9
+ private string $requestId;
10
+ private ?object $data = null;
11
+
12
+ public function __construct(object $error, int $statusCode, string $requestId)
13
+ {
14
+ $message = $error->message ?? 'Unknown error';
15
+ parent::__construct($message);
16
+ $this->errorCode = $error->type ?? 'unknown';
17
+ $this->statusCode = $statusCode;
18
+ $this->requestId = $requestId;
19
+ $this->data = $error->data ?? null;
20
+ }
21
+
22
+ public function getErrorCode(): string
23
+ {
24
+ return $this->errorCode;
25
+ }
26
+
27
+ public function getStatusCode(): int
28
+ {
29
+ return $this->statusCode;
30
+ }
31
+
32
+ public function getRequestId(): string
33
+ {
34
+ return $this->requestId;
35
+ }
36
+
37
+ public function getData(): mixed
38
+ {
39
+ return $this->data;
40
+ }
41
+ }
42
+ `;
43
+ //# sourceMappingURL=http-api-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-api-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/http-api-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpInvalidInputError extends HttpApiError
6
+ {
7
+ private object $validationErrors;
8
+
9
+ public function __construct(object $error, int $statusCode, string $requestId)
10
+ {
11
+ parent::__construct($error, $statusCode, $requestId);
12
+ $this->errorCode = 'invalid_input';
13
+ $this->validationErrors = $error->validation_errors ?? (object)[];
14
+ }
15
+
16
+ public function getValidationErrorMessages(string $paramName): array
17
+ {
18
+ return $this->validationErrors->{$paramName}->_errors ?? [];
19
+ }
20
+ }
21
+ `;
22
+ //# sourceMappingURL=http-invalid-input-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-invalid-input-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/http-invalid-input-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const _default: () => string;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpUnauthorizedError extends HttpApiError
6
+ {
7
+ public function __construct(string $requestId)
8
+ {
9
+ $error = (object)[
10
+ 'type' => 'unauthorized',
11
+ 'message' => 'Unauthorized'
12
+ ];
13
+ parent::__construct($error, 401, $requestId);
14
+ }
15
+ }
16
+ `;
17
+ //# sourceMappingURL=http-unauthorized-error.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-unauthorized-error.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-php-sdk/templates/exceptions/http-unauthorized-error.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;CAepB,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function loadExceptionTemplates(): Record<string, string>;
@@ -0,0 +1,17 @@
1
+ import actionAttemptErrorTemplate from "../templates/exceptions/action-attempt-error.template.js";
2
+ import actionAttemptFailedErrorTemplate from "../templates/exceptions/action-attempt-failed-error.template.js";
3
+ import actionAttemptTimeoutErrorTemplate from "../templates/exceptions/action-attempt-timeout-error.template.js";
4
+ import httpApiErrorTemplate from "../templates/exceptions/http-api-error.template.js";
5
+ import httpInvalidInputErrorTemplate from "../templates/exceptions/http-invalid-input-error.template.js";
6
+ import httpUnauthorizedErrorTemplate from "../templates/exceptions/http-unauthorized-error.template.js";
7
+ export function loadExceptionTemplates() {
8
+ return {
9
+ "ActionAttemptError.php": actionAttemptErrorTemplate(),
10
+ "ActionAttemptFailedError.php": actionAttemptFailedErrorTemplate(),
11
+ "ActionAttemptTimeoutError.php": actionAttemptTimeoutErrorTemplate(),
12
+ "HttpApiError.php": httpApiErrorTemplate(),
13
+ "HttpInvalidInputError.php": httpInvalidInputErrorTemplate(),
14
+ "HttpUnauthorizedError.php": httpUnauthorizedErrorTemplate(),
15
+ };
16
+ }
17
+ //# sourceMappingURL=load-exception-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-exception-templates.js","sourceRoot":"","sources":["../../../src/lib/generate-php-sdk/utils/load-exception-templates.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,MAAM,0DAA0D,CAAA;AACjG,OAAO,gCAAgC,MAAM,iEAAiE,CAAA;AAC9G,OAAO,iCAAiC,MAAM,kEAAkE,CAAA;AAChH,OAAO,oBAAoB,MAAM,oDAAoD,CAAA;AACrF,OAAO,6BAA6B,MAAM,8DAA8D,CAAA;AACxG,OAAO,6BAA6B,MAAM,6DAA6D,CAAA;AAEvG,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,wBAAwB,EAAE,0BAA0B,EAAE;QACtD,8BAA8B,EAAE,gCAAgC,EAAE;QAClE,+BAA+B,EAAE,iCAAiC,EAAE;QACpE,kBAAkB,EAAE,oBAAoB,EAAE;QAC1C,2BAA2B,EAAE,6BAA6B,EAAE;QAC5D,2BAA2B,EAAE,6BAA6B,EAAE;KAC7D,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/nextlove-sdk-generator",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Utilities for building NextLove SDK Generators",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -16,6 +16,7 @@ import smokeTestTemplate from "./templates/smoke-test.template.js"
16
16
  import PackageVersionTemplate from "./templates/PackageVersion.php.template.js"
17
17
  import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"
18
18
  import resolveOpenapiSpec from "lib/openapi/resolve-openapi-spec.js"
19
+ import { loadExceptionTemplates } from "./utils/load-exception-templates.js"
19
20
 
20
21
  export const generatePhpSDK = async (options: SdkGeneratorOptions = {}) => {
21
22
  const openapi = await resolveOpenapiSpec(options)
@@ -35,6 +36,11 @@ export const generatePhpSDK = async (options: SdkGeneratorOptions = {}) => {
35
36
  fs["tests/SmokeTest.php"] = smokeTestTemplate()
36
37
  fs["src/Utils/PackageVersion.php"] = PackageVersionTemplate()
37
38
 
39
+ const exceptions = loadExceptionTemplates()
40
+ for (const [filename, content] of Object.entries(exceptions)) {
41
+ fs[`src/Exceptions/${filename}`] = content
42
+ }
43
+
38
44
  const base_resource_object_names: string[] = []
39
45
  for (const [schema_name, schema] of Object.entries(
40
46
  openapi.components.schemas
@@ -6,7 +6,7 @@ export default () => `{
6
6
  },
7
7
  "autoload": {
8
8
  "psr-4": {
9
- "Seam\\\\": "src/",
9
+ "Seam\\\\": ["src/", "src/Exceptions/"],
10
10
  "Tests\\\\": "tests/"
11
11
  }
12
12
  },
@@ -0,0 +1,23 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptError extends \\Exception
8
+ {
9
+ private ActionAttempt $actionAttempt;
10
+
11
+ public function __construct(string $message, ActionAttempt $actionAttempt)
12
+ {
13
+ parent::__construct($message);
14
+ $this->name = get_class($this);
15
+ $this->actionAttempt = $actionAttempt;
16
+ }
17
+
18
+ public function getActionAttempt(): ActionAttempt
19
+ {
20
+ return $this->actionAttempt;
21
+ }
22
+ }
23
+ `
@@ -0,0 +1,23 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptFailedError extends ActionAttemptError
8
+ {
9
+ private string $errorCode;
10
+
11
+ public function __construct(ActionAttempt $actionAttempt)
12
+ {
13
+ parent::__construct($actionAttempt->error->message, $actionAttempt);
14
+ $this->name = get_class($this);
15
+ $this->errorCode = $actionAttempt->error->type;
16
+ }
17
+
18
+ public function getErrorCode(): string
19
+ {
20
+ return $this->errorCode;
21
+ }
22
+ }
23
+ `
@@ -0,0 +1,18 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ use Seam\\Objects\\ActionAttempt;
6
+
7
+ class ActionAttemptTimeoutError extends ActionAttemptError
8
+ {
9
+ public function __construct(ActionAttempt $actionAttempt, float $timeout)
10
+ {
11
+ parent::__construct(
12
+ "Timed out waiting for action attempt after {$timeout}s",
13
+ $actionAttempt
14
+ );
15
+ $this->name = get_class($this);
16
+ }
17
+ }
18
+ `
@@ -0,0 +1,42 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpApiError extends \\Exception
6
+ {
7
+ private string $errorCode;
8
+ private int $statusCode;
9
+ private string $requestId;
10
+ private ?object $data = null;
11
+
12
+ public function __construct(object $error, int $statusCode, string $requestId)
13
+ {
14
+ $message = $error->message ?? 'Unknown error';
15
+ parent::__construct($message);
16
+ $this->errorCode = $error->type ?? 'unknown';
17
+ $this->statusCode = $statusCode;
18
+ $this->requestId = $requestId;
19
+ $this->data = $error->data ?? null;
20
+ }
21
+
22
+ public function getErrorCode(): string
23
+ {
24
+ return $this->errorCode;
25
+ }
26
+
27
+ public function getStatusCode(): int
28
+ {
29
+ return $this->statusCode;
30
+ }
31
+
32
+ public function getRequestId(): string
33
+ {
34
+ return $this->requestId;
35
+ }
36
+
37
+ public function getData(): mixed
38
+ {
39
+ return $this->data;
40
+ }
41
+ }
42
+ `
@@ -0,0 +1,21 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpInvalidInputError extends HttpApiError
6
+ {
7
+ private object $validationErrors;
8
+
9
+ public function __construct(object $error, int $statusCode, string $requestId)
10
+ {
11
+ parent::__construct($error, $statusCode, $requestId);
12
+ $this->errorCode = 'invalid_input';
13
+ $this->validationErrors = $error->validation_errors ?? (object)[];
14
+ }
15
+
16
+ public function getValidationErrorMessages(string $paramName): array
17
+ {
18
+ return $this->validationErrors->{$paramName}->_errors ?? [];
19
+ }
20
+ }
21
+ `
@@ -0,0 +1,16 @@
1
+ export default () => `<?php
2
+
3
+ namespace Seam;
4
+
5
+ class HttpUnauthorizedError extends HttpApiError
6
+ {
7
+ public function __construct(string $requestId)
8
+ {
9
+ $error = (object)[
10
+ 'type' => 'unauthorized',
11
+ 'message' => 'Unauthorized'
12
+ ];
13
+ parent::__construct($error, 401, $requestId);
14
+ }
15
+ }
16
+ `
@@ -0,0 +1,17 @@
1
+ import actionAttemptErrorTemplate from "../templates/exceptions/action-attempt-error.template.js"
2
+ import actionAttemptFailedErrorTemplate from "../templates/exceptions/action-attempt-failed-error.template.js"
3
+ import actionAttemptTimeoutErrorTemplate from "../templates/exceptions/action-attempt-timeout-error.template.js"
4
+ import httpApiErrorTemplate from "../templates/exceptions/http-api-error.template.js"
5
+ import httpInvalidInputErrorTemplate from "../templates/exceptions/http-invalid-input-error.template.js"
6
+ import httpUnauthorizedErrorTemplate from "../templates/exceptions/http-unauthorized-error.template.js"
7
+
8
+ export function loadExceptionTemplates(): Record<string, string> {
9
+ return {
10
+ "ActionAttemptError.php": actionAttemptErrorTemplate(),
11
+ "ActionAttemptFailedError.php": actionAttemptFailedErrorTemplate(),
12
+ "ActionAttemptTimeoutError.php": actionAttemptTimeoutErrorTemplate(),
13
+ "HttpApiError.php": httpApiErrorTemplate(),
14
+ "HttpInvalidInputError.php": httpInvalidInputErrorTemplate(),
15
+ "HttpUnauthorizedError.php": httpUnauthorizedErrorTemplate(),
16
+ }
17
+ }