@entifix/rest 0.4.2 → 0.5.0

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 (29) hide show
  1. package/README.md +20 -0
  2. package/dist/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.d.ts +1 -2
  3. package/dist/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.d.ts.map +1 -1
  4. package/dist/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.js +2 -4
  5. package/dist/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.js.map +1 -1
  6. package/dist/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.d.ts +1 -2
  7. package/dist/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.d.ts.map +1 -1
  8. package/dist/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.js +2 -4
  9. package/dist/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.js.map +1 -1
  10. package/dist/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.d.ts +1 -2
  11. package/dist/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.d.ts.map +1 -1
  12. package/dist/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.js +2 -4
  13. package/dist/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.js.map +1 -1
  14. package/dist/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.d.ts +1 -1
  15. package/dist/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.d.ts.map +1 -1
  16. package/dist/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.js.map +1 -1
  17. package/dist/adapters/entity-rest/build-entity-rest-adapter-mixins/index.d.ts +1 -1
  18. package/dist/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.d.ts +1 -2
  19. package/dist/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.d.ts.map +1 -1
  20. package/dist/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.js +2 -4
  21. package/dist/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.js.map +1 -1
  22. package/dist/adapters/entity-rest/types.d.ts +10 -1
  23. package/dist/adapters/entity-rest/types.d.ts.map +1 -1
  24. package/dist/adapters/entity-rest/types.js.map +1 -1
  25. package/dist/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.d.ts +1 -3
  26. package/dist/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.d.ts.map +1 -1
  27. package/dist/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.js +16 -17
  28. package/dist/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.js.map +1 -1
  29. package/package.json +4 -5
package/README.md CHANGED
@@ -10,6 +10,26 @@ It also reads the entity metadata a service serves, and the status of a write th
10
10
  pnpm add @entifix/rest effect
11
11
  ```
12
12
 
13
+ ## Use
14
+
15
+ An adapter is built with the configuration it resolves URLs through, so the repository it makes requires nothing from its environment:
16
+
17
+ ```ts
18
+ const options: BuildEntityRestOptions = {
19
+ uriConfig: { key: 'service-domain.[entity]' },
20
+ configuration, // a ConfigurationClient, e.g. new ConfigurationClientRestClient()
21
+ };
22
+
23
+ const repository = Context.make(EntityRepositoryTag, {
24
+ get: buildEntityRestAdapterGet(Book, options),
25
+ load: buildEntityRestAdapterLoad(Book, options),
26
+ save: buildEntityRestAdapterSave(Book, options),
27
+ delete: buildEntityRestAdapterDelete(Book, options),
28
+ });
29
+
30
+ const status = buildTransactionStatusReader(options); // a TransactionStatusReader
31
+ ```
32
+
13
33
  ## Entry points
14
34
 
15
35
  | Import | What it holds |
@@ -1,4 +1,3 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { Entity, EntityConstructor, EntityId } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { BuildEntityRestOptions } from '../types.js';
@@ -9,5 +8,5 @@ import { BuildEntityRestOptions } from '../types.js';
9
8
  * envelope rather than a bare `204`: the shared fetch client always parses the
10
9
  * response as JSON, and an empty body would fail that parse.
11
10
  */
12
- export declare const buildEntityRestAdapterDelete: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(entityOrId: EntityId | TEntity_1) => Effect.Effect<undefined, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, ConfigurationRepositoryTag>;
11
+ export declare const buildEntityRestAdapterDelete: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig, configuration }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(entityOrId: EntityId | TEntity_1) => Effect.Effect<undefined, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, never>;
13
12
  //# sourceMappingURL=build-entity-rest-adapter-delete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-entity-rest-adapter-delete.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAEL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AASrD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACtC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,eAAe,sBAAsB,MAEtC,SAAO,SAAS,MAAM,EAAE,YAAY,QAAQ,GAAG,SAAO,+IA0BnD,CAAC"}
1
+ {"version":3,"file":"build-entity-rest-adapter-delete.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EAET,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AASrD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACtC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,8BAA8B,sBAAsB,MAErD,SAAO,SAAS,MAAM,EAAE,YAAY,QAAQ,GAAG,SAAO,0HAyBnD,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { EntifixLogicError, extractMetaEntity } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';
@@ -12,9 +11,8 @@ import { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-r
12
11
  * The response body is discarded, but the service still answers with an
13
12
  * envelope rather than a bare `204`: the shared fetch client always parses the
14
13
  * response as JSON, and an empty body would fail that parse.
15
- */ export const buildEntityRestAdapterDelete = (entityConstructor, { uriConfig })=>(entityOrId)=>Effect.gen(function*() {
14
+ */ export const buildEntityRestAdapterDelete = (entityConstructor, { uriConfig, configuration })=>(entityOrId)=>Effect.gen(function*() {
16
15
  var _metaEntity_key;
17
- const configurationStore = yield* ConfigurationRepositoryTag;
18
16
  const metaEntity = extractMetaEntity(entityConstructor);
19
17
  const id = toEntityId(entityOrId);
20
18
  if (id == null) {
@@ -22,7 +20,7 @@ import { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-r
22
20
  entity: entityConstructor.name
23
21
  }));
24
22
  }
25
- const url = yield* adapterMixins.buildEntityBaseUrl(configurationStore, {
23
+ const url = yield* adapterMixins.buildEntityBaseUrl(configuration, {
26
24
  uriConfig
27
25
  }, (_metaEntity_key = metaEntity.key) != null ? _metaEntity_key : metaEntity.name, String(id));
28
26
  yield* performHttpRequestThroughFetch(adapterMixins.buildEntityRequest({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.ts"],"sourcesContent":["import { ConfigurationRepositoryTag } from '@entifix/business';\nimport {\n EntifixLogicError,\n Entity,\n EntityConstructor,\n EntityId,\n extractMetaEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\n/** Accepts either an id or a whole entity, mirroring the repository contract. */\nfunction toEntityId(entityOrId: EntityId | Entity): EntityId {\n return entityOrId != null && typeof entityOrId === 'object'\n ? (entityOrId as Entity).id\n : (entityOrId as EntityId);\n}\n\n/**\n * Deletes an entity over HTTP.\n *\n * The response body is discarded, but the service still answers with an\n * envelope rather than a bare `204`: the shared fetch client always parses the\n * response as JSON, and an empty body would fail that parse.\n */\nexport const buildEntityRestAdapterDelete =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(entityOrId: EntityId | TEntity) =>\n Effect.gen(function* () {\n const configurationStore = yield* ConfigurationRepositoryTag;\n const metaEntity = extractMetaEntity(entityConstructor);\n const id = toEntityId(entityOrId);\n\n if (id == null) {\n return yield* Effect.fail(\n new EntifixLogicError(\n `Cannot delete a ${entityConstructor.name} without an id`,\n undefined,\n { entity: entityConstructor.name },\n ),\n );\n }\n\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configurationStore,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n String(id),\n );\n\n yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'DELETE', url }),\n );\n });\n"],"names":["ConfigurationRepositoryTag","EntifixLogicError","extractMetaEntity","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","toEntityId","entityOrId","id","buildEntityRestAdapterDelete","entityConstructor","uriConfig","gen","metaEntity","configurationStore","fail","name","undefined","entity","url","buildEntityBaseUrl","key","String","buildEntityRequest","method"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,oBAAoB;AAC/D,SACEC,iBAAiB,EAIjBC,iBAAiB,QACZ,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,+EAA+E,GAC/E,SAASC,WAAWC,UAA6B;IAC/C,OAAOA,cAAc,QAAQ,OAAOA,eAAe,WAC/C,AAACA,WAAsBC,EAAE,GACxBD;AACP;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,+BACX,CACEC,mBACA,EAAEC,SAAS,EAA0B,GAEvC,CAAyBJ,aACvBL,OAAOU,GAAG,CAAC;gBAkBPC;YAjBF,MAAMC,qBAAqB,OAAOf;YAClC,MAAMc,aAAaZ,kBAAkBS;YACrC,MAAMF,KAAKF,WAAWC;YAEtB,IAAIC,MAAM,MAAM;gBACd,OAAO,OAAON,OAAOa,IAAI,CACvB,IAAIf,kBACF,CAAC,gBAAgB,EAAEU,kBAAkBM,IAAI,CAAC,cAAc,CAAC,EACzDC,WACA;oBAAEC,QAAQR,kBAAkBM,IAAI;gBAAC;YAGvC;YAEA,MAAMG,MAAM,OAAOd,cAAce,kBAAkB,CACjDN,oBACA;gBAAEH;YAAU,IACZE,kBAAAA,WAAWQ,GAAG,YAAdR,kBAAkBA,WAAWG,IAAI,EACjCM,OAAOd;YAGT,OAAOL,+BACLE,cAAckB,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAUL;YAAI;QAE7D,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-delete/build-entity-rest-adapter-delete.ts"],"sourcesContent":["import {\n EntifixLogicError,\n Entity,\n EntityConstructor,\n EntityId,\n extractMetaEntity,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\n/** Accepts either an id or a whole entity, mirroring the repository contract. */\nfunction toEntityId(entityOrId: EntityId | Entity): EntityId {\n return entityOrId != null && typeof entityOrId === 'object'\n ? (entityOrId as Entity).id\n : (entityOrId as EntityId);\n}\n\n/**\n * Deletes an entity over HTTP.\n *\n * The response body is discarded, but the service still answers with an\n * envelope rather than a bare `204`: the shared fetch client always parses the\n * response as JSON, and an empty body would fail that parse.\n */\nexport const buildEntityRestAdapterDelete =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, configuration }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(entityOrId: EntityId | TEntity) =>\n Effect.gen(function* () {\n const metaEntity = extractMetaEntity(entityConstructor);\n const id = toEntityId(entityOrId);\n\n if (id == null) {\n return yield* Effect.fail(\n new EntifixLogicError(\n `Cannot delete a ${entityConstructor.name} without an id`,\n undefined,\n { entity: entityConstructor.name },\n ),\n );\n }\n\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configuration,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n String(id),\n );\n\n yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'DELETE', url }),\n );\n });\n"],"names":["EntifixLogicError","extractMetaEntity","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","toEntityId","entityOrId","id","buildEntityRestAdapterDelete","entityConstructor","uriConfig","configuration","gen","metaEntity","fail","name","undefined","entity","url","buildEntityBaseUrl","key","String","buildEntityRequest","method"],"mappings":"AAAA,SACEA,iBAAiB,EAIjBC,iBAAiB,QACZ,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,+EAA+E,GAC/E,SAASC,WAAWC,UAA6B;IAC/C,OAAOA,cAAc,QAAQ,OAAOA,eAAe,WAC/C,AAACA,WAAsBC,EAAE,GACxBD;AACP;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,+BACX,CACEC,mBACA,EAAEC,SAAS,EAAEC,aAAa,EAA0B,GAEtD,CAAyBL,aACvBL,OAAOW,GAAG,CAAC;gBAiBPC;YAhBF,MAAMA,aAAab,kBAAkBS;YACrC,MAAMF,KAAKF,WAAWC;YAEtB,IAAIC,MAAM,MAAM;gBACd,OAAO,OAAON,OAAOa,IAAI,CACvB,IAAIf,kBACF,CAAC,gBAAgB,EAAEU,kBAAkBM,IAAI,CAAC,cAAc,CAAC,EACzDC,WACA;oBAAEC,QAAQR,kBAAkBM,IAAI;gBAAC;YAGvC;YAEA,MAAMG,MAAM,OAAOd,cAAce,kBAAkB,CACjDR,eACA;gBAAED;YAAU,IACZG,kBAAAA,WAAWO,GAAG,YAAdP,kBAAkBA,WAAWE,IAAI,EACjCM,OAAOd;YAGT,OAAOL,+BACLE,cAAckB,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAUL;YAAI;QAE7D,GAAG"}
@@ -1,6 +1,5 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { Entity, EntityConstructor } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { BuildEntityRestOptions } from '../types.js';
5
- export declare const buildEntityRestAdapterGet: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(entityId: string) => Effect.Effect<TEntity_1, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, ConfigurationRepositoryTag>;
4
+ export declare const buildEntityRestAdapterGet: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig, configuration }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(entityId: string) => Effect.Effect<TEntity_1, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, never>;
6
5
  //# sourceMappingURL=build-entity-rest-adapter-get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-entity-rest-adapter-get.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,MAAM,EACN,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,yBAAyB,GACnC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,eAAe,sBAAsB,MAEtC,SAAO,SAAS,MAAM,EAAE,UAAU,MAAM,+IAqBrC,CAAC"}
1
+ {"version":3,"file":"build-entity-rest-adapter-get.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,yBAAyB,GACnC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,8BAA8B,sBAAsB,MAErD,SAAO,SAAS,MAAM,EAAE,UAAU,MAAM,0HAoBrC,CAAC"}
@@ -1,13 +1,11 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { extractMetaEntity, readEntityEnvelope } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';
5
4
  import { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';
6
- export const buildEntityRestAdapterGet = (entityConstructor, { uriConfig })=>(entityId)=>Effect.gen(function*() {
5
+ export const buildEntityRestAdapterGet = (entityConstructor, { uriConfig, configuration })=>(entityId)=>Effect.gen(function*() {
7
6
  var _metaEntity_key;
8
- const configurationStore = yield* ConfigurationRepositoryTag;
9
7
  const metaEntity = extractMetaEntity(entityConstructor);
10
- const entityUrl = yield* adapterMixins.buildEntityBaseUrl(configurationStore, {
8
+ const entityUrl = yield* adapterMixins.buildEntityBaseUrl(configuration, {
11
9
  uriConfig
12
10
  }, (_metaEntity_key = metaEntity.key) != null ? _metaEntity_key : metaEntity.name, entityId);
13
11
  const response = yield* performHttpRequestThroughFetch(adapterMixins.buildEntityRequest({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.ts"],"sourcesContent":["import { ConfigurationRepositoryTag } from '@entifix/business';\nimport {\n Entity,\n EntityConstructor,\n extractMetaEntity,\n readEntityEnvelope,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\nexport const buildEntityRestAdapterGet =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(entityId: string) =>\n Effect.gen(function* () {\n const configurationStore = yield* ConfigurationRepositoryTag;\n const metaEntity = extractMetaEntity(entityConstructor);\n\n const entityUrl = yield* adapterMixins.buildEntityBaseUrl(\n configurationStore,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n entityId,\n );\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url: entityUrl }),\n );\n const entity = yield* readEntityEnvelope(\n entityConstructor,\n response.body,\n );\n\n return entity as unknown as TEntity;\n });\n"],"names":["ConfigurationRepositoryTag","extractMetaEntity","readEntityEnvelope","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterGet","entityConstructor","uriConfig","entityId","gen","metaEntity","configurationStore","entityUrl","buildEntityBaseUrl","key","name","response","buildEntityRequest","method","url","entity","body"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,oBAAoB;AAC/D,SAGEC,iBAAiB,EACjBC,kBAAkB,QACb,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,OAAO,MAAMC,4BACX,CACEC,mBACA,EAAEC,SAAS,EAA0B,GAEvC,CAAyBC,WACvBP,OAAOQ,GAAG,CAAC;gBAOPC;YANF,MAAMC,qBAAqB,OAAOb;YAClC,MAAMY,aAAaX,kBAAkBO;YAErC,MAAMM,YAAY,OAAOR,cAAcS,kBAAkB,CACvDF,oBACA;gBAAEJ;YAAU,IACZG,kBAAAA,WAAWI,GAAG,YAAdJ,kBAAkBA,WAAWK,IAAI,EACjCP;YAGF,MAAMQ,WAAW,OAAOd,+BACtBE,cAAca,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAOC,KAAKP;YAAU;YAEnE,MAAMQ,SAAS,OAAOpB,mBACpBM,mBACAU,SAASK,IAAI;YAGf,OAAOD;QACT,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-get/build-entity-rest-adapter-get.ts"],"sourcesContent":["import {\n Entity,\n EntityConstructor,\n extractMetaEntity,\n readEntityEnvelope,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\nexport const buildEntityRestAdapterGet =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, configuration }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(entityId: string) =>\n Effect.gen(function* () {\n const metaEntity = extractMetaEntity(entityConstructor);\n\n const entityUrl = yield* adapterMixins.buildEntityBaseUrl(\n configuration,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n entityId,\n );\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url: entityUrl }),\n );\n const entity = yield* readEntityEnvelope(\n entityConstructor,\n response.body,\n );\n\n return entity as unknown as TEntity;\n });\n"],"names":["extractMetaEntity","readEntityEnvelope","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterGet","entityConstructor","uriConfig","configuration","entityId","gen","metaEntity","entityUrl","buildEntityBaseUrl","key","name","response","buildEntityRequest","method","url","entity","body"],"mappings":"AAAA,SAGEA,iBAAiB,EACjBC,kBAAkB,QACb,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,OAAO,MAAMC,4BACX,CACEC,mBACA,EAAEC,SAAS,EAAEC,aAAa,EAA0B,GAEtD,CAAyBC,WACvBR,OAAOS,GAAG,CAAC;gBAMPC;YALF,MAAMA,aAAaZ,kBAAkBO;YAErC,MAAMM,YAAY,OAAOR,cAAcS,kBAAkB,CACvDL,eACA;gBAAED;YAAU,IACZI,kBAAAA,WAAWG,GAAG,YAAdH,kBAAkBA,WAAWI,IAAI,EACjCN;YAGF,MAAMO,WAAW,OAAOd,+BACtBE,cAAca,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAOC,KAAKP;YAAU;YAEnE,MAAMQ,SAAS,OAAOpB,mBACpBM,mBACAU,SAASK,IAAI;YAGf,OAAOD;QACT,GAAG"}
@@ -1,6 +1,5 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { Entity, EntityConstructor, EntityLoadRequest, EntityPage } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { BuildEntityRestOptions } from '../types.js';
5
- export declare const buildEntityRestAdapterLoad: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(request: EntityLoadRequest<TEntity_1>) => Effect.Effect<EntityPage<TEntity_1>, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, ConfigurationRepositoryTag>;
4
+ export declare const buildEntityRestAdapterLoad: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig, configuration }: BuildEntityRestOptions) => <TEntity_1 extends Entity>(request: EntityLoadRequest<TEntity_1>) => Effect.Effect<EntityPage<TEntity_1>, import("@entifix/core").EntifixBuildError | import("@entifix/core").EntifixConnError, never>;
6
5
  //# sourceMappingURL=build-entity-rest-adapter-load.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-entity-rest-adapter-load.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAIX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,0BAA0B,GACpC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,eAAe,sBAAsB,MAEtC,SAAO,SAAS,MAAM,EAAE,SAAS,iBAAiB,CAAC,SAAO,CAAC,2JA+BxD,CAAC"}
1
+ {"version":3,"file":"build-entity-rest-adapter-load.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAIX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,eAAO,MAAM,0BAA0B,GACpC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,8BAA8B,sBAAsB,MAErD,SAAO,SAAS,MAAM,EAAE,SAAS,iBAAiB,CAAC,SAAO,CAAC,sIA8BxD,CAAC"}
@@ -1,14 +1,12 @@
1
1
  import { _ as _extends } from "@swc/helpers/_/_extends";
2
- import { ConfigurationRepositoryTag } from '@entifix/business';
3
2
  import { extractMetaEntity, readEntityPageEnvelope, serializeLoadRequestParams } from '@entifix/core';
4
3
  import { Effect } from 'effect';
5
4
  import { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';
6
5
  import { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';
7
- export const buildEntityRestAdapterLoad = (entityConstructor, { uriConfig })=>(request)=>Effect.gen(function*() {
6
+ export const buildEntityRestAdapterLoad = (entityConstructor, { uriConfig, configuration })=>(request)=>Effect.gen(function*() {
8
7
  var _metaEntity_key;
9
- const configurationStore = yield* ConfigurationRepositoryTag;
10
8
  const metaEntity = extractMetaEntity(entityConstructor);
11
- const baseUrl = yield* adapterMixins.buildEntityBaseUrl(configurationStore, {
9
+ const baseUrl = yield* adapterMixins.buildEntityBaseUrl(configuration, {
12
10
  uriConfig
13
11
  }, (_metaEntity_key = metaEntity.key) != null ? _metaEntity_key : metaEntity.name);
14
12
  // Filtering goes out as RSQL and sorting as `sort` — the shared query
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.ts"],"sourcesContent":["import { ConfigurationRepositoryTag } from '@entifix/business';\nimport {\n Entity,\n EntityConstructor,\n EntityLoadRequest,\n EntityPage,\n extractMetaEntity,\n readEntityPageEnvelope,\n serializeLoadRequestParams,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\nexport const buildEntityRestAdapterLoad =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(request: EntityLoadRequest<TEntity>) =>\n Effect.gen(function* () {\n const configurationStore = yield* ConfigurationRepositoryTag;\n const metaEntity = extractMetaEntity(entityConstructor);\n\n const baseUrl = yield* adapterMixins.buildEntityBaseUrl(\n configurationStore,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n );\n\n // Filtering goes out as RSQL and sorting as `sort` — the shared query\n // protocol in core, so what this composes is exactly what the service\n // parses back.\n const query = serializeLoadRequestParams(request).toString();\n const url = query ? `${baseUrl}?${query}` : baseUrl;\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url }),\n );\n const page = yield* readEntityPageEnvelope(\n entityConstructor,\n response.body,\n );\n\n // The envelope echoes the request the service actually served; prefer the\n // one this call made, which carries the caller's filtering/sorting types.\n return {\n ...page,\n request,\n } as unknown as EntityPage<TEntity>;\n });\n"],"names":["ConfigurationRepositoryTag","extractMetaEntity","readEntityPageEnvelope","serializeLoadRequestParams","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterLoad","entityConstructor","uriConfig","request","gen","metaEntity","configurationStore","baseUrl","buildEntityBaseUrl","key","name","query","toString","url","response","buildEntityRequest","method","page","body"],"mappings":";AAAA,SAASA,0BAA0B,QAAQ,oBAAoB;AAC/D,SAKEC,iBAAiB,EACjBC,sBAAsB,EACtBC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,OAAO,MAAMC,6BACX,CACEC,mBACA,EAAEC,SAAS,EAA0B,GAEvC,CAAyBC,UACvBP,OAAOQ,GAAG,CAAC;gBAOPC;YANF,MAAMC,qBAAqB,OAAOd;YAClC,MAAMa,aAAaZ,kBAAkBQ;YAErC,MAAMM,UAAU,OAAOR,cAAcS,kBAAkB,CACrDF,oBACA;gBAAEJ;YAAU,IACZG,kBAAAA,WAAWI,GAAG,YAAdJ,kBAAkBA,WAAWK,IAAI;YAGnC,sEAAsE;YACtE,sEAAsE;YACtE,eAAe;YACf,MAAMC,QAAQhB,2BAA2BQ,SAASS,QAAQ;YAC1D,MAAMC,MAAMF,QAAQ,GAAGJ,QAAQ,CAAC,EAAEI,OAAO,GAAGJ;YAE5C,MAAMO,WAAW,OAAOjB,+BACtBE,cAAcgB,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAOH;YAAI;YAExD,MAAMI,OAAO,OAAOvB,uBAClBO,mBACAa,SAASI,IAAI;YAGf,0EAA0E;YAC1E,0EAA0E;YAC1E,OAAO,aACFD;gBACHd;;QAEJ,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-load/build-entity-rest-adapter-load.ts"],"sourcesContent":["import {\n Entity,\n EntityConstructor,\n EntityLoadRequest,\n EntityPage,\n extractMetaEntity,\n readEntityPageEnvelope,\n serializeLoadRequestParams,\n} from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\nexport const buildEntityRestAdapterLoad =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, configuration }: BuildEntityRestOptions,\n ) =>\n <TEntity extends Entity>(request: EntityLoadRequest<TEntity>) =>\n Effect.gen(function* () {\n const metaEntity = extractMetaEntity(entityConstructor);\n\n const baseUrl = yield* adapterMixins.buildEntityBaseUrl(\n configuration,\n { uriConfig },\n metaEntity.key ?? metaEntity.name,\n );\n\n // Filtering goes out as RSQL and sorting as `sort` — the shared query\n // protocol in core, so what this composes is exactly what the service\n // parses back.\n const query = serializeLoadRequestParams(request).toString();\n const url = query ? `${baseUrl}?${query}` : baseUrl;\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url }),\n );\n const page = yield* readEntityPageEnvelope(\n entityConstructor,\n response.body,\n );\n\n // The envelope echoes the request the service actually served; prefer the\n // one this call made, which carries the caller's filtering/sorting types.\n return {\n ...page,\n request,\n } as unknown as EntityPage<TEntity>;\n });\n"],"names":["extractMetaEntity","readEntityPageEnvelope","serializeLoadRequestParams","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterLoad","entityConstructor","uriConfig","configuration","request","gen","metaEntity","baseUrl","buildEntityBaseUrl","key","name","query","toString","url","response","buildEntityRequest","method","page","body"],"mappings":";AAAA,SAKEA,iBAAiB,EACjBC,sBAAsB,EACtBC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G,OAAO,MAAMC,6BACX,CACEC,mBACA,EAAEC,SAAS,EAAEC,aAAa,EAA0B,GAEtD,CAAyBC,UACvBR,OAAOS,GAAG,CAAC;gBAMPC;YALF,MAAMA,aAAab,kBAAkBQ;YAErC,MAAMM,UAAU,OAAOR,cAAcS,kBAAkB,CACrDL,eACA;gBAAED;YAAU,IACZI,kBAAAA,WAAWG,GAAG,YAAdH,kBAAkBA,WAAWI,IAAI;YAGnC,sEAAsE;YACtE,sEAAsE;YACtE,eAAe;YACf,MAAMC,QAAQhB,2BAA2BS,SAASQ,QAAQ;YAC1D,MAAMC,MAAMF,QAAQ,GAAGJ,QAAQ,CAAC,EAAEI,OAAO,GAAGJ;YAE5C,MAAMO,WAAW,OAAOjB,+BACtBE,cAAcgB,kBAAkB,CAAC;gBAAEC,QAAQ;gBAAOH;YAAI;YAExD,MAAMI,OAAO,OAAOvB,uBAClBO,mBACAa,SAASI,IAAI;YAGf,0EAA0E;YAC1E,0EAA0E;YAC1E,OAAO,aACFD;gBACHb;;QAEJ,GAAG"}
@@ -1,5 +1,5 @@
1
1
  import { ConfigurationClient } from '@entifix/core';
2
2
  import { Effect } from 'effect';
3
3
  import { BuildEntityRestOptions } from '../types.js';
4
- export declare const buildEntityBaseUrl: (configurationStore: ConfigurationClient, options: BuildEntityRestOptions, entityName: string, entityId?: string) => Effect.Effect<string, import("@entifix/core").EntifixBuildError, never>;
4
+ export declare const buildEntityBaseUrl: (configurationStore: ConfigurationClient, options: Pick<BuildEntityRestOptions, "uriConfig">, entityName: string, entityId?: string) => Effect.Effect<string, import("@entifix/core").EntifixBuildError, never>;
5
5
  //# sourceMappingURL=build-entity-base-url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-entity-base-url.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrD,eAAO,MAAM,kBAAkB,GAC7B,oBAAoB,mBAAmB,EACvC,SAAS,sBAAsB,EAC/B,YAAY,MAAM,EAClB,WAAW,MAAM,4EAYf,CAAC"}
1
+ {"version":3,"file":"build-entity-base-url.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIrD,eAAO,MAAM,kBAAkB,GAC7B,oBAAoB,mBAAmB,EACvC,SAAS,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,EAClD,YAAY,MAAM,EAClB,WAAW,MAAM,4EAYf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.ts"],"sourcesContent":["import { ConfigurationClient } from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { BuildEntityRestOptions } from '../types.js';\n\nconst DEFAULT_URI_GROUP = 'restUri';\n\nexport const buildEntityBaseUrl = (\n configurationStore: ConfigurationClient,\n options: BuildEntityRestOptions,\n entityName: string,\n entityId?: string,\n) =>\n Effect.gen(function* () {\n const { uriConfig } = options;\n const entityUri = yield* configurationStore\n .in(uriConfig.group ?? DEFAULT_URI_GROUP)\n .getString(\n uriConfig.key.replace('[entity]', entityName),\n uriConfig.extractionMode,\n );\n\n return entityId ? `${entityUri}/${entityId}` : entityUri;\n });\n"],"names":["Effect","DEFAULT_URI_GROUP","buildEntityBaseUrl","configurationStore","options","entityName","entityId","gen","uriConfig","entityUri","in","group","getString","key","replace","extractionMode"],"mappings":"AACA,SAASA,MAAM,QAAQ,SAAS;AAIhC,MAAMC,oBAAoB;AAE1B,OAAO,MAAMC,qBAAqB,CAChCC,oBACAC,SACAC,YACAC,WAEAN,OAAOO,GAAG,CAAC;YAGHC;QAFN,MAAM,EAAEA,SAAS,EAAE,GAAGJ;QACtB,MAAMK,YAAY,OAAON,mBACtBO,EAAE,EAACF,mBAAAA,UAAUG,KAAK,YAAfH,mBAAmBP,mBACtBW,SAAS,CACRJ,UAAUK,GAAG,CAACC,OAAO,CAAC,YAAYT,aAClCG,UAAUO,cAAc;QAG5B,OAAOT,WAAW,GAAGG,UAAU,CAAC,EAAEH,UAAU,GAAGG;IACjD,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-mixins/build-entity-base-url.ts"],"sourcesContent":["import { ConfigurationClient } from '@entifix/core';\nimport { Effect } from 'effect';\n\nimport { BuildEntityRestOptions } from '../types.js';\n\nconst DEFAULT_URI_GROUP = 'restUri';\n\nexport const buildEntityBaseUrl = (\n configurationStore: ConfigurationClient,\n options: Pick<BuildEntityRestOptions, 'uriConfig'>,\n entityName: string,\n entityId?: string,\n) =>\n Effect.gen(function* () {\n const { uriConfig } = options;\n const entityUri = yield* configurationStore\n .in(uriConfig.group ?? DEFAULT_URI_GROUP)\n .getString(\n uriConfig.key.replace('[entity]', entityName),\n uriConfig.extractionMode,\n );\n\n return entityId ? `${entityUri}/${entityId}` : entityUri;\n });\n"],"names":["Effect","DEFAULT_URI_GROUP","buildEntityBaseUrl","configurationStore","options","entityName","entityId","gen","uriConfig","entityUri","in","group","getString","key","replace","extractionMode"],"mappings":"AACA,SAASA,MAAM,QAAQ,SAAS;AAIhC,MAAMC,oBAAoB;AAE1B,OAAO,MAAMC,qBAAqB,CAChCC,oBACAC,SACAC,YACAC,WAEAN,OAAOO,GAAG,CAAC;YAGHC;QAFN,MAAM,EAAEA,SAAS,EAAE,GAAGJ;QACtB,MAAMK,YAAY,OAAON,mBACtBO,EAAE,EAACF,mBAAAA,UAAUG,KAAK,YAAfH,mBAAmBP,mBACtBW,SAAS,CACRJ,UAAUK,GAAG,CAACC,OAAO,CAAC,YAAYT,aAClCG,UAAUO,cAAc;QAG5B,OAAOT,WAAW,GAAGG,UAAU,CAAC,EAAEH,UAAU,GAAGG;IACjD,GAAG"}
@@ -1,5 +1,5 @@
1
1
  export declare const buildEntityRestAdapterMixins: {
2
- buildEntityBaseUrl: (configurationStore: import("@entifix/core").ConfigurationClient, options: import("../types.js").BuildEntityRestOptions, entityName: string, entityId?: string) => import("effect/Effect").Effect<string, import("@entifix/core").EntifixBuildError, never>;
2
+ buildEntityBaseUrl: (configurationStore: import("@entifix/core").ConfigurationClient, options: Pick<import("../types.js").BuildEntityRestOptions, "uriConfig">, entityName: string, entityId?: string) => import("effect/Effect").Effect<string, import("@entifix/core").EntifixBuildError, never>;
3
3
  buildEntityRequest: ({ method, url, envelope, }: import("./build-entity-request.js").BuildEntityRequestOptions) => import("../../../index.js").HttpRequest<import("@entifix/core").EntifixEnvelope<unknown>>;
4
4
  };
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { Entity, EntityConstructor } from '@entifix/core';
3
2
  import { Effect } from 'effect';
4
3
  import { BuildEntityRestOptions } from '../types.js';
@@ -21,5 +20,5 @@ import { BuildEntityRestOptions } from '../types.js';
21
20
  * adapter parsed the `202` as an entity envelope, failed, and reported an error
22
21
  * for a create that was in fact about to succeed.
23
22
  */
24
- export declare const buildEntityRestAdapterSave: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig, create }: BuildEntityRestOptions) => <TInput extends Entity>(entity: TInput) => Effect.Effect<TInput, import("@entifix/core").EntifixError, ConfigurationRepositoryTag>;
23
+ export declare const buildEntityRestAdapterSave: <TEntity extends Entity>(entityConstructor: EntityConstructor<TEntity>, { uriConfig, create, configuration }: BuildEntityRestOptions) => <TInput extends Entity>(entity: TInput) => Effect.Effect<TInput, import("@entifix/core").EntifixError, never>;
25
24
  //# sourceMappingURL=build-entity-rest-adapter-save.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-entity-rest-adapter-save.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,MAAM,EACN,iBAAiB,EAKlB,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,GACpC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,uBAAkC,sBAAsB,MAKzD,MAAM,SAAS,MAAM,EAAE,QAAQ,MAAM,4FAkFlC,CAAC"}
1
+ {"version":3,"file":"build-entity-rest-adapter-save.d.ts","sourceRoot":"","sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,iBAAiB,EAKlB,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,GACpC,OAAO,SAAS,MAAM,EACrB,mBAAmB,iBAAiB,CAAC,OAAO,CAAC,EAC7C,sCAAiD,sBAAsB,MAKxE,MAAM,SAAS,MAAM,EAAE,QAAQ,MAAM,uEAiFlC,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { extractMetaEntity, makeEntityEnvelope, readEntityEnvelope, serializeEntity } from '@entifix/core';
3
2
  import { makeCommandEnvelope, readTransactionAcceptedEnvelope, TransactionSinkTag } from '@entifix/transactions';
4
3
  import { Effect, Option } from 'effect';
@@ -22,16 +21,15 @@ import { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-r
22
21
  * That is the point of the client owning the id (ADR 0028) — before it, this
23
22
  * adapter parsed the `202` as an entity envelope, failed, and reported an error
24
23
  * for a create that was in fact about to succeed.
25
- */ export const buildEntityRestAdapterSave = (entityConstructor, { uriConfig, create = 'entity' })=>// Deliberately not shadowing `TEntity` here (as the read builders do): the
24
+ */ export const buildEntityRestAdapterSave = (entityConstructor, { uriConfig, create = 'entity', configuration })=>// Deliberately not shadowing `TEntity` here (as the read builders do): the
26
25
  // envelope has to be built against the *constructor's* entity type, which a
27
26
  // shadowed parameter would make unreachable.
28
27
  (entity)=>Effect.gen(function*() {
29
28
  var _metaEntity_key;
30
- const configurationStore = yield* ConfigurationRepositoryTag;
31
29
  const metaEntity = extractMetaEntity(entityConstructor);
32
30
  const key = (_metaEntity_key = metaEntity.key) != null ? _metaEntity_key : metaEntity.name;
33
31
  const isCreate = entity.id == null;
34
- const url = yield* adapterMixins.buildEntityBaseUrl(configurationStore, {
32
+ const url = yield* adapterMixins.buildEntityBaseUrl(configuration, {
35
33
  uriConfig
36
34
  }, key, isCreate ? undefined : String(entity.id));
37
35
  if (isCreate && create === 'command') {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.ts"],"sourcesContent":["import { ConfigurationRepositoryTag } from '@entifix/business';\nimport {\n Entity,\n EntityConstructor,\n extractMetaEntity,\n makeEntityEnvelope,\n readEntityEnvelope,\n serializeEntity,\n} from '@entifix/core';\nimport {\n makeCommandEnvelope,\n readTransactionAcceptedEnvelope,\n type TransactionCommand,\n TransactionSinkTag,\n} from '@entifix/transactions';\nimport { Effect, Option } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\n/**\n * Persists an entity over HTTP.\n *\n * An entity without an id has never been stored, so it is created with `POST`\n * against the collection; one with an id is replaced with `PUT` against its own\n * URL.\n *\n * For a plain create the response envelope — not the request — is what gets\n * deserialized and returned, because the service is the authority on the stored\n * entity (it assigns ids and may normalize fields).\n *\n * A **transactional** create inverts that, and deliberately. The service answers\n * `202` describing a transaction rather than an entity, so there is no stored\n * entity to read back yet: the client mints the transaction id, which *is* the\n * id the entity will be stored under, and returns the entity it already holds.\n * That is the point of the client owning the id (ADR 0028) — before it, this\n * adapter parsed the `202` as an entity envelope, failed, and reported an error\n * for a create that was in fact about to succeed.\n */\nexport const buildEntityRestAdapterSave =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, create = 'entity' }: BuildEntityRestOptions,\n ) =>\n // Deliberately not shadowing `TEntity` here (as the read builders do): the\n // envelope has to be built against the *constructor's* entity type, which a\n // shadowed parameter would make unreachable.\n <TInput extends Entity>(entity: TInput) =>\n Effect.gen(function* () {\n const configurationStore = yield* ConfigurationRepositoryTag;\n const metaEntity = extractMetaEntity(entityConstructor);\n const key = metaEntity.key ?? metaEntity.name;\n const isCreate = entity.id == null;\n\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configurationStore,\n { uriConfig },\n key,\n isCreate ? undefined : String(entity.id),\n );\n\n if (isCreate && create === 'command') {\n // `crypto.randomUUID` is available in every browser this ships to and in\n // Node — and the id must be a UUID, because the service constrains the\n // key space a caller may address.\n const transactionId = crypto.randomUUID();\n entity.id = transactionId;\n\n const command: TransactionCommand = {\n transactionId,\n type: 'create',\n entity: key,\n payload: serializeEntity(\n entityConstructor,\n entity as unknown as TEntity,\n ),\n };\n\n const accepted = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({\n method: 'POST',\n url,\n envelope: makeCommandEnvelope(command),\n }),\n );\n // Read for its shape, not its contents: this asserts the service really\n // accepted a transaction rather than answering something else with a\n // 2xx, which is the failure the old code path could not distinguish.\n yield* readTransactionAcceptedEnvelope(accepted.body);\n\n // Tell whoever is watching that a write is in flight. This is the only\n // point in the system that knows it — the entity returned below is\n // indistinguishable from a plain REST create, so without this the\n // browser navigates away at the `202` and a later failure leaves no row,\n // no message and nothing to retry from (ADR 0043).\n //\n // `serviceOption`, deliberately: reading the tag this way keeps it out\n // of this function's `R`, so the storefront, the plain REST adapters and\n // every existing spec compile and run with no layer to provide. The cost\n // is that nothing *forces* a composition root to provide it, which is\n // why `mergeContext` has a spec pinning that it does.\n const sink = yield* Effect.serviceOption(TransactionSinkTag);\n if (Option.isSome(sink)) {\n // After the assertion above, never before: a `2xx` that is not a\n // transaction envelope must not register a pending id, because nothing\n // would ever settle it and the entry becomes a permanent phantom.\n sink.value.began({\n transactionId,\n entity: key,\n at: new Date().toISOString(),\n });\n }\n\n return entity;\n }\n\n const httpRequest = adapterMixins.buildEntityRequest({\n method: isCreate ? 'POST' : 'PUT',\n url,\n envelope: makeEntityEnvelope(\n entityConstructor,\n entity as unknown as TEntity,\n ),\n });\n\n const response = yield* performHttpRequestThroughFetch(httpRequest);\n const saved = yield* readEntityEnvelope(entityConstructor, response.body);\n\n return saved as unknown as TInput;\n });\n"],"names":["ConfigurationRepositoryTag","extractMetaEntity","makeEntityEnvelope","readEntityEnvelope","serializeEntity","makeCommandEnvelope","readTransactionAcceptedEnvelope","TransactionSinkTag","Effect","Option","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterSave","entityConstructor","uriConfig","create","entity","gen","metaEntity","configurationStore","key","name","isCreate","id","url","buildEntityBaseUrl","undefined","String","transactionId","crypto","randomUUID","command","type","payload","accepted","buildEntityRequest","method","envelope","body","sink","serviceOption","isSome","value","began","at","Date","toISOString","httpRequest","response","saved"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,oBAAoB;AAC/D,SAGEC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,eAAe,QACV,gBAAgB;AACvB,SACEC,mBAAmB,EACnBC,+BAA+B,EAE/BC,kBAAkB,QACb,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AAExC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,6BACX,CACEC,mBACA,EAAEC,SAAS,EAAEC,SAAS,QAAQ,EAA0B,GAE1D,2EAA2E;IAC3E,4EAA4E;IAC5E,6CAA6C;IAC7C,CAAwBC,SACtBT,OAAOU,GAAG,CAAC;gBAGGC;YAFZ,MAAMC,qBAAqB,OAAOpB;YAClC,MAAMmB,aAAalB,kBAAkBa;YACrC,MAAMO,OAAMF,kBAAAA,WAAWE,GAAG,YAAdF,kBAAkBA,WAAWG,IAAI;YAC7C,MAAMC,WAAWN,OAAOO,EAAE,IAAI;YAE9B,MAAMC,MAAM,OAAOb,cAAcc,kBAAkB,CACjDN,oBACA;gBAAEL;YAAU,GACZM,KACAE,WAAWI,YAAYC,OAAOX,OAAOO,EAAE;YAGzC,IAAID,YAAYP,WAAW,WAAW;gBACpC,yEAAyE;gBACzE,uEAAuE;gBACvE,kCAAkC;gBAClC,MAAMa,gBAAgBC,OAAOC,UAAU;gBACvCd,OAAOO,EAAE,GAAGK;gBAEZ,MAAMG,UAA8B;oBAClCH;oBACAI,MAAM;oBACNhB,QAAQI;oBACRa,SAAS9B,gBACPU,mBACAG;gBAEJ;gBAEA,MAAMkB,WAAW,OAAOzB,+BACtBE,cAAcwB,kBAAkB,CAAC;oBAC/BC,QAAQ;oBACRZ;oBACAa,UAAUjC,oBAAoB2B;gBAChC;gBAEF,wEAAwE;gBACxE,qEAAqE;gBACrE,qEAAqE;gBACrE,OAAO1B,gCAAgC6B,SAASI,IAAI;gBAEpD,uEAAuE;gBACvE,mEAAmE;gBACnE,kEAAkE;gBAClE,yEAAyE;gBACzE,mDAAmD;gBACnD,EAAE;gBACF,uEAAuE;gBACvE,yEAAyE;gBACzE,yEAAyE;gBACzE,sEAAsE;gBACtE,sDAAsD;gBACtD,MAAMC,OAAO,OAAOhC,OAAOiC,aAAa,CAAClC;gBACzC,IAAIE,OAAOiC,MAAM,CAACF,OAAO;oBACvB,iEAAiE;oBACjE,uEAAuE;oBACvE,kEAAkE;oBAClEA,KAAKG,KAAK,CAACC,KAAK,CAAC;wBACff;wBACAZ,QAAQI;wBACRwB,IAAI,IAAIC,OAAOC,WAAW;oBAC5B;gBACF;gBAEA,OAAO9B;YACT;YAEA,MAAM+B,cAAcpC,cAAcwB,kBAAkB,CAAC;gBACnDC,QAAQd,WAAW,SAAS;gBAC5BE;gBACAa,UAAUpC,mBACRY,mBACAG;YAEJ;YAEA,MAAMgC,WAAW,OAAOvC,+BAA+BsC;YACvD,MAAME,QAAQ,OAAO/C,mBAAmBW,mBAAmBmC,SAASV,IAAI;YAExE,OAAOW;QACT,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/entity-rest/build-entity-rest-adapter-save/build-entity-rest-adapter-save.ts"],"sourcesContent":["import {\n Entity,\n EntityConstructor,\n extractMetaEntity,\n makeEntityEnvelope,\n readEntityEnvelope,\n serializeEntity,\n} from '@entifix/core';\nimport {\n makeCommandEnvelope,\n readTransactionAcceptedEnvelope,\n type TransactionCommand,\n TransactionSinkTag,\n} from '@entifix/transactions';\nimport { Effect, Option } from 'effect';\n\nimport { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';\nimport { buildEntityRestAdapterMixins as adapterMixins } from '../build-entity-rest-adapter-mixins/index.js';\nimport { BuildEntityRestOptions } from '../types.js';\n\n/**\n * Persists an entity over HTTP.\n *\n * An entity without an id has never been stored, so it is created with `POST`\n * against the collection; one with an id is replaced with `PUT` against its own\n * URL.\n *\n * For a plain create the response envelope — not the request — is what gets\n * deserialized and returned, because the service is the authority on the stored\n * entity (it assigns ids and may normalize fields).\n *\n * A **transactional** create inverts that, and deliberately. The service answers\n * `202` describing a transaction rather than an entity, so there is no stored\n * entity to read back yet: the client mints the transaction id, which *is* the\n * id the entity will be stored under, and returns the entity it already holds.\n * That is the point of the client owning the id (ADR 0028) — before it, this\n * adapter parsed the `202` as an entity envelope, failed, and reported an error\n * for a create that was in fact about to succeed.\n */\nexport const buildEntityRestAdapterSave =\n <TEntity extends Entity>(\n entityConstructor: EntityConstructor<TEntity>,\n { uriConfig, create = 'entity', configuration }: BuildEntityRestOptions,\n ) =>\n // Deliberately not shadowing `TEntity` here (as the read builders do): the\n // envelope has to be built against the *constructor's* entity type, which a\n // shadowed parameter would make unreachable.\n <TInput extends Entity>(entity: TInput) =>\n Effect.gen(function* () {\n const metaEntity = extractMetaEntity(entityConstructor);\n const key = metaEntity.key ?? metaEntity.name;\n const isCreate = entity.id == null;\n\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configuration,\n { uriConfig },\n key,\n isCreate ? undefined : String(entity.id),\n );\n\n if (isCreate && create === 'command') {\n // `crypto.randomUUID` is available in every browser this ships to and in\n // Node — and the id must be a UUID, because the service constrains the\n // key space a caller may address.\n const transactionId = crypto.randomUUID();\n entity.id = transactionId;\n\n const command: TransactionCommand = {\n transactionId,\n type: 'create',\n entity: key,\n payload: serializeEntity(\n entityConstructor,\n entity as unknown as TEntity,\n ),\n };\n\n const accepted = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({\n method: 'POST',\n url,\n envelope: makeCommandEnvelope(command),\n }),\n );\n // Read for its shape, not its contents: this asserts the service really\n // accepted a transaction rather than answering something else with a\n // 2xx, which is the failure the old code path could not distinguish.\n yield* readTransactionAcceptedEnvelope(accepted.body);\n\n // Tell whoever is watching that a write is in flight. This is the only\n // point in the system that knows it — the entity returned below is\n // indistinguishable from a plain REST create, so without this the\n // browser navigates away at the `202` and a later failure leaves no row,\n // no message and nothing to retry from (ADR 0043).\n //\n // `serviceOption`, deliberately: reading the tag this way keeps it out\n // of this function's `R`, so the storefront, the plain REST adapters and\n // every existing spec compile and run with no layer to provide. The cost\n // is that nothing *forces* a composition root to provide it, which is\n // why `mergeContext` has a spec pinning that it does.\n const sink = yield* Effect.serviceOption(TransactionSinkTag);\n if (Option.isSome(sink)) {\n // After the assertion above, never before: a `2xx` that is not a\n // transaction envelope must not register a pending id, because nothing\n // would ever settle it and the entry becomes a permanent phantom.\n sink.value.began({\n transactionId,\n entity: key,\n at: new Date().toISOString(),\n });\n }\n\n return entity;\n }\n\n const httpRequest = adapterMixins.buildEntityRequest({\n method: isCreate ? 'POST' : 'PUT',\n url,\n envelope: makeEntityEnvelope(\n entityConstructor,\n entity as unknown as TEntity,\n ),\n });\n\n const response = yield* performHttpRequestThroughFetch(httpRequest);\n const saved = yield* readEntityEnvelope(entityConstructor, response.body);\n\n return saved as unknown as TInput;\n });\n"],"names":["extractMetaEntity","makeEntityEnvelope","readEntityEnvelope","serializeEntity","makeCommandEnvelope","readTransactionAcceptedEnvelope","TransactionSinkTag","Effect","Option","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","buildEntityRestAdapterSave","entityConstructor","uriConfig","create","configuration","entity","gen","metaEntity","key","name","isCreate","id","url","buildEntityBaseUrl","undefined","String","transactionId","crypto","randomUUID","command","type","payload","accepted","buildEntityRequest","method","envelope","body","sink","serviceOption","isSome","value","began","at","Date","toISOString","httpRequest","response","saved"],"mappings":"AAAA,SAGEA,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB,EAClBC,eAAe,QACV,gBAAgB;AACvB,SACEC,mBAAmB,EACnBC,+BAA+B,EAE/BC,kBAAkB,QACb,wBAAwB;AAC/B,SAASC,MAAM,EAAEC,MAAM,QAAQ,SAAS;AAExC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,+CAA+C;AAG7G;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,6BACX,CACEC,mBACA,EAAEC,SAAS,EAAEC,SAAS,QAAQ,EAAEC,aAAa,EAA0B,GAEzE,2EAA2E;IAC3E,4EAA4E;IAC5E,6CAA6C;IAC7C,CAAwBC,SACtBV,OAAOW,GAAG,CAAC;gBAEGC;YADZ,MAAMA,aAAanB,kBAAkBa;YACrC,MAAMO,OAAMD,kBAAAA,WAAWC,GAAG,YAAdD,kBAAkBA,WAAWE,IAAI;YAC7C,MAAMC,WAAWL,OAAOM,EAAE,IAAI;YAE9B,MAAMC,MAAM,OAAOb,cAAcc,kBAAkB,CACjDT,eACA;gBAAEF;YAAU,GACZM,KACAE,WAAWI,YAAYC,OAAOV,OAAOM,EAAE;YAGzC,IAAID,YAAYP,WAAW,WAAW;gBACpC,yEAAyE;gBACzE,uEAAuE;gBACvE,kCAAkC;gBAClC,MAAMa,gBAAgBC,OAAOC,UAAU;gBACvCb,OAAOM,EAAE,GAAGK;gBAEZ,MAAMG,UAA8B;oBAClCH;oBACAI,MAAM;oBACNf,QAAQG;oBACRa,SAAS9B,gBACPU,mBACAI;gBAEJ;gBAEA,MAAMiB,WAAW,OAAOzB,+BACtBE,cAAcwB,kBAAkB,CAAC;oBAC/BC,QAAQ;oBACRZ;oBACAa,UAAUjC,oBAAoB2B;gBAChC;gBAEF,wEAAwE;gBACxE,qEAAqE;gBACrE,qEAAqE;gBACrE,OAAO1B,gCAAgC6B,SAASI,IAAI;gBAEpD,uEAAuE;gBACvE,mEAAmE;gBACnE,kEAAkE;gBAClE,yEAAyE;gBACzE,mDAAmD;gBACnD,EAAE;gBACF,uEAAuE;gBACvE,yEAAyE;gBACzE,yEAAyE;gBACzE,sEAAsE;gBACtE,sDAAsD;gBACtD,MAAMC,OAAO,OAAOhC,OAAOiC,aAAa,CAAClC;gBACzC,IAAIE,OAAOiC,MAAM,CAACF,OAAO;oBACvB,iEAAiE;oBACjE,uEAAuE;oBACvE,kEAAkE;oBAClEA,KAAKG,KAAK,CAACC,KAAK,CAAC;wBACff;wBACAX,QAAQG;wBACRwB,IAAI,IAAIC,OAAOC,WAAW;oBAC5B;gBACF;gBAEA,OAAO7B;YACT;YAEA,MAAM8B,cAAcpC,cAAcwB,kBAAkB,CAAC;gBACnDC,QAAQd,WAAW,SAAS;gBAC5BE;gBACAa,UAAUpC,mBACRY,mBACAI;YAEJ;YAEA,MAAM+B,WAAW,OAAOvC,+BAA+BsC;YACvD,MAAME,QAAQ,OAAO/C,mBAAmBW,mBAAmBmC,SAASV,IAAI;YAExE,OAAOW;QACT,GAAG"}
@@ -1,4 +1,4 @@
1
- import { ConfigurationExtractMode } from '@entifix/core';
1
+ import type { ConfigurationClient, ConfigurationExtractMode } from '@entifix/core';
2
2
  /**
3
3
  * How a create is sent to this entity's service.
4
4
  *
@@ -20,5 +20,14 @@ export interface BuildEntityRestOptions {
20
20
  };
21
21
  /** Defaults to `'entity'` — the plain REST write. */
22
22
  create?: EntityCreateProtocol;
23
+ /**
24
+ * Where `uriConfig` is looked up, bound when the adapter is built.
25
+ *
26
+ * A value rather than a requirement on each call: the URL lookup is this
27
+ * adapter's mechanism, and putting it in the repository port's environment
28
+ * made every use case — and every static or database-backed caller — provide
29
+ * a configuration it never read.
30
+ */
31
+ configuration: ConfigurationClient;
23
32
  }
24
33
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/entity-rest/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,wBAAwB,CAAC;KAC3C,CAAC;IACF,qDAAqD;IACrD,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/entity-rest/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,wBAAwB,CAAC;KAC3C,CAAC;IACF,qDAAqD;IACrD,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;;;;;OAOG;IACH,aAAa,EAAE,mBAAmB,CAAC;CACpC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/entity-rest/types.ts"],"sourcesContent":["import { ConfigurationExtractMode } from '@entifix/core';\n\n/**\n * How a create is sent to this entity's service.\n *\n * `entity` is the plain REST write: `POST` an entity envelope, get the stored\n * entity back. `command` is the CQRS write path — the client mints the\n * transaction id, `POST`s a `command` envelope and gets a `202` naming the\n * transaction, because the write completes asynchronously behind a saga.\n *\n * It is per entity rather than global because the two live side by side today:\n * `ProductSpecification` is transactional, while `ProductBrand` and\n * `ProductCategory` are plain writes on another service.\n */\nexport type EntityCreateProtocol = 'entity' | 'command';\n\nexport interface BuildEntityRestOptions {\n uriConfig: {\n key: string;\n group?: string;\n extractionMode?: ConfigurationExtractMode;\n };\n /** Defaults to `'entity'` — the plain REST write. */\n create?: EntityCreateProtocol;\n}\n"],"names":[],"mappings":"AAgBA,WAQC"}
1
+ {"version":3,"sources":["../../../src/adapters/entity-rest/types.ts"],"sourcesContent":["import type {\n ConfigurationClient,\n ConfigurationExtractMode,\n} from '@entifix/core';\n\n/**\n * How a create is sent to this entity's service.\n *\n * `entity` is the plain REST write: `POST` an entity envelope, get the stored\n * entity back. `command` is the CQRS write path — the client mints the\n * transaction id, `POST`s a `command` envelope and gets a `202` naming the\n * transaction, because the write completes asynchronously behind a saga.\n *\n * It is per entity rather than global because the two live side by side today:\n * `ProductSpecification` is transactional, while `ProductBrand` and\n * `ProductCategory` are plain writes on another service.\n */\nexport type EntityCreateProtocol = 'entity' | 'command';\n\nexport interface BuildEntityRestOptions {\n uriConfig: {\n key: string;\n group?: string;\n extractionMode?: ConfigurationExtractMode;\n };\n /** Defaults to `'entity'` — the plain REST write. */\n create?: EntityCreateProtocol;\n /**\n * Where `uriConfig` is looked up, bound when the adapter is built.\n *\n * A value rather than a requirement on each call: the URL lookup is this\n * adapter's mechanism, and putting it in the repository port's environment\n * made every use case — and every static or database-backed caller — provide\n * a configuration it never read.\n */\n configuration: ConfigurationClient;\n}\n"],"names":[],"mappings":"AAmBA,WAiBC"}
@@ -1,6 +1,4 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { type TransactionStatusReader } from '@entifix/transactions';
3
- import { Effect } from 'effect';
4
2
  import type { BuildEntityRestOptions } from '../../entity-rest/types.js';
5
3
  /**
6
4
  * Reads one transaction's record over HTTP, for a browser reconciling a write it
@@ -19,5 +17,5 @@ import type { BuildEntityRestOptions } from '../../entity-rest/types.js';
19
17
  * Every other status stays an error, so an unreachable service is not quietly
20
18
  * read as "no such transaction".
21
19
  */
22
- export declare const buildTransactionStatusReader: (options: BuildEntityRestOptions) => Effect.Effect<TransactionStatusReader, never, ConfigurationRepositoryTag>;
20
+ export declare const buildTransactionStatusReader: (options: Pick<BuildEntityRestOptions, "uriConfig" | "configuration">) => TransactionStatusReader;
23
21
  //# sourceMappingURL=build-transaction-status-reader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-transaction-status-reader.d.ts","sourceRoot":"","sources":["../../../../src/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAUzE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,sBAAsB,KAC9B,MAAM,CAAC,MAAM,CAAC,uBAAuB,EAAE,KAAK,EAAE,0BAA0B,CA6BvE,CAAC"}
1
+ {"version":3,"file":"build-transaction-status-reader.d.ts","sourceRoot":"","sources":["../../../../src/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAUzE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,4BAA4B,GACvC,SAAS,IAAI,CAAC,sBAAsB,EAAE,WAAW,GAAG,eAAe,CAAC,KACnE,uBA4BF,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ConfigurationRepositoryTag } from '@entifix/business';
2
1
  import { readTransactionRecordEnvelope } from '@entifix/transactions';
3
2
  import { Effect } from 'effect';
4
3
  import { performHttpRequestThroughFetch } from '../../../clients/fetch/index.js';
@@ -25,21 +24,21 @@ import { buildEntityRestAdapterMixins as adapterMixins } from '../../entity-rest
25
24
  *
26
25
  * Every other status stays an error, so an unreachable service is not quietly
27
26
  * read as "no such transaction".
28
- */ export const buildTransactionStatusReader = (options)=>Effect.gen(function*() {
29
- const configurationStore = yield* ConfigurationRepositoryTag;
30
- return {
31
- read: (transactionId)=>Effect.gen(function*() {
32
- const url = yield* adapterMixins.buildEntityBaseUrl(configurationStore, options, TRANSACTION_PATH, transactionId);
33
- const response = yield* performHttpRequestThroughFetch(adapterMixins.buildEntityRequest({
34
- method: 'GET',
35
- url
36
- }));
37
- return yield* readTransactionRecordEnvelope(response.body);
38
- }).pipe(Effect.catch((error)=>{
39
- var _error_details;
40
- return ((_error_details = error.details) == null ? void 0 : _error_details['status']) === 404 ? Effect.succeed(undefined) : Effect.fail(error);
41
- }))
42
- };
43
- });
27
+ */ export const buildTransactionStatusReader = (options)=>{
28
+ const { configuration } = options;
29
+ return {
30
+ read: (transactionId)=>Effect.gen(function*() {
31
+ const url = yield* adapterMixins.buildEntityBaseUrl(configuration, options, TRANSACTION_PATH, transactionId);
32
+ const response = yield* performHttpRequestThroughFetch(adapterMixins.buildEntityRequest({
33
+ method: 'GET',
34
+ url
35
+ }));
36
+ return yield* readTransactionRecordEnvelope(response.body);
37
+ }).pipe(Effect.catch((error)=>{
38
+ var _error_details;
39
+ return ((_error_details = error.details) == null ? void 0 : _error_details['status']) === 404 ? Effect.succeed(undefined) : Effect.fail(error);
40
+ }))
41
+ };
42
+ };
44
43
 
45
44
  //# sourceMappingURL=build-transaction-status-reader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.ts"],"sourcesContent":["import { ConfigurationRepositoryTag } from '@entifix/business';\nimport type { EntifixError } from '@entifix/core';\nimport {\n readTransactionRecordEnvelope,\n type TransactionRecord,\n type TransactionStatusReader,\n} from '@entifix/transactions';\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 type { BuildEntityRestOptions } from '../../entity-rest/types.js';\n\n/**\n * The tracker's own path segment. It is not an entity — nothing decorates a\n * `TransactionRecord` — but the URL is composed the same way every entity URL\n * is, so `buildEntityBaseUrl` (already generic over an arbitrary name) needs no\n * transaction-shaped sibling.\n */\nconst TRANSACTION_PATH = 'transaction';\n\n/**\n * Reads one transaction's record over HTTP, for a browser reconciling a write it\n * started.\n *\n * ⚠️ **A `404` answers `undefined`, and that is not a failure.** `accepted`\n * reaches the tracker over the bus, so with the broker down the entity write\n * commits — the outbox is in the same Mongo transaction — while no event is ever\n * published and the tracker holds no record at all. A caller that treated this\n * as terminal would un-render a healthy write during a broker outage, which is\n * the moment nobody can tell a UI bug from an outage (ADR 0043). The route also\n * answers `404` for another tenant's record, deliberately, so it cannot be\n * walked to probe ids that are also primary keys — indistinguishable here, and\n * correctly so: neither is a record this caller may reconcile against.\n *\n * Every other status stays an error, so an unreachable service is not quietly\n * read as \"no such transaction\".\n */\nexport const buildTransactionStatusReader = (\n options: BuildEntityRestOptions,\n): Effect.Effect<TransactionStatusReader, never, ConfigurationRepositoryTag> =>\n Effect.gen(function* () {\n const configurationStore = yield* ConfigurationRepositoryTag;\n\n return {\n read: (\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, EntifixError> =>\n Effect.gen(function* () {\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configurationStore,\n options,\n TRANSACTION_PATH,\n transactionId,\n );\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url }),\n );\n\n return yield* readTransactionRecordEnvelope(response.body);\n }).pipe(\n Effect.catch(error =>\n error.details?.['status'] === 404\n ? Effect.succeed(undefined)\n : Effect.fail(error),\n ),\n ),\n };\n });\n"],"names":["ConfigurationRepositoryTag","readTransactionRecordEnvelope","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","TRANSACTION_PATH","buildTransactionStatusReader","options","gen","configurationStore","read","transactionId","url","buildEntityBaseUrl","response","buildEntityRequest","method","body","pipe","catch","error","details","succeed","undefined","fail"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,oBAAoB;AAE/D,SACEC,6BAA6B,QAGxB,wBAAwB;AAC/B,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,8DAA8D;AAG5H;;;;;CAKC,GACD,MAAMC,mBAAmB;AAEzB;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,UAEAN,OAAOO,GAAG,CAAC;QACT,MAAMC,qBAAqB,OAAOV;QAElC,OAAO;YACLW,MAAM,CACJC,gBAEAV,OAAOO,GAAG,CAAC;oBACT,MAAMI,MAAM,OAAOR,cAAcS,kBAAkB,CACjDJ,oBACAF,SACAF,kBACAM;oBAGF,MAAMG,WAAW,OAAOZ,+BACtBE,cAAcW,kBAAkB,CAAC;wBAAEC,QAAQ;wBAAOJ;oBAAI;oBAGxD,OAAO,OAAOZ,8BAA8Bc,SAASG,IAAI;gBAC3D,GAAGC,IAAI,CACLjB,OAAOkB,KAAK,CAACC,CAAAA;wBACXA;2BAAAA,EAAAA,iBAAAA,MAAMC,OAAO,qBAAbD,cAAe,CAAC,SAAS,MAAK,MAC1BnB,OAAOqB,OAAO,CAACC,aACftB,OAAOuB,IAAI,CAACJ;;QAGxB;IACF,GAAG"}
1
+ {"version":3,"sources":["../../../../src/adapters/transaction-status/build-transaction-status-reader/build-transaction-status-reader.ts"],"sourcesContent":["import type { EntifixError } from '@entifix/core';\nimport {\n readTransactionRecordEnvelope,\n type TransactionRecord,\n type TransactionStatusReader,\n} from '@entifix/transactions';\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 type { BuildEntityRestOptions } from '../../entity-rest/types.js';\n\n/**\n * The tracker's own path segment. It is not an entity — nothing decorates a\n * `TransactionRecord` — but the URL is composed the same way every entity URL\n * is, so `buildEntityBaseUrl` (already generic over an arbitrary name) needs no\n * transaction-shaped sibling.\n */\nconst TRANSACTION_PATH = 'transaction';\n\n/**\n * Reads one transaction's record over HTTP, for a browser reconciling a write it\n * started.\n *\n * ⚠️ **A `404` answers `undefined`, and that is not a failure.** `accepted`\n * reaches the tracker over the bus, so with the broker down the entity write\n * commits — the outbox is in the same Mongo transaction — while no event is ever\n * published and the tracker holds no record at all. A caller that treated this\n * as terminal would un-render a healthy write during a broker outage, which is\n * the moment nobody can tell a UI bug from an outage (ADR 0043). The route also\n * answers `404` for another tenant's record, deliberately, so it cannot be\n * walked to probe ids that are also primary keys — indistinguishable here, and\n * correctly so: neither is a record this caller may reconcile against.\n *\n * Every other status stays an error, so an unreachable service is not quietly\n * read as \"no such transaction\".\n */\nexport const buildTransactionStatusReader = (\n options: Pick<BuildEntityRestOptions, 'uriConfig' | 'configuration'>,\n): TransactionStatusReader => {\n const { configuration } = options;\n\n return {\n read: (\n transactionId: string,\n ): Effect.Effect<TransactionRecord | undefined, EntifixError> =>\n Effect.gen(function* () {\n const url = yield* adapterMixins.buildEntityBaseUrl(\n configuration,\n options,\n TRANSACTION_PATH,\n transactionId,\n );\n\n const response = yield* performHttpRequestThroughFetch(\n adapterMixins.buildEntityRequest({ method: 'GET', url }),\n );\n\n return yield* readTransactionRecordEnvelope(response.body);\n }).pipe(\n Effect.catch(error =>\n error.details?.['status'] === 404\n ? Effect.succeed(undefined)\n : Effect.fail(error),\n ),\n ),\n };\n};\n"],"names":["readTransactionRecordEnvelope","Effect","performHttpRequestThroughFetch","buildEntityRestAdapterMixins","adapterMixins","TRANSACTION_PATH","buildTransactionStatusReader","options","configuration","read","transactionId","gen","url","buildEntityBaseUrl","response","buildEntityRequest","method","body","pipe","catch","error","details","succeed","undefined","fail"],"mappings":"AACA,SACEA,6BAA6B,QAGxB,wBAAwB;AAC/B,SAASC,MAAM,QAAQ,SAAS;AAEhC,SAASC,8BAA8B,QAAQ,kCAAkC;AACjF,SAASC,gCAAgCC,aAAa,QAAQ,8DAA8D;AAG5H;;;;;CAKC,GACD,MAAMC,mBAAmB;AAEzB;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC;IAEA,MAAM,EAAEC,aAAa,EAAE,GAAGD;IAE1B,OAAO;QACLE,MAAM,CACJC,gBAEAT,OAAOU,GAAG,CAAC;gBACT,MAAMC,MAAM,OAAOR,cAAcS,kBAAkB,CACjDL,eACAD,SACAF,kBACAK;gBAGF,MAAMI,WAAW,OAAOZ,+BACtBE,cAAcW,kBAAkB,CAAC;oBAAEC,QAAQ;oBAAOJ;gBAAI;gBAGxD,OAAO,OAAOZ,8BAA8Bc,SAASG,IAAI;YAC3D,GAAGC,IAAI,CACLjB,OAAOkB,KAAK,CAACC,CAAAA;oBACXA;uBAAAA,EAAAA,iBAAAA,MAAMC,OAAO,qBAAbD,cAAe,CAAC,SAAS,MAAK,MAC1BnB,OAAOqB,OAAO,CAACC,aACftB,OAAOuB,IAAI,CAACJ;;IAGxB;AACF,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entifix/rest",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
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": {
@@ -51,13 +51,12 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@swc/helpers": "0.5.23",
54
- "@entifix/business": "0.4.2",
55
- "@entifix/core": "0.4.2",
56
- "@entifix/transactions": "0.4.2"
54
+ "@entifix/core": "0.5.0",
55
+ "@entifix/transactions": "0.5.0"
57
56
  },
58
57
  "devDependencies": {
59
58
  "effect": "4.0.5",
60
- "@entifix/testing-unit": "0.4.2"
59
+ "@entifix/testing-unit": "0.5.0"
61
60
  },
62
61
  "peerDependencies": {
63
62
  "effect": "^4.0.5"