@entifix/rest 0.23.8 → 0.23.10
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-entity-rest-use-case-runner.d.ts","sourceRoot":"","sources":["../../../src/adapters/entity-use-case/make-entity-rest-use-case-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAIzB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,SAAS,MAAM,EAChE,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,8BAA8B,sBAAsB,KACnD,
|
|
1
|
+
{"version":3,"file":"make-entity-rest-use-case-runner.d.ts","sourceRoot":"","sources":["../../../src/adapters/entity-use-case/make-entity-rest-use-case-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAIzB,MAAM,eAAe,CAAC;AAMvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,SAAS,MAAM,EAChE,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,8BAA8B,sBAAsB,KACnD,mBAuDF,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
1
2
|
import { extractMetaEntity, ProtocolFailure, toWireSelection } from '@entifix/core';
|
|
2
3
|
import { Effect } from 'effect';
|
|
3
4
|
import { performHttpRequestThroughFetch } from '../../clients/fetch/index.js';
|
|
@@ -21,12 +22,17 @@ import { readWriteResponse } from '../entity-rest/read-write-response.js';
|
|
|
21
22
|
uriConfig
|
|
22
23
|
}, name, id);
|
|
23
24
|
return {
|
|
24
|
-
run: (useCase, id)=>Effect.gen(function*() {
|
|
25
|
+
run: (useCase, id, payload)=>Effect.gen(function*() {
|
|
25
26
|
const url = yield* baseUrl(useCase.binding === 'entity' && id != null ? String(id) : undefined);
|
|
26
|
-
const response = yield* performHttpRequestThroughFetch({
|
|
27
|
+
const response = yield* performHttpRequestThroughFetch(_extends({
|
|
27
28
|
method: 'POST',
|
|
28
29
|
url: `${url}/${useCase.key}`
|
|
29
|
-
}
|
|
30
|
+
}, payload === undefined ? {} : {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
},
|
|
34
|
+
body: payload
|
|
35
|
+
}));
|
|
30
36
|
return yield* readWriteResponse(response, ()=>{
|
|
31
37
|
var _response_body;
|
|
32
38
|
return Effect.succeed((_response_body = response.body) == null ? void 0 : _response_body.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/entity-use-case/make-entity-rest-use-case-runner.ts"],"sourcesContent":["import {\n type BulkOutcome,\n type Entity,\n type EntityConstructor,\n type EntityUseCaseRunner,\n extractMetaEntity,\n ProtocolFailure,\n toWireSelection,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../entity-rest/build-entity-rest-adapter-mixins/index.js';\nimport { readWriteResponse } from '../entity-rest/read-write-response.js';\nimport type { BuildEntityRestOptions } from '../entity-rest/types.js';\n\n/**\n * Runs an entity's verbs against the service that serves them, at the path the\n * shell derives from each verb's key and binding — under the same base URL the\n * entity's other adapters use, so a same-origin proxy is followed the same way\n * ([ADR 0020](../../../../../../docs/adr/0020-endpoints-are-descriptors-and-the-shell-builds-an-httpapi.md)).\n *\n * A refusal arrives as the failure the service sent, decoded from its problem\n * body, so a screen shows the coded message rather than a generic error. A\n * verb that starts a flow answers `202 flowAccepted` and runs as pending; any\n * other success is settled with the `data` of what the service answered.\n */\nexport const makeEntityRestUseCaseRunner = <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, configuration }: BuildEntityRestOptions,\n): EntityUseCaseRunner => {\n const metaEntity = extractMetaEntity(entityConstructor);\n const name = metaEntity.key ?? metaEntity.name;\n const baseUrl = (id?: string) =>\n adapterMixins.buildEntityBaseUrl(configuration, { uriConfig }, name, id);\n\n return {\n run: (useCase, id) =>\n Effect.gen(function* () {\n const url = yield* baseUrl(\n useCase.binding === 'entity' && id != null ? String(id) : undefined,\n );\n const response = yield* performHttpRequestThroughFetch<{\n readonly data?: unknown;\n }>({\n method: 'POST',\n url: `${url}/${useCase.key}`,\n });\n return yield* readWriteResponse(response, () =>\n Effect.succeed(response.body?.data),\n );\n }),\n bulk: (useCase, selection) =>\n Effect.gen(function* () {\n const url = yield* baseUrl();\n // The wire form, never the selection itself: a `Set` serializes to\n // `{}`, so a selection sent raw would lose its ids.\n const response = yield* performHttpRequestThroughFetch<{\n readonly data?: unknown;\n }>({\n method: 'POST',\n url: `${url}/${useCase.key}`,\n headers: { 'Content-Type': 'application/json' },\n body: { selection: toWireSelection(selection) },\n });\n // A bulk answer is a `bulkOutcome` envelope, one outcome per record in\n // its `data`; anything else is a peer speaking something else.\n const outcomes = response.body?.data;\n if (!Array.isArray(outcomes)) {\n return yield* new ProtocolFailure({\n reason:\n 'a bulk answer carries its outcomes in a bulkOutcome envelope',\n });\n }\n return outcomes as readonly BulkOutcome[];\n }),\n };\n};\n"],"names":["extractMetaEntity","ProtocolFailure","toWireSelection","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","readWriteResponse","makeEntityRestUseCaseRunner","entityConstructor","uriConfig","configuration","metaEntity","name","key","baseUrl","id","buildEntityBaseUrl","run","useCase","gen","url","binding","String","undefined","response","method","
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/entity-use-case/make-entity-rest-use-case-runner.ts"],"sourcesContent":["import {\n type BulkOutcome,\n type Entity,\n type EntityConstructor,\n type EntityUseCaseRunner,\n extractMetaEntity,\n ProtocolFailure,\n toWireSelection,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../entity-rest/build-entity-rest-adapter-mixins/index.js';\nimport { readWriteResponse } from '../entity-rest/read-write-response.js';\nimport type { BuildEntityRestOptions } from '../entity-rest/types.js';\n\n/**\n * Runs an entity's verbs against the service that serves them, at the path the\n * shell derives from each verb's key and binding — under the same base URL the\n * entity's other adapters use, so a same-origin proxy is followed the same way\n * ([ADR 0020](../../../../../../docs/adr/0020-endpoints-are-descriptors-and-the-shell-builds-an-httpapi.md)).\n *\n * A refusal arrives as the failure the service sent, decoded from its problem\n * body, so a screen shows the coded message rather than a generic error. A\n * verb that starts a flow answers `202 flowAccepted` and runs as pending; any\n * other success is settled with the `data` of what the service answered.\n */\nexport const makeEntityRestUseCaseRunner = <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, configuration }: BuildEntityRestOptions,\n): EntityUseCaseRunner => {\n const metaEntity = extractMetaEntity(entityConstructor);\n const name = metaEntity.key ?? metaEntity.name;\n const baseUrl = (id?: string) =>\n adapterMixins.buildEntityBaseUrl(configuration, { uriConfig }, name, id);\n\n return {\n run: (useCase, id, payload) =>\n Effect.gen(function* () {\n const url = yield* baseUrl(\n useCase.binding === 'entity' && id != null ? String(id) : undefined,\n );\n const response = yield* performHttpRequestThroughFetch<{\n readonly data?: unknown;\n }>({\n method: 'POST',\n url: `${url}/${useCase.key}`,\n // A verb's input travels as its JSON body; a verb that takes none\n // is posted empty, as it always was.\n ...(payload === undefined\n ? {}\n : {\n headers: { 'Content-Type': 'application/json' },\n body: payload,\n }),\n });\n return yield* readWriteResponse(response, () =>\n Effect.succeed(response.body?.data),\n );\n }),\n bulk: (useCase, selection) =>\n Effect.gen(function* () {\n const url = yield* baseUrl();\n // The wire form, never the selection itself: a `Set` serializes to\n // `{}`, so a selection sent raw would lose its ids.\n const response = yield* performHttpRequestThroughFetch<{\n readonly data?: unknown;\n }>({\n method: 'POST',\n url: `${url}/${useCase.key}`,\n headers: { 'Content-Type': 'application/json' },\n body: { selection: toWireSelection(selection) },\n });\n // A bulk answer is a `bulkOutcome` envelope, one outcome per record in\n // its `data`; anything else is a peer speaking something else.\n const outcomes = response.body?.data;\n if (!Array.isArray(outcomes)) {\n return yield* new ProtocolFailure({\n reason:\n 'a bulk answer carries its outcomes in a bulkOutcome envelope',\n });\n }\n return outcomes as readonly BulkOutcome[];\n }),\n };\n};\n"],"names":["extractMetaEntity","ProtocolFailure","toWireSelection","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","readWriteResponse","makeEntityRestUseCaseRunner","entityConstructor","uriConfig","configuration","metaEntity","name","key","baseUrl","id","buildEntityBaseUrl","run","useCase","payload","gen","url","binding","String","undefined","response","method","headers","body","succeed","data","bulk","selection","outcomes","Array","isArray","reason"],"mappings":";AAAA,SAKEA,iBAAiB,EACjBC,eAAe,EACfC,eAAe,QACV,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,+BAA+B;AAC9E,SAASC,gCAAgCC,aAAa,QAAQ,2DAA2D;AACzH,SAASC,iBAAiB,QAAQ,wCAAwC;AAG1E;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,8BAA8B,CACzCC,mBACA,EAAEC,SAAS,EAAEC,aAAa,EAA0B;QAGvCC;IADb,MAAMA,aAAaZ,kBAAkBS;IACrC,MAAMI,QAAOD,kBAAAA,WAAWE,GAAG,YAAdF,kBAAkBA,WAAWC,IAAI;IAC9C,MAAME,UAAU,CAACC,KACfV,cAAcW,kBAAkB,CAACN,eAAe;YAAED;QAAU,GAAGG,MAAMG;IAEvE,OAAO;QACLE,KAAK,CAACC,SAASH,IAAII,UACjBjB,OAAOkB,GAAG,CAAC;gBACT,MAAMC,MAAM,OAAOP,QACjBI,QAAQI,OAAO,KAAK,YAAYP,MAAM,OAAOQ,OAAOR,MAAMS;gBAE5D,MAAMC,WAAW,OAAOtB,+BAErB;oBACDuB,QAAQ;oBACRL,KAAK,GAAGA,IAAI,CAAC,EAAEH,QAAQL,GAAG,EAAE;mBAGxBM,YAAYK,YACZ,CAAC,IACD;oBACEG,SAAS;wBAAE,gBAAgB;oBAAmB;oBAC9CC,MAAMT;gBACR;gBAEN,OAAO,OAAOb,kBAAkBmB,UAAU;wBACzBA;2BAAfvB,OAAO2B,OAAO,EAACJ,iBAAAA,SAASG,IAAI,qBAAbH,eAAeK,IAAI;;YAEtC;QACFC,MAAM,CAACb,SAASc,YACd9B,OAAOkB,GAAG,CAAC;oBAcQK;gBAbjB,MAAMJ,MAAM,OAAOP;gBACnB,mEAAmE;gBACnE,oDAAoD;gBACpD,MAAMW,WAAW,OAAOtB,+BAErB;oBACDuB,QAAQ;oBACRL,KAAK,GAAGA,IAAI,CAAC,EAAEH,QAAQL,GAAG,EAAE;oBAC5Bc,SAAS;wBAAE,gBAAgB;oBAAmB;oBAC9CC,MAAM;wBAAEI,WAAW/B,gBAAgB+B;oBAAW;gBAChD;gBACA,uEAAuE;gBACvE,+DAA+D;gBAC/D,MAAMC,YAAWR,iBAAAA,SAASG,IAAI,qBAAbH,eAAeK,IAAI;gBACpC,IAAI,CAACI,MAAMC,OAAO,CAACF,WAAW;oBAC5B,OAAO,OAAO,IAAIjC,gBAAgB;wBAChCoC,QACE;oBACJ;gBACF;gBACA,OAAOH;YACT;IACJ;AACF,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/rest",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.10",
|
|
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.
|
|
60
|
-
"@entifix/transactions": "0.23.
|
|
59
|
+
"@entifix/core": "0.23.10",
|
|
60
|
+
"@entifix/transactions": "0.23.10"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"effect": "4.0.7",
|
|
64
|
-
"@entifix/testing-unit": "0.23.
|
|
64
|
+
"@entifix/testing-unit": "0.23.10"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"effect": "^4.0.7"
|