@outfoxx/sunday 2.0.0-beta.3 → 2.0.0-beta.5

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 (55) hide show
  1. package/README.md +52 -0
  2. package/build/fetch-event-source.d.ts +3 -0
  3. package/build/fetch-event-source.js +11 -4
  4. package/build/fetch-event-source.js.map +1 -1
  5. package/build/fetch-oauth-token-provider.d.ts +43 -0
  6. package/build/fetch-oauth-token-provider.js +193 -0
  7. package/build/fetch-oauth-token-provider.js.map +1 -0
  8. package/build/fetch-transport.d.ts +5 -0
  9. package/build/fetch-transport.js +58 -8
  10. package/build/fetch-transport.js.map +1 -1
  11. package/build/index.d.ts +8 -0
  12. package/build/index.js +8 -0
  13. package/build/index.js.map +1 -1
  14. package/build/media-type-codecs/cbor-encoder.d.ts +2 -2
  15. package/build/media-type-codecs/cbor-encoder.js +2 -2
  16. package/build/media-type-codecs/cbor-encoder.js.map +1 -1
  17. package/build/media-type-codecs/json-encoder.d.ts +3 -3
  18. package/build/media-type-codecs/json-encoder.js +4 -4
  19. package/build/media-type-codecs/json-encoder.js.map +1 -1
  20. package/build/media-type-codecs/media-type-encoder.d.ts +3 -3
  21. package/build/media-type-codecs/media-type-encoder.js.map +1 -1
  22. package/build/media-type-codecs/www-form-url-encoder.d.ts +2 -2
  23. package/build/media-type-codecs/www-form-url-encoder.js +2 -2
  24. package/build/media-type-codecs/www-form-url-encoder.js.map +1 -1
  25. package/build/model-construction.d.ts +5 -0
  26. package/build/model-construction.js +40 -0
  27. package/build/model-construction.js.map +1 -0
  28. package/build/model-schema.d.ts +9 -0
  29. package/build/model-schema.js +131 -0
  30. package/build/model-schema.js.map +1 -0
  31. package/build/problem.js +2 -1
  32. package/build/problem.js.map +1 -1
  33. package/build/request-security.d.ts +16 -0
  34. package/build/request-security.js +167 -0
  35. package/build/request-security.js.map +1 -0
  36. package/build/request-validation-error.d.ts +4 -0
  37. package/build/request-validation-error.js +21 -0
  38. package/build/request-validation-error.js.map +1 -0
  39. package/build/schema-runtime.d.ts +8 -1
  40. package/build/schema-runtime.js +12 -3
  41. package/build/schema-runtime.js.map +1 -1
  42. package/build/security-binding.d.ts +22 -0
  43. package/build/security-binding.js +15 -0
  44. package/build/security-binding.js.map +1 -0
  45. package/build/token-manager.d.ts +33 -0
  46. package/build/token-manager.js +199 -0
  47. package/build/token-manager.js.map +1 -0
  48. package/build/token-provider.d.ts +44 -0
  49. package/build/token-provider.js +31 -0
  50. package/build/token-provider.js.map +1 -0
  51. package/build/transport.d.ts +5 -0
  52. package/build/unknown-variant.d.ts +12 -0
  53. package/build/unknown-variant.js +45 -0
  54. package/build/unknown-variant.js.map +1 -0
  55. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ /** Signals that an interactive application must supply a fresh authorization session. */
15
+ export class AuthorizationRequiredError extends Error {
16
+ constructor() {
17
+ super('Fresh application authorization is required');
18
+ this.name = 'AuthorizationRequiredError';
19
+ }
20
+ }
21
+ /** Safe provider failure without a provider's potentially credential-bearing error message. */
22
+ export class TokenProviderError extends Error {
23
+ reason;
24
+ /** Safe recovery classification; provider messages and credentials are never retained. */
25
+ constructor(reason = 'unavailable') {
26
+ super('The credential provider could not supply usable credentials');
27
+ this.reason = reason;
28
+ this.name = 'TokenProviderError';
29
+ }
30
+ }
31
+ //# sourceMappingURL=token-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-provider.js","sourceRoot":"","sources":["../src/token-provider.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA0CjC,yFAAyF;AACzF,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD;QACE,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEtB;IADrB,0FAA0F;IAC1F,YAAqB,SAAuD,aAAa;QACvF,KAAK,CAAC,6DAA6D,CAAC,CAAC;QADlD,WAAM,GAAN,MAAM,CAA8D;QAEvF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
@@ -1,3 +1,4 @@
1
+ import { SecurityBinding } from './security-binding.js';
1
2
  import { MediaType } from './media-type.js';
2
3
  import { TextMediaTypeDecoder } from './media-type-codecs/media-type-decoder.js';
3
4
  import { Problem } from './problem.js';
@@ -29,10 +30,14 @@ export interface RequestSpec<B> {
29
30
  queryParameters?: Record<string, unknown>;
30
31
  body?: B;
31
32
  bodyType?: SchemaLike<B>;
33
+ /** Revalidates typed parameters on every request build, before wire conversion. */
34
+ parameterValidation?: () => void;
32
35
  contentTypes?: MediaType[];
33
36
  acceptTypes?: MediaType[];
34
37
  headers?: Record<string, unknown>;
35
38
  signal?: AbortSignal;
39
+ /** Complete, explicitly selected credential bindings for this operation. */
40
+ security?: readonly SecurityBinding[];
36
41
  }
37
42
  export interface RequestAdapter {
38
43
  adapt(transport: Transport, request: Request): Promise<Request>;
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ /** Marks a fallback independently of its discriminator or structural fields. */
3
+ export declare const UnknownVariantTag: unique symbol;
4
+ /** An unknown discriminated payload whose original wire fields are preserved. */
5
+ export interface UnknownVariant {
6
+ readonly [UnknownVariantTag]: true;
7
+ readonly rawBody: Readonly<Record<string, unknown>>;
8
+ }
9
+ /** Identifies fallback instances even when their discriminator resembles a known branch. */
10
+ export declare function isUnknownVariant(value: unknown): value is UnknownVariant;
11
+ /** Dispatches encoding by fallback identity while retaining native schema validation. */
12
+ export declare function unionWithUnknown<K extends z.ZodType, U extends z.ZodType<UnknownVariant>>(known: K, unknown: U): z.ZodType<z.output<K> | z.output<U>>;
@@ -0,0 +1,45 @@
1
+ // Copyright 2020 Outfox, Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { z } from 'zod';
15
+ /** Marks a fallback independently of its discriminator or structural fields. */
16
+ export const UnknownVariantTag = Symbol.for('@outfoxx/sunday/UnknownVariant');
17
+ /** Identifies fallback instances even when their discriminator resembles a known branch. */
18
+ export function isUnknownVariant(value) {
19
+ return typeof value === 'object' && value !== null
20
+ && UnknownVariantTag in value && value[UnknownVariantTag] === true;
21
+ }
22
+ /** Dispatches encoding by fallback identity while retaining native schema validation. */
23
+ export function unionWithUnknown(known, unknown) {
24
+ const wire = z.union([known, unknown]);
25
+ return z.codec(z.unknown(), z.custom(), {
26
+ decode(value, context) {
27
+ const result = wire.safeParse(value);
28
+ if (!result.success) {
29
+ context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
30
+ return z.NEVER;
31
+ }
32
+ return result.data;
33
+ },
34
+ encode(value, context) {
35
+ const schema = isUnknownVariant(value) ? unknown : known;
36
+ const result = schema.safeEncode(value);
37
+ if (!result.success) {
38
+ context.issues.push(...result.error.issues.map(issue => ({ ...issue, input: undefined })));
39
+ return z.NEVER;
40
+ }
41
+ return result.data;
42
+ },
43
+ });
44
+ }
45
+ //# sourceMappingURL=unknown-variant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknown-variant.js","sourceRoot":"","sources":["../src/unknown-variant.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gFAAgF;AAChF,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAQ7F,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;WAC7C,iBAAiB,IAAI,KAAK,IAAI,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;AACvE,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAC9B,KAAQ,EACR,OAAU;IAEV,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAA6B,EAAE;QACjE,MAAM,CAAC,KAAK,EAAE,OAAO;YACnB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3F,OAAO,CAAC,CAAC,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,KAAK,EAAE,OAAO;YACnB,MAAM,MAAM,GAAc,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;YACpE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3F,OAAO,CAAC,CAAC,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outfoxx/sunday",
3
- "version": "v2.0.0-beta.3",
3
+ "version": "v2.0.0-beta.5",
4
4
  "description": "Sunday 🙏 The framework of REST for TypeScript/JavaScript",
5
5
  "packageManager": "bun@1.3.10",
6
6
  "type": "module",