@venizia/ignis-connectors 0.4.8 → 0.5.0-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 (38) hide show
  1. package/dist/esm/http/common/constants.d.ts +5 -0
  2. package/dist/esm/http/common/constants.js +5 -0
  3. package/dist/esm/http/common/constants.js.map +1 -1
  4. package/dist/esm/http/common/types.d.ts +15 -20
  5. package/dist/esm/http/common/types.js.map +1 -1
  6. package/dist/esm/http/common/wire.d.ts +0 -5
  7. package/dist/esm/http/common/wire.js +0 -6
  8. package/dist/esm/http/common/wire.js.map +1 -1
  9. package/dist/esm/http/datasource.d.ts +0 -17
  10. package/dist/esm/http/datasource.js +59 -109
  11. package/dist/esm/http/datasource.js.map +1 -1
  12. package/dist/esm/http/repository.d.ts +3 -8
  13. package/dist/esm/http/repository.js +1 -1
  14. package/dist/esm/http/repository.js.map +1 -1
  15. package/dist/esm/search/core/controllers/abstract.d.ts +5 -0
  16. package/dist/esm/search/core/controllers/abstract.js +4 -1
  17. package/dist/esm/search/core/controllers/abstract.js.map +1 -1
  18. package/dist/esm/search/core/controllers/factory.d.ts +299 -26
  19. package/dist/esm/search/core/controllers/factory.js +48 -29
  20. package/dist/esm/search/core/controllers/factory.js.map +1 -1
  21. package/dist/esm/search/core/controllers/index.d.ts +1 -0
  22. package/dist/esm/search/core/controllers/index.js +1 -0
  23. package/dist/esm/search/core/controllers/index.js.map +1 -1
  24. package/dist/esm/search/core/controllers/modes.d.ts +20 -0
  25. package/dist/esm/search/core/controllers/modes.js +52 -0
  26. package/dist/esm/search/core/controllers/modes.js.map +1 -0
  27. package/dist/esm/search/core/controllers/options.d.ts +4 -0
  28. package/dist/esm/search/core/controllers/options.js +3 -0
  29. package/dist/esm/search/core/controllers/options.js.map +1 -1
  30. package/dist/esm/search/core/controllers/raw-access.d.ts +2 -7
  31. package/dist/esm/search/core/controllers/raw-access.js +2 -7
  32. package/dist/esm/search/core/controllers/raw-access.js.map +1 -1
  33. package/dist/esm/search/typesense/common/types/options.d.ts +7 -0
  34. package/dist/esm/search/typesense/common/types/options.js.map +1 -1
  35. package/dist/esm/search/typesense/connector.d.ts +9 -1
  36. package/dist/esm/search/typesense/connector.js +56 -3
  37. package/dist/esm/search/typesense/connector.js.map +1 -1
  38. package/package.json +6 -6
@@ -1,4 +1,9 @@
1
1
  import type { TConstValue } from '@venizia/ignis-helpers/common';
2
+ /** Headers the HTTP datasource owns on the wire, beside the shared ones in `HTTP.Headers`. */
3
+ export declare class HttpWireHeaders {
4
+ /** The credential's `provider`, when it names one. */
5
+ static readonly AUTH_PROVIDER = "x-auth-provider";
6
+ }
2
7
  /** What a read expects back: LIST (a bare array or the `{ count, data }` envelope) or ONE (a single record, never unwrapped). */
3
8
  export declare class HttpReadShapes {
4
9
  static readonly LIST = "list";
@@ -1,3 +1,8 @@
1
+ /** Headers the HTTP datasource owns on the wire, beside the shared ones in `HTTP.Headers`. */
2
+ export class HttpWireHeaders {
3
+ /** The credential's `provider`, when it names one. */
4
+ static { this.AUTH_PROVIDER = 'x-auth-provider'; }
5
+ }
1
6
  /** What a read expects back: LIST (a bare array or the `{ count, data }` envelope) or ONE (a single record, never unwrapped). */
2
7
  export class HttpReadShapes {
3
8
  static { this.LIST = 'list'; }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/http/common/constants.ts"],"names":[],"mappings":"AAEA,iIAAiI;AACjI,MAAM,OAAO,cAAc;aACT,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aAEZ,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** What a read expects back: LIST (a bare array or the `{ count, data }` envelope) or ONE (a single record, never unwrapped). */\nexport class HttpReadShapes {\n static readonly LIST = 'list';\n static readonly ONE = 'one';\n\n static readonly SCHEME_SET = new Set<string>([this.LIST, this.ONE]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid HTTP read shape values. */\nexport type THttpReadShape = TConstValue<typeof HttpReadShapes>;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/http/common/constants.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,MAAM,OAAO,eAAe;IAC1B,sDAAsD;aACtC,kBAAa,GAAG,iBAAiB,CAAC;;AAGpD,iIAAiI;AACjI,MAAM,OAAO,cAAc;aACT,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aAEZ,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** Headers the HTTP datasource owns on the wire, beside the shared ones in `HTTP.Headers`. */\nexport class HttpWireHeaders {\n /** The credential's `provider`, when it names one. */\n static readonly AUTH_PROVIDER = 'x-auth-provider';\n}\n\n/** What a read expects back: LIST (a bare array or the `{ count, data }` envelope) or ONE (a single record, never unwrapped). */\nexport class HttpReadShapes {\n static readonly LIST = 'list';\n static readonly ONE = 'one';\n\n static readonly SCHEME_SET = new Set<string>([this.LIST, this.ONE]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid HTTP read shape values. */\nexport type THttpReadShape = TConstValue<typeof HttpReadShapes>;\n"]}
@@ -1,4 +1,4 @@
1
- import type { TFilter } from '@venizia/ignis-filter';
1
+ import type { TNativeFetchSender } from '@venizia/ignis-helpers/core';
2
2
  /** A credential the HTTP datasource attaches to a request: `Authorization: <type> <value>`, and `provider`, when set, as the `x-auth-provider` header. */
3
3
  export interface IAuthToken {
4
4
  value: string;
@@ -10,7 +10,11 @@ export interface IAuthToken {
10
10
  type?: string;
11
11
  provider?: string;
12
12
  }
13
- /** The request a hook is asked about: the repository `paths`, the method, and the final URL with its query. */
13
+ /** What `onUnauthorized` is told besides the request: `attempt` is 1 for the first 401, 2 for the retry's own. */
14
+ export interface IHttpUnauthorizedInfo {
15
+ attempt: number;
16
+ }
17
+ /** The request a hook is asked about, the SAME object for every hook and every send of one call (a session map may key on it): the repository `paths`, the method, and the final URL with its query. */
14
18
  export interface IHttpRequestContext {
15
19
  paths: Array<string>;
16
20
  method: string;
@@ -18,10 +22,6 @@ export interface IHttpRequestContext {
18
22
  /** The call's own signal: a hook may stop waiting on it. A refresh shared by other calls should not be aborted by one. */
19
23
  signal?: AbortSignal;
20
24
  }
21
- /** `undefined` means no token for this request. A throw fails the request with that error. */
22
- export type TAuthTokenResolver = (context: IHttpRequestContext) => IAuthToken | undefined;
23
- /** Headers for this request. A throw fails the request with that error. */
24
- export type THttpHeadersResolver = (context: IHttpRequestContext) => THttpHeaders | undefined;
25
25
  /** Not `Record` alone: header names are case-insensitive, and an object merge appends two spellings. */
26
26
  export type THttpHeaders = Headers | Array<[string, string]> | Record<string, string>;
27
27
  /**
@@ -46,22 +46,21 @@ export interface IHttpDataSourceSettings {
46
46
  /** Sent on every request. `x-request-count` is refused - the connector owns it. */
47
47
  headers?: THttpHeaders;
48
48
  /**
49
- * Run on every send, the 401 retry included. Wins over `headers`; a call's own headers win over
50
- * it. `x-request-count` is refused here too; an `authorization` here stands only when no token is
51
- * resolved.
49
+ * Headers for this request, run on every send (the 401 retry included); wins over `headers`, a call's own win over it. A throw
50
+ * fails the request; `x-request-count` is refused, and an `authorization` stands only when no token resolves.
52
51
  */
53
- headersResolver?: THttpHeadersResolver;
52
+ headersResolver?: (context: IHttpRequestContext) => THttpHeaders | undefined;
54
53
  /** Wins over `authTokenResolver`, and is sent whatever the request. */
55
54
  authToken?: IAuthToken;
56
- /** Run on every send, the 401 retry included. */
57
- authTokenResolver?: TAuthTokenResolver;
58
- /** Runs on a 401: `true` retries once (re-resolving the token), `false` lets the 401 stand. */
59
- onUnauthorized?: (context: IHttpRequestContext) => Promise<boolean> | boolean;
55
+ /** Run on every send, the 401 retry included. `undefined` means no token for this request. A throw fails the request with that error. */
56
+ authTokenResolver?: (context: IHttpRequestContext) => IAuthToken | undefined;
57
+ /** Runs on a 401: `true` retries once (re-resolving the token), `false` lets the 401 stand. `context` is the object the resolvers got for this call; `info.attempt` says which send failed. */
58
+ onUnauthorized?: (context: IHttpRequestContext, info: IHttpUnauthorizedInfo) => Promise<boolean> | boolean;
60
59
  /** What sends a request: the platform `fetch` when unset. Name one to route through a test double, a proxy or an instrumented client. */
61
60
  fetch?: THttpFetch;
62
61
  }
63
- /** The part of `fetch` the data source uses: a URL and its init, a `Response` back. */
64
- export type THttpFetch = (url: string, init: RequestInit) => Promise<Response>;
62
+ /** What sends a request: a URL and its init, a `Response` back. The public name of the sender type. */
63
+ export type THttpFetch = TNativeFetchSender;
65
64
  /** A list with no `Content-Range` has no total - `hasRange` says so rather than using the page size. */
66
65
  export interface IHttpReadResult<R> {
67
66
  data: R;
@@ -81,10 +80,6 @@ export interface IHttpWriteResult<R> {
81
80
  /** What the route answered beside the rows, when the server marked it with `x-response-extra`. */
82
81
  extra?: Record<string, unknown>;
83
82
  }
84
- /** The query a repository call sends: an optional `filter` typed against the entity `E`. */
85
- export type THttpQuery<E extends object> = {
86
- filter?: TFilter<E>;
87
- };
88
83
  /** Query parameters a route takes beside `filter` or `where` - a keyword, a scope. The filter and `where` win over a key of the same name. */
89
84
  export type THttpExtraQuery = Record<string, unknown>;
90
85
  /** What the IGNIS search route answers: the total as `found` (`isFoundExact` is false when it is an estimate) and the hits. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/http/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TFilter } from '@venizia/ignis-filter';\n\n/** A credential the HTTP datasource attaches to a request: `Authorization: <type> <value>`, and `provider`, when set, as the `x-auth-provider` header. */\nexport interface IAuthToken {\n value: string;\n /**\n * The authorization scheme.\n *\n * @default 'Bearer'\n */\n type?: string;\n provider?: string;\n}\n\n/** The request a hook is asked about: the repository `paths`, the method, and the final URL with its query. */\nexport interface IHttpRequestContext {\n paths: Array<string>;\n method: string;\n url: string;\n /** The call's own signal: a hook may stop waiting on it. A refresh shared by other calls should not be aborted by one. */\n signal?: AbortSignal;\n}\n\n/** `undefined` means no token for this request. A throw fails the request with that error. */\nexport type TAuthTokenResolver = (context: IHttpRequestContext) => IAuthToken | undefined;\n\n/** Headers for this request. A throw fails the request with that error. */\nexport type THttpHeadersResolver = (context: IHttpRequestContext) => THttpHeaders | undefined;\n\n/** Not `Record` alone: header names are case-insensitive, and an object merge appends two spellings. */\nexport type THttpHeaders = Headers | Array<[string, string]> | Record<string, string>;\n\n/**\n * A request body. A plain object or array goes out as JSON; a string, `Blob`, `FormData`,\n * `URLSearchParams`, `ArrayBuffer` or typed array goes out as it is. Never a stream: the 401 retry\n * sends the same body twice.\n */\nexport type THttpBody = string | object;\n\n/** The list-extras request and result types live with the server contract, in kernel. */\nexport type { TExtraRequest, TExtraResult } from '@venizia/ignis-kernel/repository';\n\n/** What one call may add: its own headers (they win over the configured ones) and a signal to abort it. */\nexport interface IHttpCallOptions {\n headers?: THttpHeaders;\n signal?: AbortSignal;\n}\n\n/** Settings of the HTTP datasource: where to send, which headers and token to attach, and what to do on a 401. */\nexport interface IHttpDataSourceSettings {\n /** An absolute URL, or a path from the page origin (`/api`). A path-relative one is refused. */\n baseUrl: string;\n\n /** The server's `error.rootKey`: an error envelope wrapped under it is unwrapped before it is read. */\n errorRootKey?: string;\n\n /** Sent on every request. `x-request-count` is refused - the connector owns it. */\n headers?: THttpHeaders;\n\n /**\n * Run on every send, the 401 retry included. Wins over `headers`; a call's own headers win over\n * it. `x-request-count` is refused here too; an `authorization` here stands only when no token is\n * resolved.\n */\n headersResolver?: THttpHeadersResolver;\n\n /** Wins over `authTokenResolver`, and is sent whatever the request. */\n authToken?: IAuthToken;\n\n /** Run on every send, the 401 retry included. */\n authTokenResolver?: TAuthTokenResolver;\n\n /** Runs on a 401: `true` retries once (re-resolving the token), `false` lets the 401 stand. */\n onUnauthorized?: (context: IHttpRequestContext) => Promise<boolean> | boolean;\n\n /** What sends a request: the platform `fetch` when unset. Name one to route through a test double, a proxy or an instrumented client. */\n fetch?: THttpFetch;\n}\n\n/** The part of `fetch` the data source uses: a URL and its init, a `Response` back. */\nexport type THttpFetch = (url: string, init: RequestInit) => Promise<Response>;\n\n/** A list with no `Content-Range` has no total - `hasRange` says so rather than using the page size. */\nexport interface IHttpReadResult<R> {\n data: R;\n hasRange: boolean;\n /** Raw header: tells a present-but-unreadable one from an absent one. */\n contentRange?: string;\n total?: number;\n skip?: number;\n dataLength: number;\n /** What a list answered beside its rows, when the server marked it with `x-response-extra`. */\n extra?: Record<string, unknown>;\n}\n\n/** What a write answers: the rows the server returned, and its `x-response-count`. */\nexport interface IHttpWriteResult<R> {\n data: R;\n count: number;\n /** What the route answered beside the rows, when the server marked it with `x-response-extra`. */\n extra?: Record<string, unknown>;\n}\n\n/** The query a repository call sends: an optional `filter` typed against the entity `E`. */\nexport type THttpQuery<E extends object> = { filter?: TFilter<E> };\n\n/** Query parameters a route takes beside `filter` or `where` - a keyword, a scope. The filter and `where` win over a key of the same name. */\nexport type THttpExtraQuery = Record<string, unknown>;\n\n/** What the IGNIS search route answers: the total as `found` (`isFoundExact` is false when it is an estimate) and the hits. */\nexport interface IHttpSearchResult<R> {\n found: number;\n isFoundExact: boolean;\n hits: Array<{ document: R; score?: number; highlight?: unknown; highlights?: Array<unknown> }>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/http/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TNativeFetchSender } from '@venizia/ignis-helpers/core';\n\n/** A credential the HTTP datasource attaches to a request: `Authorization: <type> <value>`, and `provider`, when set, as the `x-auth-provider` header. */\nexport interface IAuthToken {\n value: string;\n /**\n * The authorization scheme.\n *\n * @default 'Bearer'\n */\n type?: string;\n provider?: string;\n}\n\n/** What `onUnauthorized` is told besides the request: `attempt` is 1 for the first 401, 2 for the retry's own. */\nexport interface IHttpUnauthorizedInfo {\n attempt: number;\n}\n\n/** The request a hook is asked about, the SAME object for every hook and every send of one call (a session map may key on it): the repository `paths`, the method, and the final URL with its query. */\nexport interface IHttpRequestContext {\n paths: Array<string>;\n method: string;\n url: string;\n /** The call's own signal: a hook may stop waiting on it. A refresh shared by other calls should not be aborted by one. */\n signal?: AbortSignal;\n}\n\n/** Not `Record` alone: header names are case-insensitive, and an object merge appends two spellings. */\nexport type THttpHeaders = Headers | Array<[string, string]> | Record<string, string>;\n\n/**\n * A request body. A plain object or array goes out as JSON; a string, `Blob`, `FormData`,\n * `URLSearchParams`, `ArrayBuffer` or typed array goes out as it is. Never a stream: the 401 retry\n * sends the same body twice.\n */\nexport type THttpBody = string | object;\n\n/** The list-extras request and result types live with the server contract, in kernel. */\nexport type { TExtraRequest, TExtraResult } from '@venizia/ignis-kernel/repository';\n\n/** What one call may add: its own headers (they win over the configured ones) and a signal to abort it. */\nexport interface IHttpCallOptions {\n headers?: THttpHeaders;\n signal?: AbortSignal;\n}\n\n/** Settings of the HTTP datasource: where to send, which headers and token to attach, and what to do on a 401. */\nexport interface IHttpDataSourceSettings {\n /** An absolute URL, or a path from the page origin (`/api`). A path-relative one is refused. */\n baseUrl: string;\n\n /** The server's `error.rootKey`: an error envelope wrapped under it is unwrapped before it is read. */\n errorRootKey?: string;\n\n /** Sent on every request. `x-request-count` is refused - the connector owns it. */\n headers?: THttpHeaders;\n\n /**\n * Headers for this request, run on every send (the 401 retry included); wins over `headers`, a call's own win over it. A throw\n * fails the request; `x-request-count` is refused, and an `authorization` stands only when no token resolves.\n */\n headersResolver?: (context: IHttpRequestContext) => THttpHeaders | undefined;\n\n /** Wins over `authTokenResolver`, and is sent whatever the request. */\n authToken?: IAuthToken;\n\n /** Run on every send, the 401 retry included. `undefined` means no token for this request. A throw fails the request with that error. */\n authTokenResolver?: (context: IHttpRequestContext) => IAuthToken | undefined;\n\n /** Runs on a 401: `true` retries once (re-resolving the token), `false` lets the 401 stand. `context` is the object the resolvers got for this call; `info.attempt` says which send failed. */\n onUnauthorized?: (\n context: IHttpRequestContext,\n info: IHttpUnauthorizedInfo,\n ) => Promise<boolean> | boolean;\n\n /** What sends a request: the platform `fetch` when unset. Name one to route through a test double, a proxy or an instrumented client. */\n fetch?: THttpFetch;\n}\n\n/** What sends a request: a URL and its init, a `Response` back. The public name of the sender type. */\nexport type THttpFetch = TNativeFetchSender;\n\n/** A list with no `Content-Range` has no total - `hasRange` says so rather than using the page size. */\nexport interface IHttpReadResult<R> {\n data: R;\n hasRange: boolean;\n /** Raw header: tells a present-but-unreadable one from an absent one. */\n contentRange?: string;\n total?: number;\n skip?: number;\n dataLength: number;\n /** What a list answered beside its rows, when the server marked it with `x-response-extra`. */\n extra?: Record<string, unknown>;\n}\n\n/** What a write answers: the rows the server returned, and its `x-response-count`. */\nexport interface IHttpWriteResult<R> {\n data: R;\n count: number;\n /** What the route answered beside the rows, when the server marked it with `x-response-extra`. */\n extra?: Record<string, unknown>;\n}\n\n/** Query parameters a route takes beside `filter` or `where` - a keyword, a scope. The filter and `where` win over a key of the same name. */\nexport type THttpExtraQuery = Record<string, unknown>;\n\n/** What the IGNIS search route answers: the total as `found` (`isFoundExact` is false when it is an estimate) and the hits. */\nexport interface IHttpSearchResult<R> {\n found: number;\n isFoundExact: boolean;\n hits: Array<{ document: R; score?: number; highlight?: unknown; highlights?: Array<unknown> }>;\n}\n"]}
@@ -21,11 +21,6 @@ export declare class HttpWire {
21
21
  entries: Array<[string, string]>;
22
22
  name: string;
23
23
  }): void;
24
- /** `baseUrl` (no trailing slash) followed by each path with one leading slash: `('/api/', ['a', '/b'])` is `/api/a/b`. */
25
- static toRequestUrl(opts: {
26
- baseUrl: string;
27
- paths: Array<string>;
28
- }): string;
29
24
  /**
30
25
  * The body as `fetch` takes it. Anything `fetch` already sends as a body passes through untouched;
31
26
  * any other object is JSON. Serialised ONCE, so the 401 retry sends the same bytes.
@@ -41,12 +41,6 @@ export class HttpWire {
41
41
  });
42
42
  }
43
43
  }
44
- /** `baseUrl` (no trailing slash) followed by each path with one leading slash: `('/api/', ['a', '/b'])` is `/api/a/b`. */
45
- static toRequestUrl(opts) {
46
- const { baseUrl, paths } = opts;
47
- const base = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
48
- return `${base}${paths.map((path) => (path.startsWith('/') ? path : `/${path}`)).join('')}`;
49
- }
50
44
  /**
51
45
  * The body as `fetch` takes it. Anything `fetch` already sends as a body passes through untouched;
52
46
  * any other object is JSON. Serialised ONCE, so the 401 retry sends the same bytes.
@@ -1 +1 @@
1
- {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../../src/http/common/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACnB;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,CAAC,IAAgC;QACrD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GACV,OAAO,YAAY,OAAO;YACxB,CAAC,C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ItB;QACC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;QACnD,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAEtE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,WAAW,GAAqB,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAEvE,OAAO,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,IAAsC;QACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC7B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAElC,MAAM,SAAS,GACb,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;YAC3C,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,2BAA2B,CAAC;QAE/D,OAAO,SAAS;YACd,CAAC,CAAC,GAAG,QAAQ,KAAK,GAAG,CAAC,MAAM,gGAAgG;YAC5H,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC;CACF","sourcesContent":["import { HttpReadShapes, type THttpReadShape } from './constants';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HttpExtraRequest } from '@venizia/ignis-kernel/repository';\nimport type { TExtraRequest, THttpBody, THttpHeaders } from './types';\n\n/**\n * What `HttpDataSource` puts on the wire and reads back off it: headers, request bodies, rows and\n * the path an error message names. Internal - not part of the `http` entry.\n */\nexport class HttpWire {\n /**\n * Caller headers as unique lowercase pairs, last spelling winning.\n *\n * Never `new Headers(input)`: that constructor APPENDS, so `{ 'X-Tenant': 'north', 'x-tenant':\n * 'south' }` - which a merge of two config objects produces - reaches the wire as `\"north, south\"`,\n * a value neither caller wrote. A `Headers` instance arrives already joined; that one is the\n * caller's own, and is passed through as it stands.\n */\n static toHeaderEntries(opts: { headers?: THttpHeaders }): Array<[string, string]> {\n const { headers } = opts;\n\n if (!headers) {\n return [];\n }\n\n const source =\n headers instanceof Headers\n ? [...headers.entries()]\n : Array.isArray(headers)\n ? headers\n : Object.entries(headers);\n\n const merged = new Map<string, string>();\n\n for (const [name, value] of source) {\n merged.set(name.toLowerCase(), value);\n }\n\n return [...merged.entries()];\n }\n\n /** The connector always sends `x-request-count: false`; a caller header carrying it would contradict that. */\n static assertNoRequestCountHeader(opts: {\n entries: Array<[string, string]>;\n name: string;\n }): void {\n const { entries, name } = opts;\n\n if (entries.some(([headerName]) => headerName === HTTP.Headers.REQUEST_COUNT_DATA)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${name}] ${HTTP.Headers.REQUEST_COUNT_DATA} is owned by HttpDataSource and always sent as false: rows come back bare, the total in Content-Range.`,\n });\n }\n }\n\n /** `baseUrl` (no trailing slash) followed by each path with one leading slash: `('/api/', ['a', '/b'])` is `/api/a/b`. */\n static toRequestUrl(opts: { baseUrl: string; paths: Array<string> }): string {\n const { baseUrl, paths } = opts;\n const base = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;\n\n return `${base}${paths.map((path) => (path.startsWith('/') ? path : `/${path}`)).join('')}`;\n }\n\n /**\n * The body as `fetch` takes it. Anything `fetch` already sends as a body passes through untouched;\n * any other object is JSON. Serialised ONCE, so the 401 retry sends the same bytes.\n */\n static toRequestBody(opts: { body?: THttpBody }): {\n payload: RequestInit['body'];\n isJson: boolean;\n isFormData: boolean;\n } {\n const { body } = opts;\n\n if (body === undefined) {\n return { payload: undefined, isJson: false, isFormData: false };\n }\n\n const isFormData = body instanceof FormData;\n const isSentAsIs =\n isFormData ||\n typeof body === 'string' ||\n body instanceof Blob ||\n body instanceof URLSearchParams ||\n body instanceof ArrayBuffer;\n\n if (isSentAsIs) {\n return { payload: body, isJson: false, isFormData };\n }\n\n // A typed array may sit on a SharedArrayBuffer, which `fetch` refuses; a Blob copy never does.\n if (ArrayBuffer.isView(body)) {\n return {\n payload: new Blob([new Uint8Array(body.buffer, body.byteOffset, body.byteLength).slice()]),\n isJson: false,\n isFormData: false,\n };\n }\n\n return {\n payload: HttpWire.toJson({ value: body, label: 'The request body' }),\n isJson: true,\n isFormData: false,\n };\n }\n\n /** JSON, or a 400 naming what failed: a bigint or a cycle would otherwise escape as a bare TypeError. */\n static toJson(opts: { value: unknown; label: string }): string {\n const { value, label } = opts;\n\n try {\n return JSON.stringify(value);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `${label} cannot be sent as JSON | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n\n /**\n * A list is a bare array or the `{ count, data }` envelope; `one` is never unwrapped, since a record\n * may carry `data` and `count` columns. The envelope `count` is the page size, never the total.\n *\n * Anything else asked for as a list throws: counting it as one row is how `existsWith` answers true\n * for an empty result and a page reports a length it does not have.\n */\n static unwrapRows<R>(opts: { body: unknown; shape: THttpReadShape; url: string }): R {\n const { body, shape, url } = opts;\n\n if (shape === HttpReadShapes.ONE || Array.isArray(body)) {\n return body as R;\n }\n\n if (body && typeof body === 'object' && 'data' in body && 'count' in body) {\n return (body as { data: R }).data;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[read] A list was asked for and the response is neither an array nor a { count, data } envelope | ${HttpWire.describeUrl({ url })}`,\n });\n }\n\n /**\n * The call's headers plus `x-request-extra` for the extras it asks for - `name`, `-name`,\n * `name(key,key)` - and `-*` first when it wants the rows alone, with every default off.\n */\n static withExtraHeader(opts: {\n headers?: THttpHeaders;\n extra?: TExtraRequest;\n isEveryDefaultOff?: boolean;\n }): THttpHeaders | undefined {\n const { headers, extra, isEveryDefaultOff } = opts;\n const value = HttpExtraRequest.toHeader({ extra, isEveryDefaultOff });\n\n if (value === undefined) {\n return headers;\n }\n\n const extraHeader: [string, string] = [HttpExtraRequest.HEADER, value];\n\n return [...HttpWire.toHeaderEntries({ headers }), extraHeader];\n }\n\n /**\n * The path a message names - never the host or the query. A server that relays this error would\n * otherwise send an internal host and a filter's values to its own clients. 414/431 add the length.\n */\n static describeUrl(opts: { url: string; status?: number }): string {\n const { url, status } = opts;\n const { pathname } = new URL(url);\n\n const isTooLong =\n status === HTTP.ResultCodes.RS_4.URITooLong ||\n status === HTTP.ResultCodes.RS_4.RequestHeaderFieldsTooLarge;\n\n return isTooLong\n ? `${pathname} (${url.length} chars) | The URL is too long for a GET - split the filter (a long inq) into smaller requests.`\n : pathname;\n }\n}\n"]}
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../../src/http/common/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACnB;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,CAAC,IAAgC;QACrD,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GACV,OAAO,YAAY,OAAO;YACxB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;YACxB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;gBACtB,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,MAAM,CAAC,OAAO,CA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AU;YAC3C,MAAM,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,2BAA2B,CAAC;QAE/D,OAAO,SAAS;YACd,CAAC,CAAC,GAAG,QAAQ,KAAK,GAAG,CAAC,MAAM,gGAAgG;YAC5H,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC;CACF","sourcesContent":["import { HttpReadShapes, type THttpReadShape } from './constants';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HttpExtraRequest } from '@venizia/ignis-kernel/repository';\nimport type { TExtraRequest, THttpBody, THttpHeaders } from './types';\n\n/**\n * What `HttpDataSource` puts on the wire and reads back off it: headers, request bodies, rows and\n * the path an error message names. Internal - not part of the `http` entry.\n */\nexport class HttpWire {\n /**\n * Caller headers as unique lowercase pairs, last spelling winning.\n *\n * Never `new Headers(input)`: that constructor APPENDS, so `{ 'X-Tenant': 'north', 'x-tenant':\n * 'south' }` - which a merge of two config objects produces - reaches the wire as `\"north, south\"`,\n * a value neither caller wrote. A `Headers` instance arrives already joined; that one is the\n * caller's own, and is passed through as it stands.\n */\n static toHeaderEntries(opts: { headers?: THttpHeaders }): Array<[string, string]> {\n const { headers } = opts;\n\n if (!headers) {\n return [];\n }\n\n const source =\n headers instanceof Headers\n ? [...headers.entries()]\n : Array.isArray(headers)\n ? headers\n : Object.entries(headers);\n\n const merged = new Map<string, string>();\n\n for (const [name, value] of source) {\n merged.set(name.toLowerCase(), value);\n }\n\n return [...merged.entries()];\n }\n\n /** The connector always sends `x-request-count: false`; a caller header carrying it would contradict that. */\n static assertNoRequestCountHeader(opts: {\n entries: Array<[string, string]>;\n name: string;\n }): void {\n const { entries, name } = opts;\n\n if (entries.some(([headerName]) => headerName === HTTP.Headers.REQUEST_COUNT_DATA)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${name}] ${HTTP.Headers.REQUEST_COUNT_DATA} is owned by HttpDataSource and always sent as false: rows come back bare, the total in Content-Range.`,\n });\n }\n }\n\n /**\n * The body as `fetch` takes it. Anything `fetch` already sends as a body passes through untouched;\n * any other object is JSON. Serialised ONCE, so the 401 retry sends the same bytes.\n */\n static toRequestBody(opts: { body?: THttpBody }): {\n payload: RequestInit['body'];\n isJson: boolean;\n isFormData: boolean;\n } {\n const { body } = opts;\n\n if (body === undefined) {\n return { payload: undefined, isJson: false, isFormData: false };\n }\n\n const isFormData = body instanceof FormData;\n const isSentAsIs =\n isFormData ||\n typeof body === 'string' ||\n body instanceof Blob ||\n body instanceof URLSearchParams ||\n body instanceof ArrayBuffer;\n\n if (isSentAsIs) {\n return { payload: body, isJson: false, isFormData };\n }\n\n // A typed array may sit on a SharedArrayBuffer, which `fetch` refuses; a Blob copy never does.\n if (ArrayBuffer.isView(body)) {\n return {\n payload: new Blob([new Uint8Array(body.buffer, body.byteOffset, body.byteLength).slice()]),\n isJson: false,\n isFormData: false,\n };\n }\n\n return {\n payload: HttpWire.toJson({ value: body, label: 'The request body' }),\n isJson: true,\n isFormData: false,\n };\n }\n\n /** JSON, or a 400 naming what failed: a bigint or a cycle would otherwise escape as a bare TypeError. */\n static toJson(opts: { value: unknown; label: string }): string {\n const { value, label } = opts;\n\n try {\n return JSON.stringify(value);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `${label} cannot be sent as JSON | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n\n /**\n * A list is a bare array or the `{ count, data }` envelope; `one` is never unwrapped, since a record\n * may carry `data` and `count` columns. The envelope `count` is the page size, never the total.\n *\n * Anything else asked for as a list throws: counting it as one row is how `existsWith` answers true\n * for an empty result and a page reports a length it does not have.\n */\n static unwrapRows<R>(opts: { body: unknown; shape: THttpReadShape; url: string }): R {\n const { body, shape, url } = opts;\n\n if (shape === HttpReadShapes.ONE || Array.isArray(body)) {\n return body as R;\n }\n\n if (body && typeof body === 'object' && 'data' in body && 'count' in body) {\n return (body as { data: R }).data;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[read] A list was asked for and the response is neither an array nor a { count, data } envelope | ${HttpWire.describeUrl({ url })}`,\n });\n }\n\n /**\n * The call's headers plus `x-request-extra` for the extras it asks for - `name`, `-name`,\n * `name(key,key)` - and `-*` first when it wants the rows alone, with every default off.\n */\n static withExtraHeader(opts: {\n headers?: THttpHeaders;\n extra?: TExtraRequest;\n isEveryDefaultOff?: boolean;\n }): THttpHeaders | undefined {\n const { headers, extra, isEveryDefaultOff } = opts;\n const value = HttpExtraRequest.toHeader({ extra, isEveryDefaultOff });\n\n if (value === undefined) {\n return headers;\n }\n\n const extraHeader: [string, string] = [HttpExtraRequest.HEADER, value];\n\n return [...HttpWire.toHeaderEntries({ headers }), extraHeader];\n }\n\n /**\n * The path a message names - never the host or the query. A server that relays this error would\n * otherwise send an internal host and a filter's values to its own clients. 414/431 add the length.\n */\n static describeUrl(opts: { url: string; status?: number }): string {\n const { url, status } = opts;\n const { pathname } = new URL(url);\n\n const isTooLong =\n status === HTTP.ResultCodes.RS_4.URITooLong ||\n status === HTTP.ResultCodes.RS_4.RequestHeaderFieldsTooLarge;\n\n return isTooLong\n ? `${pathname} (${url.length} chars) | The URL is too long for a GET - split the filter (a long inq) into smaller requests.`\n : pathname;\n }\n}\n"]}
@@ -8,8 +8,6 @@ export declare class HttpDataSource extends DataSourceRoot<IHttpDataSourceSettin
8
8
  schema: never;
9
9
  /** Normalised once: every request copies these, never re-parses `settings.headers`. */
10
10
  protected configuredHeaders: Array<[string, string]>;
11
- /** Decided once: a relative baseUrl (`/api`) is resolved against the page origin on every request. */
12
- protected isRelativeBaseUrl: boolean;
13
11
  constructor(opts: IHttpDataSourceSettings & {
14
12
  name?: string;
15
13
  });
@@ -30,21 +28,6 @@ export declare class HttpDataSource extends DataSourceRoot<IHttpDataSourceSettin
30
28
  isJsonBody?: boolean;
31
29
  isFormDataBody?: boolean;
32
30
  }): Headers;
33
- /** The browser global `location` is not declared for a server build, so it is probed, not assumed. */
34
- protected resolveLocationOrigin(): string | undefined;
35
- /** The path as an error message quotes it: cut at 200 characters, with an ellipsis. */
36
- protected static toEchoedPath(opts: {
37
- path: string;
38
- }): string;
39
- /** The request paths name a place under the base path, so none may be a dot segment, hide one, or carry a separator the URL parser would read differently from a server. */
40
- protected assertPathsStayUnderBase(opts: {
41
- paths: Array<string>;
42
- }): void;
43
- /** The resolved URL, whatever built it, is on the base's origin and under its path: the check that holds when the text checks above miss a form. */
44
- protected assertUnderBase(opts: {
45
- url: URL;
46
- origin?: string;
47
- }): void;
48
31
  buildUrl(opts: {
49
32
  paths: Array<string>;
50
33
  query?: Record<string, unknown>;
@@ -1,20 +1,9 @@
1
- import { EchoUtility } from '../common/internal/index.js';
2
- import { HttpReadShapes } from './common/constants.js';
1
+ import { HttpReadShapes, HttpWireHeaders } from './common/constants.js';
3
2
  import { DataSourceRoot } from '@venizia/ignis-kernel/repository';
4
3
  import { HTTP } from '@venizia/ignis-helpers/common';
5
- import { getError } from '@venizia/ignis-helpers/core';
4
+ import { NativeFetcher, UrlBuilder, UrlFetchError } from '@venizia/ignis-helpers/core';
6
5
  import { HttpResponseReader } from './common/readers.js';
7
6
  import { HttpWire } from './common/wire.js';
8
- /** A scheme and `//` make a URL absolute - `localhost:3000` has neither. Read by pattern: `URL.canParse` needs Safari 17 or Chrome 120, and this runs in pages. */
9
- const ABSOLUTE_URL_PATTERN = /^[a-z][a-z\d+.-]*:\/\//i;
10
- /** A backslash is a separator to the URL parser, and a control character (a tab or a newline inside `.<TAB>.`) is dropped by it: neither may hide a dot segment. `%5c` is the encoded backslash. */
11
- const UNSAFE_REQUEST_PATH_PATTERN = /[\p{Cc}\\]|%5c/iu;
12
- /** What ends a path segment for the URL parser: a slash, a `?` or a `#` (it ends the path itself, so `..?` is a `..` segment), and the encoded slash, which a server may decode into a separator. */
13
- const REQUEST_PATH_SEPARATOR_PATTERN = /[/?#]|%2f/i;
14
- /** The longest part of a refused path an error message copies: a huge path is not copied whole into the error and the log. */
15
- const MAX_ECHOED_PATH_LENGTH = 200;
16
- /** A segment that is `.` or `..` once its `%2e` is decoded. */
17
- const DOT_SEGMENT_PATTERN = /^(?:\.|%2e){1,2}$/i;
18
7
  /** Reads an IGNIS REST server through the repository contract. Targets IGNIS, not any REST API. */
19
8
  export class HttpDataSource extends DataSourceRoot {
20
9
  constructor(opts) {
@@ -23,21 +12,7 @@ export class HttpDataSource extends DataSourceRoot {
23
12
  const { name = 'http', ...settings } = opts;
24
13
  const configured = HttpWire.toHeaderEntries({ headers: settings.headers });
25
14
  HttpWire.assertNoRequestCountHeader({ entries: configured, name });
26
- this.isRelativeBaseUrl = !ABSOLUTE_URL_PATTERN.test(settings.baseUrl);
27
- // Against the page, `api` would follow the current route; `localhost:3000` is not a URL at all.
28
- if (this.isRelativeBaseUrl && !settings.baseUrl.startsWith('/')) {
29
- throw getError({
30
- statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
31
- message: `[${name}] baseUrl '${settings.baseUrl}' is neither absolute nor a path from the origin | Pass '/api' or an absolute URL such as 'https://api.example.com'`,
32
- });
33
- }
34
- // A `?` or `#` in the base would swallow the request paths into the query or the fragment.
35
- if (/[?#]/.test(settings.baseUrl)) {
36
- throw getError({
37
- statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
38
- message: `[${name}] baseUrl must not carry a query or a fragment: the request paths would end up inside it | Pass the base without '?' or '#', and use the call's query option`,
39
- });
40
- }
15
+ UrlBuilder.assertBase({ baseUrl: settings.baseUrl, scope: name });
41
16
  this.configuredHeaders = configured;
42
17
  this.name = name;
43
18
  this.settings = settings;
@@ -67,7 +42,7 @@ export class HttpDataSource extends DataSourceRoot {
67
42
  headers.set(name, value);
68
43
  }
69
44
  if (isJsonBody && !headers.has(HTTP.Headers.CONTENT_TYPE)) {
70
- headers.set(HTTP.Headers.CONTENT_TYPE, 'application/json');
45
+ headers.set(HTTP.Headers.CONTENT_TYPE, HTTP.HeaderValues.APPLICATION_JSON);
71
46
  }
72
47
  // Only `fetch` knows the multipart boundary; any other content-type here would drop it.
73
48
  if (isFormDataBody) {
@@ -81,68 +56,13 @@ export class HttpDataSource extends DataSourceRoot {
81
56
  headers.set(HTTP.Headers.AUTHORIZATION, `${token.type ?? 'Bearer'} ${token.value}`);
82
57
  // Unconditionally it would send the string "undefined".
83
58
  if (token.provider) {
84
- headers.set('x-auth-provider', token.provider);
59
+ headers.set(HttpWireHeaders.AUTH_PROVIDER, token.provider);
85
60
  }
86
61
  return headers;
87
62
  }
88
- /** The browser global `location` is not declared for a server build, so it is probed, not assumed. */
89
- resolveLocationOrigin() {
90
- const location = Reflect.get(globalThis, 'location');
91
- if (typeof location !== 'object' || location === null || !('origin' in location)) {
92
- return undefined;
93
- }
94
- return typeof location.origin === 'string' ? location.origin : undefined;
95
- }
96
- /** The path as an error message quotes it: cut at 200 characters, with an ellipsis. */
97
- static toEchoedPath(opts) {
98
- const { path } = opts;
99
- return path.length > MAX_ECHOED_PATH_LENGTH
100
- ? `${path.slice(0, MAX_ECHOED_PATH_LENGTH)}…`
101
- : path;
102
- }
103
- /** The request paths name a place under the base path, so none may be a dot segment, hide one, or carry a separator the URL parser would read differently from a server. */
104
- assertPathsStayUnderBase(opts) {
105
- for (const path of opts.paths) {
106
- const segments = path.split(REQUEST_PATH_SEPARATOR_PATTERN);
107
- const isEscaping = UNSAFE_REQUEST_PATH_PATTERN.test(path) ||
108
- // A trailing space is stripped from the whole URL by the parser, so `.. ` ends as `..`.
109
- segments.some((segment) => DOT_SEGMENT_PATTERN.test(segment.trimEnd()));
110
- if (isEscaping) {
111
- throw getError({
112
- statusCode: HTTP.ResultCodes.RS_4.BadRequest,
113
- message: `[${this.name}] A request path must stay under the base path: no dot segment, backslash or control character | path: '${EchoUtility.toSafeEcho({ value: HttpDataSource.toEchoedPath({ path }) })}'`,
114
- });
115
- }
116
- }
117
- }
118
- /** The resolved URL, whatever built it, is on the base's origin and under its path: the check that holds when the text checks above miss a form. */
119
- assertUnderBase(opts) {
120
- const { url, origin } = opts;
121
- const base = new URL(this.settings.baseUrl, origin);
122
- const basePath = base.pathname.replace(/\/+$/, '');
123
- const isUnderBase = url.origin === base.origin &&
124
- (url.pathname === basePath || url.pathname.startsWith(`${basePath}/`));
125
- if (!isUnderBase) {
126
- throw getError({
127
- statusCode: HTTP.ResultCodes.RS_4.BadRequest,
128
- message: `[${this.name}] A request path must stay under the base path: the URL left the origin or the base path`,
129
- });
130
- }
131
- }
132
63
  buildUrl(opts) {
133
64
  const { paths, query } = opts;
134
- this.assertPathsStayUnderBase({ paths });
135
- const requestUrl = HttpWire.toRequestUrl({ baseUrl: this.settings.baseUrl, paths });
136
- // A page or a Web Worker has an origin to resolve '/api' against; a server has none.
137
- const origin = this.isRelativeBaseUrl ? this.resolveLocationOrigin() : undefined;
138
- if (this.isRelativeBaseUrl && !origin) {
139
- throw getError({
140
- statusCode: HTTP.ResultCodes.RS_5.InternalServerError,
141
- message: `[${this.name}] Relative baseUrl '${this.settings.baseUrl}' needs a page or worker location to resolve against, and there is none here | Pass an absolute baseUrl such as 'https://api.example.com'`,
142
- });
143
- }
144
- const url = new URL(requestUrl, origin);
145
- this.assertUnderBase({ url, origin });
65
+ const url = UrlBuilder.join({ baseUrl: this.settings.baseUrl, paths, scope: this.name });
146
66
  const parameters = Object.entries(query ?? {});
147
67
  for (const [key, value] of parameters) {
148
68
  if (value === undefined) {
@@ -169,32 +89,62 @@ export class HttpDataSource extends DataSourceRoot {
169
89
  const method = opts.method ?? HTTP.Methods.GET;
170
90
  const context = { paths: opts.paths, method, url, signal };
171
91
  const { payload, isJson, isFormData } = HttpWire.toRequestBody({ body: opts.body });
172
- // Both hooks run inside `send`, so the retry sends what they answer after the refresh.
173
- const send = () =>
174
- // The platform `fetch` unless the settings name a sender; looked up per call, so a test that swaps the global is heard.
175
- (this.settings.fetch ?? fetch)(url, {
176
- method: method.toUpperCase(),
177
- body: payload,
178
- signal,
179
- headers: this.buildHeaders({
180
- token: this.resolveAuthToken({ context }),
181
- // Resolved first, so the call's own headers win over them.
182
- requestHeaders: [...this.resolveHeaders({ context }), ...requestHeaders],
183
- isJsonBody: isJson,
184
- isFormDataBody: isFormData,
185
- }),
92
+ const { onUnauthorized } = this.settings;
93
+ // One fetcher per call: its hooks close over this call's context. Both resolvers run in `onRequest`, so the retry sends what they answer after the refresh.
94
+ const fetcher = new NativeFetcher({
95
+ name: this.name,
96
+ fetch: this.settings.fetch,
97
+ hooks: {
98
+ onRequest: ({ headers }) => {
99
+ const built = this.buildHeaders({
100
+ token: this.resolveAuthToken({ context }),
101
+ // Resolved first, so the call's own headers win over them.
102
+ requestHeaders: [...this.resolveHeaders({ context }), ...requestHeaders],
103
+ isJsonBody: isJson,
104
+ isFormDataBody: isFormData,
105
+ });
106
+ for (const name of [...headers.keys()]) {
107
+ headers.delete(name);
108
+ }
109
+ built.forEach((value, name) => headers.set(name, value));
110
+ },
111
+ },
186
112
  });
187
- let response = await send();
188
- if (response.status === HTTP.ResultCodes.RS_4.Unauthorized && this.settings.onUnauthorized) {
189
- const shouldRetry = await this.settings.onUnauthorized(context);
190
- // A call aborted while the session refreshed is not sent again.
191
- if (shouldRetry) {
192
- signal?.throwIfAborted();
193
- const result = await send();
194
- response = result;
113
+ try {
114
+ const response = await fetcher.send({
115
+ url,
116
+ method,
117
+ body: payload,
118
+ signal,
119
+ // Every status is an answer the data source reads itself; a 401 with a refresh hook throws once so the retry can see it.
120
+ acceptStatus: (status) => !onUnauthorized || status !== HTTP.ResultCodes.RS_4.Unauthorized,
121
+ retry: onUnauthorized
122
+ ? {
123
+ maxAttempts: 2,
124
+ backoff: { initialDelayMs: 0, maxDelayMs: 0 },
125
+ shouldRetry: async ({ error, attempt }) => {
126
+ if (!UrlFetchError.is(error) ||
127
+ error.status !== HTTP.ResultCodes.RS_4.Unauthorized) {
128
+ return false;
129
+ }
130
+ const isRefreshed = await onUnauthorized(context, { attempt });
131
+ // The second 401 stands: the hook hears of it, its answer is ignored, and nothing is sent a third time.
132
+ return attempt === 1 && isRefreshed;
133
+ },
134
+ }
135
+ : undefined,
136
+ });
137
+ return response;
138
+ }
139
+ catch (error) {
140
+ // The 401 that stands is the answer: the data source reads its body into its own error.
141
+ if (error instanceof UrlFetchError &&
142
+ error.status === HTTP.ResultCodes.RS_4.Unauthorized &&
143
+ error.response instanceof Response) {
144
+ return error.response;
195
145
  }
146
+ throw error;
196
147
  }
197
- return response;
198
148
  }
199
149
  /**
200
150
  * The body as JSON, `null` when there is none; a body that is not JSON is the server's fault, named
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../src/http/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAWtD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,mKAAmK;AACnK,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAEvD,oMAAoM;AACpM,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAEvD,qMAAqM;AACrM,MAAM,8BAA8B,GAAG,YAAY,CAAC;AAEpD,8HAA8H;AAC9H,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,mGAAmG;AACnG,MAAM,OAAO,cAAe,SAAQ,cAAuC;IAUzE,YAAY,IAAiD;QAC3D,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;QAR5C,WAAM,G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T,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { EchoUtility } from '@/common/internal';\nimport { HttpReadShapes, type THttpReadShape } from './common/constants';\nimport { DataSourceRoot } from '@venizia/ignis-kernel/repository';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HttpResponseReader } from './common/readers';\nimport type {\n IAuthToken,\n IHttpCallOptions,\n IHttpDataSourceSettings,\n TExtraRequest,\n IHttpReadResult,\n IHttpRequestContext,\n IHttpWriteResult,\n THttpBody,\n} from './common/types';\nimport { HttpWire } from './common/wire';\n\n/** A scheme and `//` make a URL absolute - `localhost:3000` has neither. Read by pattern: `URL.canParse` needs Safari 17 or Chrome 120, and this runs in pages. */\nconst ABSOLUTE_URL_PATTERN = /^[a-z][a-z\\d+.-]*:\\/\\//i;\n\n/** A backslash is a separator to the URL parser, and a control character (a tab or a newline inside `.<TAB>.`) is dropped by it: neither may hide a dot segment. `%5c` is the encoded backslash. */\nconst UNSAFE_REQUEST_PATH_PATTERN = /[\\p{Cc}\\\\]|%5c/iu;\n\n/** What ends a path segment for the URL parser: a slash, a `?` or a `#` (it ends the path itself, so `..?` is a `..` segment), and the encoded slash, which a server may decode into a separator. */\nconst REQUEST_PATH_SEPARATOR_PATTERN = /[/?#]|%2f/i;\n\n/** The longest part of a refused path an error message copies: a huge path is not copied whole into the error and the log. */\nconst MAX_ECHOED_PATH_LENGTH = 200;\n\n/** A segment that is `.` or `..` once its `%2e` is decoded. */\nconst DOT_SEGMENT_PATTERN = /^(?:\\.|%2e){1,2}$/i;\n\n/** Reads an IGNIS REST server through the repository contract. Targets IGNIS, not any REST API. */\nexport class HttpDataSource extends DataSourceRoot<IHttpDataSourceSettings> {\n override name: string;\n override settings: IHttpDataSourceSettings;\n override schema = {} as never;\n\n /** Normalised once: every request copies these, never re-parses `settings.headers`. */\n protected configuredHeaders: Array<[string, string]>;\n /** Decided once: a relative baseUrl (`/api`) is resolved against the page origin on every request. */\n protected isRelativeBaseUrl: boolean;\n\n constructor(opts: IHttpDataSourceSettings & { name?: string }) {\n super({ scope: opts.name ?? HttpDataSource.name });\n\n const { name = 'http', ...settings } = opts;\n\n const configured = HttpWire.toHeaderEntries({ headers: settings.headers });\n HttpWire.assertNoRequestCountHeader({ entries: configured, name });\n\n this.isRelativeBaseUrl = !ABSOLUTE_URL_PATTERN.test(settings.baseUrl);\n\n // Against the page, `api` would follow the current route; `localhost:3000` is not a URL at all.\n if (this.isRelativeBaseUrl && !settings.baseUrl.startsWith('/')) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${name}] baseUrl '${settings.baseUrl}' is neither absolute nor a path from the origin | Pass '/api' or an absolute URL such as 'https://api.example.com'`,\n });\n }\n\n // A `?` or `#` in the base would swallow the request paths into the query or the fragment.\n if (/[?#]/.test(settings.baseUrl)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${name}] baseUrl must not carry a query or a fragment: the request paths would end up inside it | Pass the base without '?' or '#', and use the call's query option`,\n });\n }\n\n this.configuredHeaders = configured;\n this.name = name;\n this.settings = settings;\n }\n\n async configure(): Promise<void> {}\n\n override getCapabilities() {\n return { transactions: false };\n }\n\n protected resolveAuthToken(opts: { context: IHttpRequestContext }): IAuthToken | undefined {\n return this.settings.authToken ?? this.settings.authTokenResolver?.(opts.context);\n }\n\n /** Re-run on every send, so a header the app changed since the last request is the one sent. */\n protected resolveHeaders(opts: { context: IHttpRequestContext }): Array<[string, string]> {\n const resolver = this.settings.headersResolver;\n\n if (!resolver) {\n return [];\n }\n\n const entries = HttpWire.toHeaderEntries({ headers: resolver(opts.context) });\n HttpWire.assertNoRequestCountHeader({ entries, name: this.name });\n\n return entries;\n }\n\n protected buildHeaders(opts: {\n token?: IAuthToken;\n requestHeaders?: Array<[string, string]>;\n isJsonBody?: boolean;\n isFormDataBody?: boolean;\n }): Headers {\n const { token, requestHeaders, isJsonBody, isFormDataBody } = opts;\n const headers = new Headers(this.configuredHeaders);\n\n // A request's own headers win over the configured ones; the connector's below win over both.\n for (const [name, value] of requestHeaders ?? []) {\n headers.set(name, value);\n }\n\n if (isJsonBody && !headers.has(HTTP.Headers.CONTENT_TYPE)) {\n headers.set(HTTP.Headers.CONTENT_TYPE, 'application/json');\n }\n\n // Only `fetch` knows the multipart boundary; any other content-type here would drop it.\n if (isFormDataBody) {\n headers.delete(HTTP.Headers.CONTENT_TYPE);\n }\n\n // Set last: under the envelope a record read answers `{ count, data }`.\n headers.set(HTTP.Headers.REQUEST_COUNT_DATA, 'false');\n\n if (!token) {\n return headers;\n }\n\n headers.set(HTTP.Headers.AUTHORIZATION, `${token.type ?? 'Bearer'} ${token.value}`);\n\n // Unconditionally it would send the string \"undefined\".\n if (token.provider) {\n headers.set('x-auth-provider', token.provider);\n }\n\n return headers;\n }\n\n /** The browser global `location` is not declared for a server build, so it is probed, not assumed. */\n protected resolveLocationOrigin(): string | undefined {\n const location: unknown = Reflect.get(globalThis, 'location');\n\n if (typeof location !== 'object' || location === null || !('origin' in location)) {\n return undefined;\n }\n\n return typeof location.origin === 'string' ? location.origin : undefined;\n }\n\n /** The path as an error message quotes it: cut at 200 characters, with an ellipsis. */\n protected static toEchoedPath(opts: { path: string }): string {\n const { path } = opts;\n\n return path.length > MAX_ECHOED_PATH_LENGTH\n ? `${path.slice(0, MAX_ECHOED_PATH_LENGTH)}…`\n : path;\n }\n\n /** The request paths name a place under the base path, so none may be a dot segment, hide one, or carry a separator the URL parser would read differently from a server. */\n protected assertPathsStayUnderBase(opts: { paths: Array<string> }): void {\n for (const path of opts.paths) {\n const segments = path.split(REQUEST_PATH_SEPARATOR_PATTERN);\n const isEscaping =\n UNSAFE_REQUEST_PATH_PATTERN.test(path) ||\n // A trailing space is stripped from the whole URL by the parser, so `.. ` ends as `..`.\n segments.some((segment) => DOT_SEGMENT_PATTERN.test(segment.trimEnd()));\n\n if (isEscaping) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[${this.name}] A request path must stay under the base path: no dot segment, backslash or control character | path: '${EchoUtility.toSafeEcho({ value: HttpDataSource.toEchoedPath({ path }) })}'`,\n });\n }\n }\n }\n\n /** The resolved URL, whatever built it, is on the base's origin and under its path: the check that holds when the text checks above miss a form. */\n protected assertUnderBase(opts: { url: URL; origin?: string }): void {\n const { url, origin } = opts;\n const base = new URL(this.settings.baseUrl, origin);\n const basePath = base.pathname.replace(/\\/+$/, '');\n const isUnderBase =\n url.origin === base.origin &&\n (url.pathname === basePath || url.pathname.startsWith(`${basePath}/`));\n\n if (!isUnderBase) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[${this.name}] A request path must stay under the base path: the URL left the origin or the base path`,\n });\n }\n }\n\n buildUrl(opts: { paths: Array<string>; query?: Record<string, unknown> }): string {\n const { paths, query } = opts;\n this.assertPathsStayUnderBase({ paths });\n\n const requestUrl = HttpWire.toRequestUrl({ baseUrl: this.settings.baseUrl, paths });\n\n // A page or a Web Worker has an origin to resolve '/api' against; a server has none.\n const origin = this.isRelativeBaseUrl ? this.resolveLocationOrigin() : undefined;\n\n if (this.isRelativeBaseUrl && !origin) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${this.name}] Relative baseUrl '${this.settings.baseUrl}' needs a page or worker location to resolve against, and there is none here | Pass an absolute baseUrl such as 'https://api.example.com'`,\n });\n }\n\n const url = new URL(requestUrl, origin);\n this.assertUnderBase({ url, origin });\n\n const parameters = Object.entries(query ?? {});\n\n for (const [key, value] of parameters) {\n if (value === undefined) {\n continue;\n }\n\n url.searchParams.set(\n key,\n typeof value === 'string'\n ? value\n : HttpWire.toJson({ value, label: `[${this.name}] Query parameter '${key}'` }),\n );\n }\n\n return url.toString();\n }\n\n /**\n * The raw `Response`, on any method - for what the repository verbs do not cover, like an export\n * or a PUT to a hand-written route. Auth and the 401 retry apply; the retry resends the same body.\n */\n async request(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n method?: string;\n body?: THttpBody;\n } & IHttpCallOptions,\n ): Promise<Response> {\n return this.sendRequest({ ...opts, url: this.buildUrl(opts) });\n }\n\n /** `request` on a URL already built: `read` and `write` serialise a long query once, not per use. */\n protected async sendRequest(\n opts: {\n paths: Array<string>;\n url: string;\n method?: string;\n body?: THttpBody;\n } & IHttpCallOptions,\n ): Promise<Response> {\n const { url, signal } = opts;\n const requestHeaders = HttpWire.toHeaderEntries({ headers: opts.headers });\n HttpWire.assertNoRequestCountHeader({ entries: requestHeaders, name: this.name });\n\n const method = opts.method ?? HTTP.Methods.GET;\n const context: IHttpRequestContext = { paths: opts.paths, method, url, signal };\n const { payload, isJson, isFormData } = HttpWire.toRequestBody({ body: opts.body });\n\n // Both hooks run inside `send`, so the retry sends what they answer after the refresh.\n const send = () =>\n // The platform `fetch` unless the settings name a sender; looked up per call, so a test that swaps the global is heard.\n (this.settings.fetch ?? fetch)(url, {\n method: method.toUpperCase(),\n body: payload,\n signal,\n headers: this.buildHeaders({\n token: this.resolveAuthToken({ context }),\n // Resolved first, so the call's own headers win over them.\n requestHeaders: [...this.resolveHeaders({ context }), ...requestHeaders],\n isJsonBody: isJson,\n isFormDataBody: isFormData,\n }),\n });\n\n let response = await send();\n\n if (response.status === HTTP.ResultCodes.RS_4.Unauthorized && this.settings.onUnauthorized) {\n const shouldRetry = await this.settings.onUnauthorized(context);\n\n // A call aborted while the session refreshed is not sent again.\n if (shouldRetry) {\n signal?.throwIfAborted();\n const result = await send();\n response = result;\n }\n }\n\n return response;\n }\n\n /**\n * The body as JSON, `null` when there is none; a body that is not JSON is the server's fault, named\n * as such. Its content stays out of the message, which a relaying server may pass to its clients.\n */\n protected async readJsonBody(opts: { response: Response; url: string; verb: string }) {\n const { response, url, verb } = opts;\n\n return HttpResponseReader.readJson({\n response,\n context: `[${this.name}][${verb}] ${response.status} | ${HttpWire.describeUrl({ url, status: response.status })}`,\n });\n }\n\n /**\n * A failed response as the error the server threw: its status, code, args and text, and its\n * `extra` with the `requestId` added. `message` adds where it failed, for logs; `normalized.text`\n * stays the server's, for display - `HTTP <status>` when the server sent none. `cause` is the server's `details.cause` - a 422's per-field\n * issues, `{ path, message, code }`.\n */\n protected async toResponseError(opts: { response: Response; url: string; verb: string }) {\n const { response, url, verb } = opts;\n const described = HttpWire.describeUrl({ url, status: response.status });\n\n return HttpResponseReader.toApplicationError({\n response,\n rootKey: this.settings.errorRootKey,\n context: `[${this.name}][${verb}] ${response.status} | ${described}`,\n });\n }\n\n /**\n * Rows plus the total from `Content-Range`, reported absent when the header is. A GET unless told\n * otherwise: `method` and `body` reach a list route a service wrote to take its filter in a body.\n */\n async read<R>(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n shape?: THttpReadShape;\n method?: string;\n body?: THttpBody;\n /** Extras the route offers beside its rows, asked for by name (`x-request-extra`). */\n extra?: TExtraRequest;\n /** The rows alone: every default extra off (`-*`), for a read that only counts or probes. */\n isEveryDefaultOff?: boolean;\n } & IHttpCallOptions,\n ): Promise<IHttpReadResult<R>> {\n const url = this.buildUrl(opts);\n const headers = HttpWire.withExtraHeader({\n headers: opts.headers,\n extra: opts.extra,\n isEveryDefaultOff: opts.isEveryDefaultOff,\n });\n const response = await this.sendRequest({ ...opts, url, headers });\n\n if (!response.ok) {\n const result = await this.toResponseError({ response, url, verb: 'read' });\n throw result;\n }\n\n // A 204 or an empty body is no row; a list asked for of it still throws below.\n const parsed = await this.readJsonBody({ response, url, verb: 'read' });\n const { body, extra } = HttpResponseReader.readExtra({\n body: parsed,\n headers: response.headers,\n });\n const contentRange = response.headers.get(HTTP.Headers.CONTENT_RANGE) ?? undefined;\n const range = HttpResponseReader.parseContentRange({ header: contentRange });\n const data = HttpWire.unwrapRows<R>({ body, shape: opts.shape ?? HttpReadShapes.LIST, url });\n\n return {\n data,\n hasRange: range !== undefined,\n contentRange,\n total: range?.total,\n skip: range?.skip,\n dataLength: Array.isArray(data) ? data.length : data === null ? 0 : 1,\n extra,\n };\n }\n\n /**\n * A write, and what it answered: the body as the rows, the count from `x-response-count`. The\n * connector asks for bare rows, so an IGNIS write answers the row or the rows, never the envelope.\n */\n async write<R>(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n method: string;\n body?: THttpBody;\n /** Extras the route answers beside its rows, asked for by name (`x-request-extra`). */\n extra?: TExtraRequest;\n } & IHttpCallOptions,\n ): Promise<IHttpWriteResult<R>> {\n const url = this.buildUrl(opts);\n const headers = HttpWire.withExtraHeader({ headers: opts.headers, extra: opts.extra });\n const response = await this.sendRequest({ ...opts, url, headers });\n\n if (!response.ok) {\n const result = await this.toResponseError({ response, url, verb: 'write' });\n throw result;\n }\n\n // A 204, or a route that answers nothing, has no body to parse.\n const parsed = await this.readJsonBody({ response, url, verb: 'write' });\n const { extra } = HttpResponseReader.readExtra({ body: parsed, headers: response.headers });\n // `extra` is only read off an object body, which carries the rows under `data`.\n const data = (extra && HttpResponseReader.isPlainObject(parsed) ? parsed.data : parsed) as R;\n\n const countHeader = response.headers.get(HTTP.Headers.RESPONSE_COUNT_DATA);\n const counted = countHeader === null ? Number.NaN : Number(countHeader);\n\n return {\n data,\n count: Number.isFinite(counted)\n ? counted\n : Array.isArray(data)\n ? data.length\n : data === null\n ? 0\n : 1,\n ...(extra ? { extra } : {}),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../../src/http/datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAuB,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACvF,OA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;QAChF,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAM,CAAC;QAE7F,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAExE,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAC7B,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;oBACnB,CAAC,CAAC,IAAI,CAAC,MAAM;oBACb,CAAC,CAAC,IAAI,KAAK,IAAI;wBACb,CAAC,CAAC,CAAC;wBACH,CAAC,CAAC,CAAC;YACT,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { HttpReadShapes, HttpWireHeaders, type THttpReadShape } from './common/constants';\nimport { DataSourceRoot } from '@venizia/ignis-kernel/repository';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { NativeFetcher, UrlBuilder, UrlFetchError } from '@venizia/ignis-helpers/core';\nimport { HttpResponseReader } from './common/readers';\nimport type {\n IAuthToken,\n IHttpCallOptions,\n IHttpDataSourceSettings,\n TExtraRequest,\n IHttpReadResult,\n IHttpRequestContext,\n IHttpWriteResult,\n THttpBody,\n} from './common/types';\nimport { HttpWire } from './common/wire';\n\n/** Reads an IGNIS REST server through the repository contract. Targets IGNIS, not any REST API. */\nexport class HttpDataSource extends DataSourceRoot<IHttpDataSourceSettings> {\n override name: string;\n override settings: IHttpDataSourceSettings;\n override schema = {} as never;\n\n /** Normalised once: every request copies these, never re-parses `settings.headers`. */\n protected configuredHeaders: Array<[string, string]>;\n\n constructor(opts: IHttpDataSourceSettings & { name?: string }) {\n super({ scope: opts.name ?? HttpDataSource.name });\n\n const { name = 'http', ...settings } = opts;\n\n const configured = HttpWire.toHeaderEntries({ headers: settings.headers });\n HttpWire.assertNoRequestCountHeader({ entries: configured, name });\n\n UrlBuilder.assertBase({ baseUrl: settings.baseUrl, scope: name });\n\n this.configuredHeaders = configured;\n this.name = name;\n this.settings = settings;\n }\n\n async configure(): Promise<void> {}\n\n override getCapabilities() {\n return { transactions: false };\n }\n\n protected resolveAuthToken(opts: { context: IHttpRequestContext }): IAuthToken | undefined {\n return this.settings.authToken ?? this.settings.authTokenResolver?.(opts.context);\n }\n\n /** Re-run on every send, so a header the app changed since the last request is the one sent. */\n protected resolveHeaders(opts: { context: IHttpRequestContext }): Array<[string, string]> {\n const resolver = this.settings.headersResolver;\n\n if (!resolver) {\n return [];\n }\n\n const entries = HttpWire.toHeaderEntries({ headers: resolver(opts.context) });\n HttpWire.assertNoRequestCountHeader({ entries, name: this.name });\n\n return entries;\n }\n\n protected buildHeaders(opts: {\n token?: IAuthToken;\n requestHeaders?: Array<[string, string]>;\n isJsonBody?: boolean;\n isFormDataBody?: boolean;\n }): Headers {\n const { token, requestHeaders, isJsonBody, isFormDataBody } = opts;\n const headers = new Headers(this.configuredHeaders);\n\n // A request's own headers win over the configured ones; the connector's below win over both.\n for (const [name, value] of requestHeaders ?? []) {\n headers.set(name, value);\n }\n\n if (isJsonBody && !headers.has(HTTP.Headers.CONTENT_TYPE)) {\n headers.set(HTTP.Headers.CONTENT_TYPE, HTTP.HeaderValues.APPLICATION_JSON);\n }\n\n // Only `fetch` knows the multipart boundary; any other content-type here would drop it.\n if (isFormDataBody) {\n headers.delete(HTTP.Headers.CONTENT_TYPE);\n }\n\n // Set last: under the envelope a record read answers `{ count, data }`.\n headers.set(HTTP.Headers.REQUEST_COUNT_DATA, 'false');\n\n if (!token) {\n return headers;\n }\n\n headers.set(HTTP.Headers.AUTHORIZATION, `${token.type ?? 'Bearer'} ${token.value}`);\n\n // Unconditionally it would send the string \"undefined\".\n if (token.provider) {\n headers.set(HttpWireHeaders.AUTH_PROVIDER, token.provider);\n }\n\n return headers;\n }\n\n buildUrl(opts: { paths: Array<string>; query?: Record<string, unknown> }): string {\n const { paths, query } = opts;\n const url = UrlBuilder.join({ baseUrl: this.settings.baseUrl, paths, scope: this.name });\n\n const parameters = Object.entries(query ?? {});\n\n for (const [key, value] of parameters) {\n if (value === undefined) {\n continue;\n }\n\n url.searchParams.set(\n key,\n typeof value === 'string'\n ? value\n : HttpWire.toJson({ value, label: `[${this.name}] Query parameter '${key}'` }),\n );\n }\n\n return url.toString();\n }\n\n /**\n * The raw `Response`, on any method - for what the repository verbs do not cover, like an export\n * or a PUT to a hand-written route. Auth and the 401 retry apply; the retry resends the same body.\n */\n async request(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n method?: string;\n body?: THttpBody;\n } & IHttpCallOptions,\n ): Promise<Response> {\n return this.sendRequest({ ...opts, url: this.buildUrl(opts) });\n }\n\n /** `request` on a URL already built: `read` and `write` serialise a long query once, not per use. */\n protected async sendRequest(\n opts: {\n paths: Array<string>;\n url: string;\n method?: string;\n body?: THttpBody;\n } & IHttpCallOptions,\n ): Promise<Response> {\n const { url, signal } = opts;\n const requestHeaders = HttpWire.toHeaderEntries({ headers: opts.headers });\n HttpWire.assertNoRequestCountHeader({ entries: requestHeaders, name: this.name });\n\n const method = opts.method ?? HTTP.Methods.GET;\n const context: IHttpRequestContext = { paths: opts.paths, method, url, signal };\n const { payload, isJson, isFormData } = HttpWire.toRequestBody({ body: opts.body });\n const { onUnauthorized } = this.settings;\n\n // One fetcher per call: its hooks close over this call's context. Both resolvers run in `onRequest`, so the retry sends what they answer after the refresh.\n const fetcher = new NativeFetcher({\n name: this.name,\n fetch: this.settings.fetch,\n hooks: {\n onRequest: ({ headers }) => {\n const built = this.buildHeaders({\n token: this.resolveAuthToken({ context }),\n // Resolved first, so the call's own headers win over them.\n requestHeaders: [...this.resolveHeaders({ context }), ...requestHeaders],\n isJsonBody: isJson,\n isFormDataBody: isFormData,\n });\n\n for (const name of [...headers.keys()]) {\n headers.delete(name);\n }\n\n built.forEach((value, name) => headers.set(name, value));\n },\n },\n });\n\n try {\n const response = await fetcher.send({\n url,\n method,\n body: payload,\n signal,\n // Every status is an answer the data source reads itself; a 401 with a refresh hook throws once so the retry can see it.\n acceptStatus: (status) => !onUnauthorized || status !== HTTP.ResultCodes.RS_4.Unauthorized,\n retry: onUnauthorized\n ? {\n maxAttempts: 2,\n backoff: { initialDelayMs: 0, maxDelayMs: 0 },\n shouldRetry: async ({ error, attempt }) => {\n if (\n !UrlFetchError.is(error) ||\n error.status !== HTTP.ResultCodes.RS_4.Unauthorized\n ) {\n return false;\n }\n\n const isRefreshed = await onUnauthorized(context, { attempt });\n\n // The second 401 stands: the hook hears of it, its answer is ignored, and nothing is sent a third time.\n return attempt === 1 && isRefreshed;\n },\n }\n : undefined,\n });\n\n return response;\n } catch (error) {\n // The 401 that stands is the answer: the data source reads its body into its own error.\n if (\n error instanceof UrlFetchError &&\n error.status === HTTP.ResultCodes.RS_4.Unauthorized &&\n error.response instanceof Response\n ) {\n return error.response;\n }\n\n throw error;\n }\n }\n\n /**\n * The body as JSON, `null` when there is none; a body that is not JSON is the server's fault, named\n * as such. Its content stays out of the message, which a relaying server may pass to its clients.\n */\n protected async readJsonBody(opts: { response: Response; url: string; verb: string }) {\n const { response, url, verb } = opts;\n\n return HttpResponseReader.readJson({\n response,\n context: `[${this.name}][${verb}] ${response.status} | ${HttpWire.describeUrl({ url, status: response.status })}`,\n });\n }\n\n /**\n * A failed response as the error the server threw: its status, code, args and text, and its\n * `extra` with the `requestId` added. `message` adds where it failed, for logs; `normalized.text`\n * stays the server's, for display - `HTTP <status>` when the server sent none. `cause` is the server's `details.cause` - a 422's per-field\n * issues, `{ path, message, code }`.\n */\n protected async toResponseError(opts: { response: Response; url: string; verb: string }) {\n const { response, url, verb } = opts;\n const described = HttpWire.describeUrl({ url, status: response.status });\n\n return HttpResponseReader.toApplicationError({\n response,\n rootKey: this.settings.errorRootKey,\n context: `[${this.name}][${verb}] ${response.status} | ${described}`,\n });\n }\n\n /**\n * Rows plus the total from `Content-Range`, reported absent when the header is. A GET unless told\n * otherwise: `method` and `body` reach a list route a service wrote to take its filter in a body.\n */\n async read<R>(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n shape?: THttpReadShape;\n method?: string;\n body?: THttpBody;\n /** Extras the route offers beside its rows, asked for by name (`x-request-extra`). */\n extra?: TExtraRequest;\n /** The rows alone: every default extra off (`-*`), for a read that only counts or probes. */\n isEveryDefaultOff?: boolean;\n } & IHttpCallOptions,\n ): Promise<IHttpReadResult<R>> {\n const url = this.buildUrl(opts);\n const headers = HttpWire.withExtraHeader({\n headers: opts.headers,\n extra: opts.extra,\n isEveryDefaultOff: opts.isEveryDefaultOff,\n });\n const response = await this.sendRequest({ ...opts, url, headers });\n\n if (!response.ok) {\n const result = await this.toResponseError({ response, url, verb: 'read' });\n throw result;\n }\n\n // A 204 or an empty body is no row; a list asked for of it still throws below.\n const parsed = await this.readJsonBody({ response, url, verb: 'read' });\n const { body, extra } = HttpResponseReader.readExtra({\n body: parsed,\n headers: response.headers,\n });\n const contentRange = response.headers.get(HTTP.Headers.CONTENT_RANGE) ?? undefined;\n const range = HttpResponseReader.parseContentRange({ header: contentRange });\n const data = HttpWire.unwrapRows<R>({ body, shape: opts.shape ?? HttpReadShapes.LIST, url });\n\n return {\n data,\n hasRange: range !== undefined,\n contentRange,\n total: range?.total,\n skip: range?.skip,\n dataLength: Array.isArray(data) ? data.length : data === null ? 0 : 1,\n extra,\n };\n }\n\n /**\n * A write, and what it answered: the body as the rows, the count from `x-response-count`. The\n * connector asks for bare rows, so an IGNIS write answers the row or the rows, never the envelope.\n */\n async write<R>(\n opts: {\n paths: Array<string>;\n query?: Record<string, unknown>;\n method: string;\n body?: THttpBody;\n /** Extras the route answers beside its rows, asked for by name (`x-request-extra`). */\n extra?: TExtraRequest;\n } & IHttpCallOptions,\n ): Promise<IHttpWriteResult<R>> {\n const url = this.buildUrl(opts);\n const headers = HttpWire.withExtraHeader({ headers: opts.headers, extra: opts.extra });\n const response = await this.sendRequest({ ...opts, url, headers });\n\n if (!response.ok) {\n const result = await this.toResponseError({ response, url, verb: 'write' });\n throw result;\n }\n\n // A 204, or a route that answers nothing, has no body to parse.\n const parsed = await this.readJsonBody({ response, url, verb: 'write' });\n const { extra } = HttpResponseReader.readExtra({ body: parsed, headers: response.headers });\n // `extra` is only read off an object body, which carries the rows under `data`.\n const data = (extra && HttpResponseReader.isPlainObject(parsed) ? parsed.data : parsed) as R;\n\n const countHeader = response.headers.get(HTTP.Headers.RESPONSE_COUNT_DATA);\n const counted = countHeader === null ? Number.NaN : Number(countHeader);\n\n return {\n data,\n count: Number.isFinite(counted)\n ? counted\n : Array.isArray(data)\n ? data.length\n : data === null\n ? 0\n : 1,\n ...(extra ? { extra } : {}),\n };\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { IDeletableRepository, IReadableRepository, IUpdatableRepository, TCount, TDataWithRange, TByIdFilter, TFields, TFilter, TRow, TSchemaType, TWhere } from '@venizia/ignis-kernel/repository';
1
+ import type { IDeletableRepository, IReadableRepository, IUpdatableRepository, TCount, TDataWithRange, TByIdFilter, TFields, TFilter, TRow, TWhere } from '@venizia/ignis-kernel/repository';
2
2
  import { AbstractEntity } from '@venizia/ignis-kernel/repository';
3
3
  import type { TSearchInput } from '../search/core/repositories/common/constants.js';
4
4
  import type { IHttpCallOptions, IHttpSearchResult, IHttpWriteResult, THttpExtraQuery, TExtraRequest, TExtraResult } from './common/types.js';
@@ -7,13 +7,7 @@ import type { HttpDataSource } from './datasource.js';
7
7
  * What a repository call takes. Only `headers` and `signal` cross HTTP; the shared repository
8
8
  * options (`transaction`, `log`, ...) are accepted for the common contract and have no effect.
9
9
  */
10
- export type THttpRepositoryOptions = NonNullable<Parameters<IReadableRepository['existsWith']>[0]['options']> & IHttpCallOptions;
11
- /** A remote resource has a name but no local schema. */
12
- export declare class HttpResourceEntity extends AbstractEntity {
13
- getSchema<T = unknown>(_opts: {
14
- type: TSchemaType;
15
- }): T;
16
- }
10
+ type THttpRepositoryOptions = NonNullable<Parameters<IReadableRepository['existsWith']>[0]['options']> & IHttpCallOptions;
17
11
  /**
18
12
  * One remote resource, read and written through the IGNIS CRUD routes, in the `@venizia/ignis-filter`
19
13
  * vocabulary. `P` is what a write sends - a partial row by default, since the server fills ids and
@@ -271,4 +265,5 @@ export declare class HttpRepository<E extends object = object, P extends object
271
265
  data: unknown;
272
266
  }>;
273
267
  }
268
+ export {};
274
269
  //# sourceMappingURL=repository.d.ts.map