@procedures/client 0.32.0 → 0.34.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.
- package/CHANGELOG.md +59 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/server/addressing.d.ts.map +1 -1
- package/dist/adapters/http/server/addressing.js +6 -2
- package/dist/adapters/http/server/addressing.js.map +1 -1
- package/dist/adapters/local/client/transport.js +2 -1
- package/dist/adapters/local/client/transport.js.map +1 -1
- package/dist/browser.d.ts +3 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +5 -3
- package/dist/browser.js.map +1 -1
- package/dist/events/publisher.d.ts +6 -8
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +7 -31
- package/dist/events/publisher.js.map +1 -1
- package/dist/procedures/collection/changes.d.ts +2 -2
- package/dist/procedures/collection/changes.js +2 -2
- package/dist/procedures/collection/index.js +1 -1
- package/dist/procedures/collection/index.js.map +1 -1
- package/dist/procedures/collection/partition.d.ts +8 -56
- package/dist/procedures/collection/partition.d.ts.map +1 -1
- package/dist/procedures/collection/partition.js +7 -73
- package/dist/procedures/collection/partition.js.map +1 -1
- package/dist/procedures/collection/topic.d.ts +27 -39
- package/dist/procedures/collection/topic.d.ts.map +1 -1
- package/dist/procedures/collection/topic.js +55 -38
- package/dist/procedures/collection/topic.js.map +1 -1
- package/dist/procedures/core/schemas.d.ts +26 -10
- package/dist/procedures/core/schemas.d.ts.map +1 -1
- package/dist/procedures/core/schemas.js +34 -16
- package/dist/procedures/core/schemas.js.map +1 -1
- package/dist/procedures/define-procedure.d.ts.map +1 -1
- package/dist/procedures/define-procedure.js +5 -5
- package/dist/procedures/define-procedure.js.map +1 -1
- package/dist/procedures/index.d.ts +4 -3
- package/dist/procedures/index.d.ts.map +1 -1
- package/dist/procedures/index.js +5 -3
- package/dist/procedures/index.js.map +1 -1
- package/dist/procedures/module.d.ts +22 -0
- package/dist/procedures/module.d.ts.map +1 -1
- package/dist/procedures/module.js +18 -0
- package/dist/procedures/module.js.map +1 -1
- package/dist/procedures/registry.d.ts +2 -1
- package/dist/procedures/registry.d.ts.map +1 -1
- package/dist/procedures/registry.js +4 -2
- package/dist/procedures/registry.js.map +1 -1
- package/dist/procedures/segments.d.ts +61 -0
- package/dist/procedures/segments.d.ts.map +1 -0
- package/dist/procedures/segments.js +71 -0
- package/dist/procedures/segments.js.map +1 -0
- package/dist/procedures/types.d.ts +5 -2
- package/dist/procedures/types.d.ts.map +1 -1
- package/dist/procedures/types.js +8 -4
- package/dist/procedures/types.js.map +1 -1
- package/dist/server/host-policy.d.ts +1 -1
- package/dist/server/host-policy.d.ts.map +1 -1
- package/dist/server/host-policy.js +5 -3
- package/dist/server/host-policy.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/method.d.ts +18 -3
- package/dist/server/method.d.ts.map +1 -1
- package/dist/server/method.js +23 -6
- package/dist/server/method.js.map +1 -1
- package/dist/server/procedure-server.d.ts +5 -23
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +4 -29
- package/dist/server/procedure-server.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/http/server/addressing.ts +6 -2
- package/src/adapters/local/client/transport.ts +2 -2
- package/src/browser.ts +6 -1
- package/src/events/publisher.ts +14 -40
- package/src/procedures/collection/changes.ts +2 -2
- package/src/procedures/collection/index.ts +1 -1
- package/src/procedures/collection/partition.ts +10 -87
- package/src/procedures/collection/topic.ts +48 -51
- package/src/procedures/core/schemas.ts +35 -16
- package/src/procedures/define-procedure.ts +5 -7
- package/src/procedures/index.ts +6 -2
- package/src/procedures/module.ts +34 -0
- package/src/procedures/registry.ts +4 -2
- package/src/procedures/segments.ts +74 -0
- package/src/procedures/types.ts +8 -4
- package/src/server/host-policy.ts +5 -4
- package/src/server/index.ts +2 -0
- package/src/server/method.ts +23 -6
- package/src/server/procedure-server.ts +6 -34
|
@@ -20,7 +20,7 @@ import { ProcedureRegistry, PROCEDURE_REGISTRY } from "../procedures/registry.js
|
|
|
20
20
|
import { createCollectionProcedures } from "../procedures/collection/procedures.js";
|
|
21
21
|
import { InvocationError, closableUnread, invokeProcedure, type AdmitItem, type Interceptor, type Invocation } from "../procedures/invoke.js";
|
|
22
22
|
import type { Capability, ClearanceOrder, ProcedureContext, ResourcesOf } from "../procedures/types.js";
|
|
23
|
-
import {
|
|
23
|
+
import type { CollectionPartitions } from "../procedures/collection/partition.js";
|
|
24
24
|
import { VERSION_CONFLICTS_METADATA_KEY, versionConflictsOf } from "../procedures/collection/precondition.js";
|
|
25
25
|
import { TIMEOUT_METADATA_KEY, effectsOf, joinNarrowing, narrowCapability } from "../procedures/capability.js";
|
|
26
26
|
import { IdempotencyCache, idempotencyKeyOf, isRepeatable, type IdempotencyOptions } from "../procedures/idempotency.js";
|
|
@@ -546,8 +546,7 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
546
546
|
this.publisher = events instanceof EventPublisher ? events : events ? new EventPublisher({ ...events, clock: events.clock ?? this.clock }) : undefined;
|
|
547
547
|
if (this.publisher) this.registerProcedure(this.publisher.procedure, { alwaysOn: true });
|
|
548
548
|
|
|
549
|
-
// Configure collections
|
|
550
|
-
// storages for a shared topic (roadmap CLI-57)
|
|
549
|
+
// Configure collections
|
|
551
550
|
if (options.collections) {
|
|
552
551
|
for (const [name, storage] of Object.entries(options.collections)) {
|
|
553
552
|
this.storages.set(name, storage);
|
|
@@ -626,34 +625,19 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
626
625
|
* for: the collection procedures and the subscriptions of `EventPublisher` use it. `storageOf`
|
|
627
626
|
* gives the storage of a partition: give the same storage for the same partition each time.
|
|
628
627
|
*
|
|
629
|
-
* The name can have a dot (roadmap CLI-42).
|
|
630
|
-
* name and the partition of a topic stay apart
|
|
631
|
-
*
|
|
632
|
-
* The server refuses partitions of `a` while it has a storage of `a.b` (roadmap CLI-57, decision
|
|
633
|
-
* D23). The plain topic of `a.b` is the topic of the partition `b` of `a`. `useStorage` refuses
|
|
634
|
-
* the other order.
|
|
628
|
+
* The name is the raw name, and it can have a dot (roadmap CLI-42 and CLI-75). Each topic
|
|
629
|
+
* encodes the name, so the name and the partition of a topic stay apart
|
|
630
|
+
* (`collectionChangeTopic()`). The partitions of `a` and a storage of `a.b` do not share a topic.
|
|
635
631
|
*
|
|
636
632
|
* @param name - Collection name
|
|
637
633
|
* @param partitions - The storage of each partition, and the resolver
|
|
638
634
|
* @returns this (for chaining)
|
|
639
|
-
* @throws CollectionTopicCollisionError when the topic of a partition is the topic of a collection with a storage
|
|
640
635
|
*/
|
|
641
636
|
usePartitions<T>(name: string, partitions: CollectionPartitions<T>): this {
|
|
642
|
-
assertTopicsApart(this.storages.keys(), (collection) => collection === name);
|
|
643
637
|
this.partitions.set(name, partitions as CollectionPartitions<unknown>);
|
|
644
638
|
return this;
|
|
645
639
|
}
|
|
646
640
|
|
|
647
|
-
/**
|
|
648
|
-
* The check of the topics of new storages (roadmap CLI-57, decision D23). The plain topic of each
|
|
649
|
-
* one must not be the topic of a partition of a collection with partitions.
|
|
650
|
-
*
|
|
651
|
-
* @throws CollectionTopicCollisionError for the first pair with the same topic
|
|
652
|
-
*/
|
|
653
|
-
private assertPlainTopicsApart(names: Iterable<string>): void {
|
|
654
|
-
assertTopicsApart(names, (collection) => this.partitions.has(collection));
|
|
655
|
-
}
|
|
656
|
-
|
|
657
641
|
// ===========================================================================
|
|
658
642
|
// Storage Configuration
|
|
659
643
|
// ===========================================================================
|
|
@@ -674,21 +658,17 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
674
658
|
* that took the old storage, for the time of `grace` at most. Before, such a call could fail
|
|
675
659
|
* because the storage was closed.
|
|
676
660
|
*
|
|
677
|
-
* The
|
|
678
|
-
* The plain topic of `a.b` is the topic of the partition `b` of `a`. With options, the promise
|
|
679
|
-
* rejects, and the old storage stays as it is.
|
|
661
|
+
* The name is the raw name, and it can have a dot. Its topic encodes the name (roadmap CLI-75).
|
|
680
662
|
*
|
|
681
663
|
* @param name - Collection name
|
|
682
664
|
* @param storage - Storage backend
|
|
683
665
|
* @param options - Drain and close the old storage
|
|
684
666
|
* @returns this (for chaining), or a promise of it when options are given
|
|
685
|
-
* @throws CollectionTopicCollisionError when the topic of the collection is the topic of a partition
|
|
686
667
|
*/
|
|
687
668
|
useStorage<T>(name: string, storage: CollectionStorage<T>): this;
|
|
688
669
|
useStorage<T>(name: string, storage: CollectionStorage<T>, options: UseStorageOptions): Promise<this>;
|
|
689
670
|
useStorage<T>(name: string, storage: CollectionStorage<T>, options?: UseStorageOptions): this | Promise<this> {
|
|
690
671
|
if (options === undefined) {
|
|
691
|
-
this.assertPlainTopicsApart([name]);
|
|
692
672
|
this.storages.set(name, storage as CollectionStorage<unknown>);
|
|
693
673
|
return this;
|
|
694
674
|
}
|
|
@@ -700,9 +680,6 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
700
680
|
* the old storage, and close it.
|
|
701
681
|
*/
|
|
702
682
|
private async replaceStorage(name: string, storage: CollectionStorage<unknown>, options: UseStorageOptions): Promise<this> {
|
|
703
|
-
// Before the flush: a refused storage changes nothing (roadmap CLI-57). With an old storage,
|
|
704
|
-
// usePartitions() sees the name during the flush. Without one, no await comes before the set.
|
|
705
|
-
this.assertPlainTopicsApart([name]);
|
|
706
683
|
const graceMs = optionalMs(options.grace, "grace") ?? TIMER_DEFAULTS.server.storageGraceMs;
|
|
707
684
|
const old = this.storages.get(name);
|
|
708
685
|
const other = old !== undefined && old !== storage ? old : undefined;
|
|
@@ -774,15 +751,10 @@ export class ProcedureServer extends Server implements RepositoryProvider, StopP
|
|
|
774
751
|
/**
|
|
775
752
|
* Configure multiple storages at once.
|
|
776
753
|
*
|
|
777
|
-
* The server examines all the names before it sets a storage: a refused name sets none (roadmap
|
|
778
|
-
* CLI-57, decision D23).
|
|
779
|
-
*
|
|
780
754
|
* @param storages - Map of collection names to storage backends
|
|
781
755
|
* @returns this (for chaining)
|
|
782
|
-
* @throws CollectionTopicCollisionError when the topic of a collection is the topic of a partition
|
|
783
756
|
*/
|
|
784
757
|
useStorages(storages: Record<string, CollectionStorage<unknown>>): this {
|
|
785
|
-
this.assertPlainTopicsApart(Object.keys(storages));
|
|
786
758
|
for (const [name, storage] of Object.entries(storages)) {
|
|
787
759
|
this.storages.set(name, storage);
|
|
788
760
|
}
|