@entifix/rest 0.23.26 → 0.23.27

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.
@@ -7,6 +7,11 @@ export interface ParticipantAddress {
7
7
  /** The crossing token this caller presents to that participant. */
8
8
  readonly crossingToken: Redacted.Redacted<string>;
9
9
  }
10
+ /**
11
+ * Whether an `HttpClient` failure proves the request never left: a URL or a
12
+ * body that could not be built, or a socket error from {@link UNSENT_CODES}.
13
+ */
14
+ export declare const requestNeverSent: (error: unknown) => boolean;
10
15
  /**
11
16
  * Calls participants over HTTP, as the slip pinned each step's call
12
17
  * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):
@@ -15,7 +20,7 @@ export interface ParticipantAddress {
15
20
  * themselves as a flat JSON body — what the participant's own route declares,
16
21
  * never a wrapper of the flow's. A refusal decodes into the failure the participant
17
22
  * sent, by its code; a body that is not a problem is `protocol`; no answer at
18
- * all is `unavailable`. A step with no call — the commit point that names no
23
+ * all is `unavailable`, with `sent: false` when the request provably never left. A step with no call — the commit point that names no
19
24
  * participant — answers at once.
20
25
  */
21
26
  export declare const makeHttpParticipantClient: (client: HttpClient.HttpClient, participants: Readonly<Record<string, ParticipantAddress>>) => ParticipantClient;
@@ -1 +1 @@
1
- {"version":3,"file":"participant-client.d.ts","sourceRoot":"","sources":["../../src/endpoint/participant-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,iBAAiB,EACtB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAU,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAE5D,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CACnD;AAqBD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GACpC,QAAQ,UAAU,CAAC,UAAU,EAC7B,cAAc,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,KACzD,iBA8DD,CAAC;AAEH,gEAAgE;AAChE,eAAO,MAAM,0BAA0B,GACrC,cAAc,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,oEAOzD,CAAC"}
1
+ {"version":3,"file":"participant-client.d.ts","sourceRoot":"","sources":["../../src/endpoint/participant-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,iBAAiB,EACtB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAU,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAE5D,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;CACnD;AAgDD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,KAAG,OAMjD,CAAC;AAQF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GACpC,QAAQ,UAAU,CAAC,UAAU,EAC7B,cAAc,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,KACzD,iBAoED,CAAC;AAEH,gEAAgE;AAChE,eAAO,MAAM,0BAA0B,GACrC,cAAc,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,oEAOzD,CAAC"}
@@ -12,6 +12,35 @@ const parse = (text)=>{
12
12
  return undefined;
13
13
  }
14
14
  };
15
+ /**
16
+ * Socket errors raised before a single byte of the request was written: the
17
+ * participant refused the connection, or its name or route does not exist.
18
+ * A reset or a timeout is not here — the request may have arrived.
19
+ */ const UNSENT_CODES = new Set([
20
+ 'ECONNREFUSED',
21
+ 'ENOTFOUND',
22
+ 'EAI_AGAIN',
23
+ 'ENETUNREACH',
24
+ 'EHOSTUNREACH'
25
+ ]);
26
+ /** The error codes along a cause chain, outermost first, a bounded walk. */ const codesOf = (error)=>{
27
+ const codes = [];
28
+ let current = error;
29
+ for(let depth = 0; depth < 8 && typeof current === 'object' && current !== null; depth++){
30
+ const { code, cause, reason } = current;
31
+ if (typeof code === 'string') codes.push(code);
32
+ current = reason != null ? reason : cause;
33
+ }
34
+ return codes;
35
+ };
36
+ /**
37
+ * Whether an `HttpClient` failure proves the request never left: a URL or a
38
+ * body that could not be built, or a socket error from {@link UNSENT_CODES}.
39
+ */ export const requestNeverSent = (error)=>{
40
+ const reason = error.reason;
41
+ if ((reason == null ? void 0 : reason._tag) === 'InvalidUrlError' || (reason == null ? void 0 : reason._tag) === 'EncodeError') return true;
42
+ return codesOf(error).some((code)=>UNSENT_CODES.has(code));
43
+ };
15
44
  /** The step's path with each `:name` taken from the call's inputs. */ const pathOf = (call, path)=>path.replace(/:([A-Za-z0-9_]+)/g, (_match, name)=>{
16
45
  var _call_inputs_name;
17
46
  return encodeURIComponent(String((_call_inputs_name = call.inputs[name]) != null ? _call_inputs_name : ''));
@@ -24,7 +53,7 @@ const parse = (text)=>{
24
53
  * themselves as a flat JSON body — what the participant's own route declares,
25
54
  * never a wrapper of the flow's. A refusal decodes into the failure the participant
26
55
  * sent, by its code; a body that is not a problem is `protocol`; no answer at
27
- * all is `unavailable`. A step with no call — the commit point that names no
56
+ * all is `unavailable`, with `sent: false` when the request provably never left. A step with no call — the commit point that names no
28
57
  * participant — answers at once.
29
58
  */ export const makeHttpParticipantClient = (client, participants)=>({
30
59
  call: (request)=>Effect.gen(function*() {
@@ -50,7 +79,10 @@ const parse = (text)=>{
50
79
  } : {}, remaining === undefined ? {} : {
51
80
  [DEADLINE_HEADER]: String(remaining)
52
81
  })), target.method === 'GET' ? (outgoing)=>outgoing : HttpClientRequest.bodyText(JSON.stringify(request.inputs), 'application/json'));
53
- const response = yield* client.execute(outgoing).pipe(Effect.mapError(()=>new Unavailable({
82
+ const response = yield* client.execute(outgoing).pipe(Effect.mapError((error)=>requestNeverSent(error) ? new Unavailable({
83
+ dependency,
84
+ sent: false
85
+ }) : new Unavailable({
54
86
  dependency
55
87
  })));
56
88
  const text = yield* response.text.pipe(Effect.mapError(()=>new Unavailable({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/endpoint/participant-client.ts"],"sourcesContent":["import {\n currentRemainingMs,\n DEADLINE_HEADER,\n decodeProblem,\n type EntifixFailure,\n formatIdempotencyKey,\n IDEMPOTENCY_KEY_HEADER,\n Internal,\n PROBLEM_CONTENT_TYPE,\n ProtocolFailure,\n Timeout,\n Unavailable,\n} from '@entifix/core';\nimport {\n type ParticipantCall,\n type ParticipantClient,\n ParticipantClientTag,\n} from '@entifix/transactions';\nimport { Effect, Layer, Redacted } from 'effect';\nimport { HttpClient, HttpClientRequest } from 'effect/http';\n\n/** Where one participant is reached, and the token it takes. */\nexport interface ParticipantAddress {\n readonly baseUrl: string;\n /** The crossing token this caller presents to that participant. */\n readonly crossingToken: Redacted.Redacted<string>;\n}\n\n/** The header a crossing token travels in. */\nconst CROSSING_TOKEN_HEADER = 'x-crossing-token';\n/** The header a crossing names the organization it acts for in. */\nconst ORGANIZATION_HEADER = 'x-organization-id';\n\nconst parse = (text: string): unknown => {\n try {\n return JSON.parse(text) as unknown;\n } catch {\n return undefined;\n }\n};\n\n/** The step's path with each `:name` taken from the call's inputs. */\nconst pathOf = (call: ParticipantCall, path: string) =>\n path.replace(/:([A-Za-z0-9_]+)/g, (_match, name: string) =>\n encodeURIComponent(String(call.inputs[name] ?? '')),\n );\n\n/**\n * Calls participants over HTTP, as the slip pinned each step's call\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):\n * the crossing token the participant takes, the step's `Idempotency-Key`, the\n * flow's remaining deadline, the organization the inputs name, and the inputs\n * themselves as a flat JSON body — what the participant's own route declares,\n * never a wrapper of the flow's. A refusal decodes into the failure the participant\n * sent, by its code; a body that is not a problem is `protocol`; no answer at\n * all is `unavailable`. A step with no call — the commit point that names no\n * participant — answers at once.\n */\nexport const makeHttpParticipantClient = (\n client: HttpClient.HttpClient,\n participants: Readonly<Record<string, ParticipantAddress>>,\n): ParticipantClient => ({\n call: request =>\n Effect.gen(function* () {\n const target =\n request.kind === 'action'\n ? request.step.call\n : request.step.compensation;\n if (target === undefined) return undefined;\n const name = request.step.participant ?? '';\n const address = participants[name];\n if (address === undefined)\n return yield* Effect.fail(new Internal() as EntifixFailure);\n const dependency = `${name} ${target.method} ${target.path}`;\n\n const remaining = yield* currentRemainingMs;\n if (remaining === 0)\n return yield* Effect.fail(new Timeout({ dependency }));\n\n const organizationId = request.inputs['organizationId'];\n const outgoing = HttpClientRequest.make(target.method)(\n `${address.baseUrl}${pathOf(request, target.path)}`,\n ).pipe(\n HttpClientRequest.setHeaders({\n accept: 'application/json',\n [CROSSING_TOKEN_HEADER]: Redacted.value(address.crossingToken),\n [IDEMPOTENCY_KEY_HEADER]: formatIdempotencyKey(\n request.idempotencyKey,\n ),\n ...(typeof organizationId === 'string'\n ? { [ORGANIZATION_HEADER]: organizationId }\n : {}),\n ...(remaining === undefined\n ? {}\n : { [DEADLINE_HEADER]: String(remaining) }),\n }),\n target.method === 'GET'\n ? (outgoing: HttpClientRequest.HttpClientRequest) => outgoing\n : HttpClientRequest.bodyText(\n JSON.stringify(request.inputs),\n 'application/json',\n ),\n );\n\n const response = yield* client\n .execute(outgoing)\n .pipe(Effect.mapError(() => new Unavailable({ dependency })));\n const text = yield* response.text.pipe(\n Effect.mapError(() => new Unavailable({ dependency })),\n );\n if (response.status < 400) return text === '' ? undefined : parse(text);\n const isProblem =\n response.headers['content-type']?.startsWith(PROBLEM_CONTENT_TYPE) ===\n true;\n return yield* Effect.fail(\n isProblem\n ? decodeProblem(parse(text), response.status)\n : new ProtocolFailure({\n reason: `${dependency} answered ${String(response.status)} without a problem body`,\n upstreamStatus: response.status,\n }),\n );\n }),\n});\n\n/** The HTTP participant client over the host's `HttpClient`. */\nexport const HttpParticipantClientLayer = (\n participants: Readonly<Record<string, ParticipantAddress>>,\n) =>\n Layer.effect(\n ParticipantClientTag,\n Effect.map(HttpClient.HttpClient, client =>\n makeHttpParticipantClient(client, participants),\n ),\n );\n"],"names":["currentRemainingMs","DEADLINE_HEADER","decodeProblem","formatIdempotencyKey","IDEMPOTENCY_KEY_HEADER","Internal","PROBLEM_CONTENT_TYPE","ProtocolFailure","Timeout","Unavailable","ParticipantClientTag","Effect","Layer","Redacted","HttpClient","HttpClientRequest","CROSSING_TOKEN_HEADER","ORGANIZATION_HEADER","parse","text","JSON","undefined","pathOf","call","path","replace","_match","name","encodeURIComponent","String","inputs","makeHttpParticipantClient","client","participants","request","gen","response","target","kind","step","compensation","participant","address","fail","dependency","method","remaining","organizationId","outgoing","make","baseUrl","pipe","setHeaders","accept","value","crossingToken","idempotencyKey","bodyText","stringify","execute","mapError","status","isProblem","headers","startsWith","reason","upstreamStatus","HttpParticipantClientLayer","effect","map"],"mappings":";AAAA,SACEA,kBAAkB,EAClBC,eAAe,EACfC,aAAa,EAEbC,oBAAoB,EACpBC,sBAAsB,EACtBC,QAAQ,EACRC,oBAAoB,EACpBC,eAAe,EACfC,OAAO,EACPC,WAAW,QACN,gBAAgB;AACvB,SAGEC,oBAAoB,QACf,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,SAAS;AACjD,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,cAAc;AAS5D,4CAA4C,GAC5C,MAAMC,wBAAwB;AAC9B,iEAAiE,GACjE,MAAMC,sBAAsB;AAE5B,MAAMC,QAAQ,CAACC;IACb,IAAI;Q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{"version":3,"sources":["../../src/endpoint/participant-client.ts"],"sourcesContent":["import {\n currentRemainingMs,\n DEADLINE_HEADER,\n decodeProblem,\n type EntifixFailure,\n formatIdempotencyKey,\n IDEMPOTENCY_KEY_HEADER,\n Internal,\n PROBLEM_CONTENT_TYPE,\n ProtocolFailure,\n Timeout,\n Unavailable,\n} from '@entifix/core';\nimport {\n type ParticipantCall,\n type ParticipantClient,\n ParticipantClientTag,\n} from '@entifix/transactions';\nimport { Effect, Layer, Redacted } from 'effect';\nimport { HttpClient, HttpClientRequest } from 'effect/http';\n\n/** Where one participant is reached, and the token it takes. */\nexport interface ParticipantAddress {\n readonly baseUrl: string;\n /** The crossing token this caller presents to that participant. */\n readonly crossingToken: Redacted.Redacted<string>;\n}\n\n/** The header a crossing token travels in. */\nconst CROSSING_TOKEN_HEADER = 'x-crossing-token';\n/** The header a crossing names the organization it acts for in. */\nconst ORGANIZATION_HEADER = 'x-organization-id';\n\nconst parse = (text: string): unknown => {\n try {\n return JSON.parse(text) as unknown;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Socket errors raised before a single byte of the request was written: the\n * participant refused the connection, or its name or route does not exist.\n * A reset or a timeout is not here — the request may have arrived.\n */\nconst UNSENT_CODES = new Set([\n 'ECONNREFUSED',\n 'ENOTFOUND',\n 'EAI_AGAIN',\n 'ENETUNREACH',\n 'EHOSTUNREACH',\n]);\n\n/** The error codes along a cause chain, outermost first, a bounded walk. */\nconst codesOf = (error: unknown): readonly string[] => {\n const codes: string[] = [];\n let current: unknown = error;\n for (\n let depth = 0;\n depth < 8 && typeof current === 'object' && current !== null;\n depth++\n ) {\n const { code, cause, reason } = current as {\n readonly code?: unknown;\n readonly cause?: unknown;\n readonly reason?: unknown;\n };\n if (typeof code === 'string') codes.push(code);\n current = reason ?? cause;\n }\n return codes;\n};\n\n/**\n * Whether an `HttpClient` failure proves the request never left: a URL or a\n * body that could not be built, or a socket error from {@link UNSENT_CODES}.\n */\nexport const requestNeverSent = (error: unknown): boolean => {\n const reason = (error as { readonly reason?: { readonly _tag?: unknown } })\n .reason;\n if (reason?._tag === 'InvalidUrlError' || reason?._tag === 'EncodeError')\n return true;\n return codesOf(error).some(code => UNSENT_CODES.has(code));\n};\n\n/** The step's path with each `:name` taken from the call's inputs. */\nconst pathOf = (call: ParticipantCall, path: string) =>\n path.replace(/:([A-Za-z0-9_]+)/g, (_match, name: string) =>\n encodeURIComponent(String(call.inputs[name] ?? '')),\n );\n\n/**\n * Calls participants over HTTP, as the slip pinned each step's call\n * ([ADR 0016](../../../../../docs/adr/0016-a-flow-engine-port-and-a-durable-workflow-adapter.md)):\n * the crossing token the participant takes, the step's `Idempotency-Key`, the\n * flow's remaining deadline, the organization the inputs name, and the inputs\n * themselves as a flat JSON body — what the participant's own route declares,\n * never a wrapper of the flow's. A refusal decodes into the failure the participant\n * sent, by its code; a body that is not a problem is `protocol`; no answer at\n * all is `unavailable`, with `sent: false` when the request provably never left. A step with no call — the commit point that names no\n * participant — answers at once.\n */\nexport const makeHttpParticipantClient = (\n client: HttpClient.HttpClient,\n participants: Readonly<Record<string, ParticipantAddress>>,\n): ParticipantClient => ({\n call: request =>\n Effect.gen(function* () {\n const target =\n request.kind === 'action'\n ? request.step.call\n : request.step.compensation;\n if (target === undefined) return undefined;\n const name = request.step.participant ?? '';\n const address = participants[name];\n if (address === undefined)\n return yield* Effect.fail(new Internal() as EntifixFailure);\n const dependency = `${name} ${target.method} ${target.path}`;\n\n const remaining = yield* currentRemainingMs;\n if (remaining === 0)\n return yield* Effect.fail(new Timeout({ dependency }));\n\n const organizationId = request.inputs['organizationId'];\n const outgoing = HttpClientRequest.make(target.method)(\n `${address.baseUrl}${pathOf(request, target.path)}`,\n ).pipe(\n HttpClientRequest.setHeaders({\n accept: 'application/json',\n [CROSSING_TOKEN_HEADER]: Redacted.value(address.crossingToken),\n [IDEMPOTENCY_KEY_HEADER]: formatIdempotencyKey(\n request.idempotencyKey,\n ),\n ...(typeof organizationId === 'string'\n ? { [ORGANIZATION_HEADER]: organizationId }\n : {}),\n ...(remaining === undefined\n ? {}\n : { [DEADLINE_HEADER]: String(remaining) }),\n }),\n target.method === 'GET'\n ? (outgoing: HttpClientRequest.HttpClientRequest) => outgoing\n : HttpClientRequest.bodyText(\n JSON.stringify(request.inputs),\n 'application/json',\n ),\n );\n\n const response = yield* client\n .execute(outgoing)\n .pipe(\n Effect.mapError(error =>\n requestNeverSent(error)\n ? new Unavailable({ dependency, sent: false })\n : new Unavailable({ dependency }),\n ),\n );\n const text = yield* response.text.pipe(\n Effect.mapError(() => new Unavailable({ dependency })),\n );\n if (response.status < 400) return text === '' ? undefined : parse(text);\n const isProblem =\n response.headers['content-type']?.startsWith(PROBLEM_CONTENT_TYPE) ===\n true;\n return yield* Effect.fail(\n isProblem\n ? decodeProblem(parse(text), response.status)\n : new ProtocolFailure({\n reason: `${dependency} answered ${String(response.status)} without a problem body`,\n upstreamStatus: response.status,\n }),\n );\n }),\n});\n\n/** The HTTP participant client over the host's `HttpClient`. */\nexport const HttpParticipantClientLayer = (\n participants: Readonly<Record<string, ParticipantAddress>>,\n) =>\n Layer.effect(\n ParticipantClientTag,\n Effect.map(HttpClient.HttpClient, client =>\n makeHttpParticipantClient(client, participants),\n ),\n );\n"],"names":["currentRemainingMs","DEADLINE_HEADER","decodeProblem","formatIdempotencyKey","IDEMPOTENCY_KEY_HEADER","Internal","PROBLEM_CONTENT_TYPE","ProtocolFailure","Timeout","Unavailable","ParticipantClientTag","Effect","Layer","Redacted","HttpClient","HttpClientRequest","CROSSING_TOKEN_HEADER","ORGANIZATION_HEADER","parse","text","JSON","undefined","UNSENT_CODES","Set","codesOf","error","codes","current","depth","code","cause","reason","push","requestNeverSent","_tag","some","has","pathOf","call","path","replace","_match","name","encodeURIComponent","String","inputs","makeHttpParticipantClient","client","participants","request","gen","response","target","kind","step","compensation","participant","address","fail","dependency","method","remaining","organizationId","outgoing","make","baseUrl","pipe","setHeaders","accept","value","crossingToken","idempotencyKey","bodyText","stringify","execute","mapError","sent","status","isProblem","headers","startsWith","upstreamStatus","HttpParticipantClientLayer","effect","map"],"mappings":";AAAA,SACEA,kBAAkB,EAClBC,eAAe,EACfC,aAAa,EAEbC,oBAAoB,EACpBC,sBAAsB,EACtBC,QAAQ,EACRC,oBAAoB,EACpBC,eAAe,EACfC,OAAO,EACPC,WAAW,QACN,gBAAgB;AACvB,SAGEC,oBAAoB,QACf,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,SAAS;AACjD,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,cAAc;AAS5D,4CAA4C,GAC5C,MAAMC,wBAAwB;AAC9B,iEAAiE,GACjE,MAAMC,sBAAsB;AAE5B,MAAMC,QAAQ,CAACC;IACb,IAAI;QACF,OAAOC,KAAKF,KAAK,CAACC;IACpB,EAAE,eAAM;QACN,OAAOE;IACT;AACF;AAEA;;;;CAIC,GACD,MAAMC,eAAe,IAAIC,IAAI;IAC3B;IACA;IACA;IACA;IACA;CACD;AAED,0EAA0E,GAC1E,MAAMC,UAAU,CAACC;IACf,MAAMC,QAAkB,EAAE;IAC1B,IAAIC,UAAmBF;IACvB,IACE,IAAIG,QAAQ,GACZA,QAAQ,KAAK,OAAOD,YAAY,YAAYA,YAAY,MACxDC,QACA;QACA,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAGJ;QAKhC,IAAI,OAAOE,SAAS,UAAUH,MAAMM,IAAI,CAACH;QACzCF,UAAUI,iBAAAA,SAAUD;IACtB;IACA,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,MAAMO,mBAAmB,CAACR;IAC/B,MAAMM,SAAS,AAACN,MACbM,MAAM;IACT,IAAIA,CAAAA,0BAAAA,OAAQG,IAAI,MAAK,qBAAqBH,CAAAA,0BAAAA,OAAQG,IAAI,MAAK,eACzD,OAAO;IACT,OAAOV,QAAQC,OAAOU,IAAI,CAACN,CAAAA,OAAQP,aAAac,GAAG,CAACP;A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BAA0BC,QAAQC,gBAEpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/rest",
3
- "version": "0.23.26",
3
+ "version": "0.23.27",
4
4
  "description": "HTTP entity adapter for the browser: get, load, save and delete against an entifix service, plus served metadata and transaction status.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,12 +56,12 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@swc/helpers": "0.5.23",
59
- "@entifix/core": "0.23.26",
60
- "@entifix/transactions": "0.23.26"
59
+ "@entifix/core": "0.23.27",
60
+ "@entifix/transactions": "0.23.27"
61
61
  },
62
62
  "devDependencies": {
63
63
  "effect": "4.0.7",
64
- "@entifix/testing-unit": "0.23.26"
64
+ "@entifix/testing-unit": "0.23.27"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "effect": "^4.0.7"