@party-stack/runtime 0.4.1 → 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 (80) hide show
  1. package/lib/BrowserAuthenticationError.d.ts +11 -0
  2. package/lib/BrowserAuthenticationError.d.ts.map +1 -0
  3. package/lib/BrowserAuthenticationError.js +15 -0
  4. package/lib/BrowserAuthenticationError.js.map +1 -0
  5. package/lib/MemoryRuntime.d.ts +11 -0
  6. package/lib/MemoryRuntime.d.ts.map +1 -0
  7. package/lib/MemoryRuntime.js +23 -0
  8. package/lib/MemoryRuntime.js.map +1 -0
  9. package/lib/NetworkConnectivity.d.ts +13 -0
  10. package/lib/NetworkConnectivity.d.ts.map +1 -0
  11. package/lib/NetworkConnectivity.js +29 -0
  12. package/lib/NetworkConnectivity.js.map +1 -0
  13. package/lib/Runtime.d.ts +34 -0
  14. package/lib/Runtime.d.ts.map +1 -0
  15. package/lib/Runtime.js +28 -0
  16. package/lib/Runtime.js.map +1 -0
  17. package/lib/RuntimePartition.d.ts +16 -0
  18. package/lib/RuntimePartition.d.ts.map +1 -0
  19. package/lib/RuntimePartition.js +13 -0
  20. package/lib/RuntimePartition.js.map +1 -0
  21. package/lib/Runtimes.d.ts +22 -0
  22. package/lib/Runtimes.d.ts.map +1 -0
  23. package/lib/Runtimes.js +24 -0
  24. package/lib/Runtimes.js.map +1 -0
  25. package/lib/_virtual/_rolldown/runtime.js +13 -0
  26. package/lib/capacity.d.ts +26 -0
  27. package/lib/capacity.d.ts.map +1 -0
  28. package/lib/capacity.js +28 -0
  29. package/lib/capacity.js.map +1 -0
  30. package/lib/encryptionKeys.d.ts +36 -0
  31. package/lib/encryptionKeys.d.ts.map +1 -0
  32. package/lib/encryptionKeys.js +84 -0
  33. package/lib/encryptionKeys.js.map +1 -0
  34. package/lib/index.d.ts +11 -10
  35. package/lib/index.js +10 -9
  36. package/lib/memory/MemoryBlobBytesStore.d.ts +6 -5
  37. package/lib/memory/MemoryBlobBytesStore.d.ts.map +1 -1
  38. package/lib/memory/MemoryBlobBytesStore.js +9 -9
  39. package/lib/memory/MemoryBlobBytesStore.js.map +1 -1
  40. package/lib/testing.d.ts +42 -0
  41. package/lib/testing.d.ts.map +1 -0
  42. package/lib/testing.js +138 -0
  43. package/lib/testing.js.map +1 -0
  44. package/lib/tracing.d.ts +48 -0
  45. package/lib/tracing.d.ts.map +1 -0
  46. package/lib/tracing.js +173 -0
  47. package/lib/tracing.js.map +1 -0
  48. package/lib/types.d.ts +23 -29
  49. package/lib/types.d.ts.map +1 -1
  50. package/package.json +14 -14
  51. package/lib/coordinator/createPersistedCollectionCoordinator.d.ts +0 -6
  52. package/lib/coordinator/createPersistedCollectionCoordinator.d.ts.map +0 -1
  53. package/lib/coordinator/createPersistedCollectionCoordinator.js +0 -499
  54. package/lib/coordinator/createPersistedCollectionCoordinator.js.map +0 -1
  55. package/lib/coordinator/index.d.ts +0 -2
  56. package/lib/coordinator/index.js +0 -2
  57. package/lib/effection/index.d.ts +0 -7
  58. package/lib/effection/index.d.ts.map +0 -1
  59. package/lib/effection/index.js +0 -28
  60. package/lib/effection/index.js.map +0 -1
  61. package/lib/utils/BrowserAuthenticationCancelledError.d.ts +0 -6
  62. package/lib/utils/BrowserAuthenticationCancelledError.d.ts.map +0 -1
  63. package/lib/utils/BrowserAuthenticationCancelledError.js +0 -11
  64. package/lib/utils/BrowserAuthenticationCancelledError.js.map +0 -1
  65. package/lib/utils/createCollectionPersistence.d.ts +0 -7
  66. package/lib/utils/createCollectionPersistence.d.ts.map +0 -1
  67. package/lib/utils/createCollectionPersistence.js +0 -24
  68. package/lib/utils/createCollectionPersistence.js.map +0 -1
  69. package/lib/utils/createDefaultRuntime.d.ts +0 -5
  70. package/lib/utils/createDefaultRuntime.d.ts.map +0 -1
  71. package/lib/utils/createDefaultRuntime.js +0 -19
  72. package/lib/utils/createDefaultRuntime.js.map +0 -1
  73. package/lib/utils/createLocalCollection.d.ts +0 -11
  74. package/lib/utils/createLocalCollection.d.ts.map +0 -1
  75. package/lib/utils/createLocalCollection.js +0 -22
  76. package/lib/utils/createLocalCollection.js.map +0 -1
  77. package/lib/utils/defineRuntime.d.ts +0 -8
  78. package/lib/utils/defineRuntime.d.ts.map +0 -1
  79. package/lib/utils/defineRuntime.js +0 -30
  80. package/lib/utils/defineRuntime.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ import { Schema } from "effect";
2
+ //#region src/BrowserAuthenticationError.d.ts
3
+ declare const BrowserAuthenticationError_base: Schema.Class<BrowserAuthenticationError, Schema.TaggedStruct<"BrowserAuthenticationError", {
4
+ readonly reason: Schema.Literals<readonly ["Cancelled", "Configuration", "Platform"]>;
5
+ readonly message: Schema.String;
6
+ readonly cause: Schema.optional<Schema.Defect>;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ export declare class BrowserAuthenticationError extends BrowserAuthenticationError_base {}
9
+ //#endregion
10
+ export {};
11
+ //# sourceMappingURL=BrowserAuthenticationError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserAuthenticationError.d.ts","names":[],"sources":["../src/BrowserAuthenticationError.ts"],"mappings":";;;;;;;qBAEa,mCAAmC"}
@@ -0,0 +1,15 @@
1
+ import { Schema } from "effect";
2
+ //#region src/BrowserAuthenticationError.ts
3
+ var BrowserAuthenticationError = class extends Schema.TaggedError()("BrowserAuthenticationError", {
4
+ reason: Schema.Literals([
5
+ "Cancelled",
6
+ "Configuration",
7
+ "Platform"
8
+ ]),
9
+ message: Schema.String,
10
+ cause: Schema.optional(Schema.Defect())
11
+ }) {};
12
+ //#endregion
13
+ export { BrowserAuthenticationError };
14
+
15
+ //# sourceMappingURL=BrowserAuthenticationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserAuthenticationError.js","names":[],"sources":["../src/BrowserAuthenticationError.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport class BrowserAuthenticationError extends Schema.TaggedError<BrowserAuthenticationError>()(\n \"BrowserAuthenticationError\",\n {\n reason: Schema.Literals([\"Cancelled\", \"Configuration\", \"Platform\"]),\n message: Schema.String,\n cause: Schema.optional(Schema.Defect()),\n }\n) {}\n"],"mappings":";;AAEA,IAAa,6BAAb,cAAgD,OAAO,YAAwC,CAAC,CAC5F,8BACA;CACI,QAAQ,OAAO,SAAS;EAAC;EAAa;EAAiB;CAAU,CAAC;CAClE,SAAS,OAAO;CAChB,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;AAC1C,CACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { RuntimePartition } from "./RuntimePartition.js";
2
+ import { Runtime, RuntimeService } from "./Runtime.js";
3
+ import { Effect, Layer } from "effect";
4
+ declare namespace MemoryRuntime_d_exports {
5
+ export { layer, make };
6
+ }
7
+ export declare const make: () => Effect.Effect<RuntimeService, never, RuntimePartition>;
8
+ export declare const layer: Layer.Layer<Runtime, never, RuntimePartition>;
9
+ //#endregion
10
+ export { MemoryRuntime_d_exports };
11
+ //# sourceMappingURL=MemoryRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryRuntime.d.ts","names":["_$__Runtime_js0.RuntimeService","_$__RuntimePartition_js0.RuntimePartition"],"sources":["../src/MemoryRuntime.ts"],"mappings":";;;;;;qBAMa,YAAI,OAAA,OAAJA,uBAAIC;qBAOJ,OAAK,MAAA,MAAA,gBAAAA"}
@@ -0,0 +1,23 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { makeMemoryEncryptionKeyring } from "./encryptionKeys.js";
3
+ import { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
4
+ import { Runtime } from "./Runtime.js";
5
+ import { Effect, Layer } from "effect";
6
+ import * as Memory from "@party-stack/ontology-storage/memory/tables";
7
+ //#region src/MemoryRuntime.ts
8
+ var MemoryRuntime_exports = /* @__PURE__ */ __exportAll({
9
+ layer: () => layer,
10
+ make: () => make
11
+ });
12
+ const make = Effect.fnUntraced(function* () {
13
+ return yield* Runtime.make({
14
+ tables: yield* Memory.make(),
15
+ blobBytes: new MemoryBlobBytesStore(),
16
+ encryptionKeyring: yield* makeMemoryEncryptionKeyring()
17
+ });
18
+ });
19
+ const layer = Layer.effect(Runtime, make());
20
+ //#endregion
21
+ export { MemoryRuntime_exports, layer, make };
22
+
23
+ //# sourceMappingURL=MemoryRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryRuntime.js","names":[],"sources":["../src/MemoryRuntime.ts"],"sourcesContent":["import * as Memory from \"@party-stack/ontology-storage/memory/tables\";\nimport { Effect, Layer } from \"effect\";\nimport { makeMemoryEncryptionKeyring } from \"./encryptionKeys.js\";\nimport { MemoryBlobBytesStore } from \"./memory/MemoryBlobBytesStore.js\";\nimport { Runtime } from \"./Runtime.js\";\n\nexport const make = Effect.fnUntraced(function* () {\n return yield* Runtime.make({\n tables: yield* Memory.make(),\n blobBytes: new MemoryBlobBytesStore(),\n encryptionKeyring: yield* makeMemoryEncryptionKeyring(),\n });\n});\nexport const layer = Layer.effect(Runtime, make());\n"],"mappings":";;;;;;;;;;;AAMA,MAAa,OAAO,OAAO,WAAW,aAAa;CAC/C,OAAO,OAAO,QAAQ,KAAK;EACvB,QAAQ,OAAO,OAAO,KAAK;EAC3B,WAAW,IAAI,qBAAqB;EACpC,mBAAmB,OAAO,4BAA4B;CAC1D,CAAC;AACL,CAAC;AACD,MAAa,QAAQ,MAAM,OAAO,SAAS,KAAK,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { NetworkConnectivity } from "./types.js";
2
+ import { Effect, Stream } from "effect";
3
+ //#region src/NetworkConnectivity.d.ts
4
+ /** Platforms without a monitor still handle individual request failures normally. */
5
+ export declare const alwaysOnlineConnectivity: NetworkConnectivity;
6
+ /** Latest-value state with bounded delivery, owned by the platform scope. */
7
+ export declare const makeNetworkConnectivity: (initial: boolean) => Effect.Effect<{
8
+ online: Effect.Effect<boolean, never, never>;
9
+ changes: Stream.Stream<boolean, never, never>;
10
+ set: (value: boolean) => Effect.Effect<void, never, never>;
11
+ }, never, import("effect/Scope").Scope>;
12
+ //#endregion
13
+ //# sourceMappingURL=NetworkConnectivity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkConnectivity.d.ts","names":[],"sources":["../src/NetworkConnectivity.ts"],"mappings":";;;;qBAIa,0BAA0B;;qBAM1B,0BAAuB,qBAAA,OAAA;;;EAUf,MAAA,mBAAO,OAAA;iCAO1B"}
@@ -0,0 +1,29 @@
1
+ import { Effect, PubSub, Stream } from "effect";
2
+ //#region src/NetworkConnectivity.ts
3
+ /** Platforms without a monitor still handle individual request failures normally. */
4
+ const alwaysOnlineConnectivity = {
5
+ online: Effect.succeed(true),
6
+ changes: Stream.make(true)
7
+ };
8
+ /** Latest-value state with bounded delivery, owned by the platform scope. */
9
+ const makeNetworkConnectivity = Effect.fnUntraced(function* (initial) {
10
+ const events = yield* Effect.acquireRelease(PubSub.sliding({
11
+ capacity: 1,
12
+ replay: 1
13
+ }), PubSub.shutdown);
14
+ let current = initial;
15
+ yield* PubSub.publish(events, initial);
16
+ return {
17
+ online: Effect.sync(() => current),
18
+ changes: Stream.fromPubSub(events),
19
+ set: (value) => Effect.sync(() => {
20
+ if (value === current) return;
21
+ current = value;
22
+ PubSub.publishUnsafe(events, value);
23
+ })
24
+ };
25
+ });
26
+ //#endregion
27
+ export { alwaysOnlineConnectivity, makeNetworkConnectivity };
28
+
29
+ //# sourceMappingURL=NetworkConnectivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkConnectivity.js","names":[],"sources":["../src/NetworkConnectivity.ts"],"sourcesContent":["import { Effect, PubSub, Stream } from \"effect\";\nimport type { NetworkConnectivity } from \"./types.js\";\n\n/** Platforms without a monitor still handle individual request failures normally. */\nexport const alwaysOnlineConnectivity: NetworkConnectivity = {\n online: Effect.succeed(true),\n changes: Stream.make(true),\n};\n\n/** Latest-value state with bounded delivery, owned by the platform scope. */\nexport const makeNetworkConnectivity = Effect.fnUntraced(function* (initial: boolean) {\n const events = yield* Effect.acquireRelease(\n PubSub.sliding<boolean>({ capacity: 1, replay: 1 }),\n PubSub.shutdown\n );\n let current = initial;\n yield* PubSub.publish(events, initial);\n return {\n online: Effect.sync(() => current),\n changes: Stream.fromPubSub(events),\n set: (value: boolean) =>\n Effect.sync(() => {\n if (value === current) return;\n current = value;\n PubSub.publishUnsafe(events, value);\n }),\n };\n});\n"],"mappings":";;;AAIA,MAAa,2BAAgD;CACzD,QAAQ,OAAO,QAAQ,IAAI;CAC3B,SAAS,OAAO,KAAK,IAAI;AAC7B;;AAGA,MAAa,0BAA0B,OAAO,WAAW,WAAW,SAAkB;CAClF,MAAM,SAAS,OAAO,OAAO,eACzB,OAAO,QAAiB;EAAE,UAAU;EAAG,QAAQ;CAAE,CAAC,GAClD,OAAO,QACX;CACA,IAAI,UAAU;CACd,OAAO,OAAO,QAAQ,QAAQ,OAAO;CACrC,OAAO;EACH,QAAQ,OAAO,WAAW,OAAO;EACjC,SAAS,OAAO,WAAW,MAAM;EACjC,MAAM,UACF,OAAO,WAAW;GACd,IAAI,UAAU,SAAS;GACvB,UAAU;GACV,OAAO,cAAc,QAAQ,KAAK;EACtC,CAAC;CACT;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { RuntimePartition } from "./RuntimePartition.js";
2
+ import { ResourceCapacity } from "./capacity.js";
3
+ import { BrowserAuthentication, NetworkConnectivity, RuntimeOptions } from "./types.js";
4
+ import { Context, Effect, Schema } from "effect";
5
+ import { EncryptionKeyringService } from "@party-stack/ontology-storage/encrypted";
6
+ import { BlobBytesService } from "@party-stack/ontology-storage/blobs";
7
+ import { TablesService } from "@party-stack/ontology-storage/tables";
8
+ //#region src/Runtime.d.ts
9
+ declare const RuntimeError_base: Schema.Class<RuntimeError, Schema.TaggedStruct<"RuntimeError", {
10
+ readonly operation: Schema.String;
11
+ readonly cause: Schema.Defect;
12
+ }>, import("effect/Cause").YieldableError>;
13
+ export declare class RuntimeError extends RuntimeError_base {}
14
+ /** Acquired platform capabilities and application-boundary bridges, owned by an Effect Scope. */
15
+ export interface RuntimeService {
16
+ readonly capacity?: ResourceCapacity;
17
+ /** Context-derived partition key; identity selection uses Connect's userId separately. */
18
+ readonly owner: string;
19
+ readonly namespace: string;
20
+ readonly browserAuthentication?: BrowserAuthentication;
21
+ readonly destroy: Effect.Effect<void, RuntimeError>;
22
+ readonly tables: TablesService;
23
+ readonly encryptionKeyring?: EncryptionKeyringService;
24
+ readonly connectivity: NetworkConnectivity;
25
+ readonly bytes: BlobBytesService;
26
+ }
27
+ declare const Runtime_base: Context.ServiceClass<Runtime, "@party-stack/runtime/Runtime", RuntimeService>;
28
+ export declare class Runtime extends Runtime_base {
29
+ /** Construct the runtime in the caller's Scope; platform Layers own their resources. */
30
+ static readonly make: (adapter: RuntimeOptions) => Effect.Effect<RuntimeService, never, RuntimePartition>;
31
+ }
32
+ //#endregion
33
+ export {};
34
+ //# sourceMappingURL=Runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Runtime.d.ts","names":[],"sources":["../src/Runtime.ts"],"mappings":";;;;;;;;;;;;qBASa,qBAAqB;;iBAKjB;WACJ,WAAW;;WAEX;WACA;WACA,wBAAwB;WACxB,SAAS,OAAO,aAAa;WAC7B,QAAQ;WACR,oBAAoB;WACpB,cAAc;WACd,OAAO;;;qBAEP,gBAAgB;;kBAET,OAAI,SAAA,mBAAA,OAAA,OAAA,uBAAA"}
package/lib/Runtime.js ADDED
@@ -0,0 +1,28 @@
1
+ import { alwaysOnlineConnectivity } from "./NetworkConnectivity.js";
2
+ import { RuntimePartition } from "./RuntimePartition.js";
3
+ import { Context, Effect, Schema } from "effect";
4
+ //#region src/Runtime.ts
5
+ var RuntimeError = class extends Schema.TaggedError()("RuntimeError", {
6
+ operation: Schema.String,
7
+ cause: Schema.Defect()
8
+ }) {};
9
+ var Runtime = class Runtime extends Context.Service()("@party-stack/runtime/Runtime") {
10
+ /** Construct the runtime in the caller's Scope; platform Layers own their resources. */
11
+ static make = Effect.fnUntraced(function* (adapter) {
12
+ const partition = yield* RuntimePartition;
13
+ return Runtime.of({
14
+ ...partition,
15
+ capacity: adapter.capacity,
16
+ browserAuthentication: adapter.browserAuthentication,
17
+ destroy: adapter.destroy ?? Effect.void,
18
+ tables: adapter.tables,
19
+ encryptionKeyring: adapter.encryptionKeyring,
20
+ connectivity: adapter.connectivity ?? alwaysOnlineConnectivity,
21
+ bytes: adapter.blobBytes
22
+ });
23
+ });
24
+ };
25
+ //#endregion
26
+ export { Runtime, RuntimeError };
27
+
28
+ //# sourceMappingURL=Runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Runtime.js","names":[],"sources":["../src/Runtime.ts"],"sourcesContent":["import { Context, Effect, Schema } from \"effect\";\nimport { alwaysOnlineConnectivity } from \"./NetworkConnectivity.js\";\nimport { RuntimePartition } from \"./RuntimePartition.js\";\nimport type { ResourceCapacity } from \"./capacity.js\";\nimport type { RuntimeOptions, BrowserAuthentication, NetworkConnectivity } from \"./types.js\";\nimport type { BlobBytesService } from \"@party-stack/ontology-storage/blobs\";\nimport type { EncryptionKeyringService } from \"@party-stack/ontology-storage/encrypted\";\nimport type { TablesService } from \"@party-stack/ontology-storage/tables\";\n\nexport class RuntimeError extends Schema.TaggedError<RuntimeError>()(\"RuntimeError\", {\n operation: Schema.String,\n cause: Schema.Defect(),\n}) {}\n/** Acquired platform capabilities and application-boundary bridges, owned by an Effect Scope. */\nexport interface RuntimeService {\n readonly capacity?: ResourceCapacity;\n /** Context-derived partition key; identity selection uses Connect's userId separately. */\n readonly owner: string;\n readonly namespace: string;\n readonly browserAuthentication?: BrowserAuthentication;\n readonly destroy: Effect.Effect<void, RuntimeError>;\n readonly tables: TablesService;\n readonly encryptionKeyring?: EncryptionKeyringService;\n readonly connectivity: NetworkConnectivity;\n readonly bytes: BlobBytesService;\n}\nexport class Runtime extends Context.Service<Runtime, RuntimeService>()(\"@party-stack/runtime/Runtime\") {\n /** Construct the runtime in the caller's Scope; platform Layers own their resources. */\n static readonly make = Effect.fnUntraced(function* (adapter: RuntimeOptions) {\n const partition = yield* RuntimePartition;\n\n const service = Runtime.of({\n ...partition,\n capacity: adapter.capacity,\n browserAuthentication: adapter.browserAuthentication,\n destroy: adapter.destroy ?? Effect.void,\n tables: adapter.tables,\n encryptionKeyring: adapter.encryptionKeyring,\n connectivity: adapter.connectivity ?? alwaysOnlineConnectivity,\n bytes: adapter.blobBytes,\n });\n return service;\n });\n}\n"],"mappings":";;;;AASA,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACjF,WAAW,OAAO;CAClB,OAAO,OAAO,OAAO;AACzB,CAAC,CAAC,CAAC,CAAC;AAcJ,IAAa,UAAb,MAAa,gBAAgB,QAAQ,QAAiC,CAAC,CAAC,8BAA8B,CAAC,CAAC;;CAEpG,OAAgB,OAAO,OAAO,WAAW,WAAW,SAAyB;EACzE,MAAM,YAAY,OAAO;EAYzB,OAVgB,QAAQ,GAAG;GACvB,GAAG;GACH,UAAU,QAAQ;GAClB,uBAAuB,QAAQ;GAC/B,SAAS,QAAQ,WAAW,OAAO;GACnC,QAAQ,QAAQ;GAChB,mBAAmB,QAAQ;GAC3B,cAAc,QAAQ,gBAAgB;GACtC,OAAO,QAAQ;EACnB,CACa;CACjB,CAAC;AACL"}
@@ -0,0 +1,16 @@
1
+ import { Context, Schema } from "effect";
2
+ //#region src/RuntimePartition.d.ts
3
+ export declare const RuntimePartitionSchema: Schema.Struct<{
4
+ /** Context-derived storage key, potentially combining tenant/token/user fields; not a user ID. */
5
+ readonly owner: Schema.String;
6
+ readonly namespace: Schema.String;
7
+ }>;
8
+ declare const RuntimePartition_base: Context.ServiceClass<RuntimePartition, "@party-stack/runtime/RuntimePartition", {
9
+ readonly owner: string;
10
+ readonly namespace: string;
11
+ }>;
12
+ /** Storage partition selected by the application context and ontology namespace. */
13
+ export declare class RuntimePartition extends RuntimePartition_base {}
14
+ //#endregion
15
+ export {};
16
+ //# sourceMappingURL=RuntimePartition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimePartition.d.ts","names":[],"sources":["../src/RuntimePartition.ts"],"mappings":";;qBAEa,wBAAsB,OAAA;;;;;;;;;;qBAOtB,yBAAyB"}
@@ -0,0 +1,13 @@
1
+ import { Context, Schema } from "effect";
2
+ //#region src/RuntimePartition.ts
3
+ const RuntimePartitionSchema = Schema.Struct({
4
+ /** Context-derived storage key, potentially combining tenant/token/user fields; not a user ID. */
5
+ owner: Schema.String,
6
+ namespace: Schema.String
7
+ });
8
+ /** Storage partition selected by the application context and ontology namespace. */
9
+ var RuntimePartition = class extends Context.Service()("@party-stack/runtime/RuntimePartition") {};
10
+ //#endregion
11
+ export { RuntimePartition, RuntimePartitionSchema };
12
+
13
+ //# sourceMappingURL=RuntimePartition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimePartition.js","names":[],"sources":["../src/RuntimePartition.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\n\nexport const RuntimePartitionSchema = Schema.Struct({\n /** Context-derived storage key, potentially combining tenant/token/user fields; not a user ID. */\n owner: Schema.String,\n namespace: Schema.String,\n});\n\n/** Storage partition selected by the application context and ontology namespace. */\nexport class RuntimePartition extends Context.Service<RuntimePartition, typeof RuntimePartitionSchema.Type>()(\n \"@party-stack/runtime/RuntimePartition\"\n) {}\n"],"mappings":";;AAEA,MAAa,yBAAyB,OAAO,OAAO;;CAEhD,OAAO,OAAO;CACd,WAAW,OAAO;AACtB,CAAC;;AAGD,IAAa,mBAAb,cAAsC,QAAQ,QAA8D,CAAC,CACzG,uCACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { RuntimePartition } from "./RuntimePartition.js";
2
+ import { BrowserAuthentication, RuntimeAcquisitionError } from "./types.js";
3
+ import { Runtime, RuntimeService } from "./Runtime.js";
4
+ import { Context, Effect, Layer, Scope } from "effect";
5
+ //#region src/Runtimes.d.ts
6
+ /** Platform configuration supplies a Layer; partition identity is an Effect requirement. */
7
+ export type RuntimeLayer = Layer.Layer<Runtime, RuntimeAcquisitionError, RuntimePartition>;
8
+ /** Platform capabilities plus lazy partition acquisition; creating this Layer opens no storage. */
9
+ export type RuntimesLayer = Layer.Layer<Runtimes, RuntimeAcquisitionError>;
10
+ declare const Runtimes_base: Context.ServiceClass<Runtimes, "@party-stack/runtime/Runtimes", {
11
+ readonly browserAuthentication?: BrowserAuthentication;
12
+ readonly acquire: (partition: RuntimePartition["Service"]) => Effect.Effect<RuntimeService, RuntimeAcquisitionError, Scope.Scope>;
13
+ }>;
14
+ /** Scoped partition acquisition for installations that open multiple ontologies. */
15
+ export declare class Runtimes extends Runtimes_base {
16
+ static readonly layer: (platform: RuntimeLayer, options?: {
17
+ readonly browserAuthentication?: BrowserAuthentication;
18
+ }) => Layer.Layer<Runtimes, never, never>;
19
+ }
20
+ //#endregion
21
+ export {};
22
+ //# sourceMappingURL=Runtimes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Runtimes.d.ts","names":[],"sources":["../src/Runtimes.ts"],"mappings":";;;;;;YASY,eAAe,MAAM,MAAM,SAAS,yBAAyB;;YAE7D,gBAAgB,MAAM,MAAM,UAAU;;WAMT,wBAAA;WACf,UACd,WAAW,gCACV,OAAO,OAAO,gBAAgB,yBAAyB,MAAM;;;qBAN7D,iBAAiB;kBASV,QAAK,UACP,cAAY;aACF,wBAAwB;QAAuB,MAAA,MAAA"}
@@ -0,0 +1,24 @@
1
+ import { RuntimePartition, RuntimePartitionSchema } from "./RuntimePartition.js";
2
+ import { Runtime } from "./Runtime.js";
3
+ import { Context, Effect, Layer, LayerMap, Schema } from "effect";
4
+ //#region src/Runtimes.ts
5
+ /** Scoped partition acquisition for installations that open multiple ontologies. */
6
+ var Runtimes = class Runtimes extends Context.Service()("@party-stack/runtime/Runtimes") {
7
+ static layer = (platform, options = {}) => Layer.effect(Runtimes, Effect.gen(function* () {
8
+ const codec = Schema.fromJsonString(RuntimePartitionSchema);
9
+ const encode = Schema.encodeSync(codec);
10
+ const decode = Schema.decodeUnknownSync(codec);
11
+ const partitions = yield* LayerMap.make((key) => Layer.fresh(platform).pipe(Layer.provide(Layer.succeed(RuntimePartition)(decode(key)))));
12
+ return Runtimes.of({
13
+ browserAuthentication: options.browserAuthentication,
14
+ acquire: Effect.fnUntraced(function* (partition) {
15
+ const context = yield* partitions.contextEffect(encode(partition));
16
+ return Context.get(context, Runtime);
17
+ })
18
+ });
19
+ }));
20
+ };
21
+ //#endregion
22
+ export { Runtimes };
23
+
24
+ //# sourceMappingURL=Runtimes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Runtimes.js","names":[],"sources":["../src/Runtimes.ts"],"sourcesContent":["import { Context, Effect, Layer, LayerMap, Schema } from \"effect\";\nimport { Runtime } from \"./Runtime.js\";\nimport { RuntimePartition, RuntimePartitionSchema } from \"./RuntimePartition.js\";\nimport type { RuntimeService } from \"./Runtime.js\";\nimport type { RuntimeAcquisitionError } from \"./types.js\";\nimport type { BrowserAuthentication } from \"./types.js\";\nimport type { Scope } from \"effect\";\n\n/** Platform configuration supplies a Layer; partition identity is an Effect requirement. */\nexport type RuntimeLayer = Layer.Layer<Runtime, RuntimeAcquisitionError, RuntimePartition>;\n/** Platform capabilities plus lazy partition acquisition; creating this Layer opens no storage. */\nexport type RuntimesLayer = Layer.Layer<Runtimes, RuntimeAcquisitionError>;\n\n/** Scoped partition acquisition for installations that open multiple ontologies. */\nexport class Runtimes extends Context.Service<\n Runtimes,\n {\n readonly browserAuthentication?: BrowserAuthentication;\n readonly acquire: (\n partition: RuntimePartition[\"Service\"]\n ) => Effect.Effect<RuntimeService, RuntimeAcquisitionError, Scope.Scope>;\n }\n>()(\"@party-stack/runtime/Runtimes\") {\n static readonly layer = (\n platform: RuntimeLayer,\n options: { readonly browserAuthentication?: BrowserAuthentication } = {}\n ) =>\n Layer.effect(\n Runtimes,\n Effect.gen(function* () {\n const codec = Schema.fromJsonString(RuntimePartitionSchema);\n const encode = Schema.encodeSync(codec);\n const decode = Schema.decodeUnknownSync(codec);\n const partitions = yield* LayerMap.make((key: string) =>\n Layer.fresh(platform).pipe(Layer.provide(Layer.succeed(RuntimePartition)(decode(key))))\n );\n return Runtimes.of({\n browserAuthentication: options.browserAuthentication,\n acquire: Effect.fnUntraced(function* (partition) {\n const context = yield* partitions.contextEffect(encode(partition));\n return Context.get(context, Runtime);\n }),\n });\n })\n );\n}\n"],"mappings":";;;;;AAcA,IAAa,WAAb,MAAa,iBAAiB,QAAQ,QAQpC,CAAC,CAAC,+BAA+B,CAAC,CAAC;CACjC,OAAgB,SACZ,UACA,UAAsE,CAAC,MAEvE,MAAM,OACF,UACA,OAAO,IAAI,aAAa;EACpB,MAAM,QAAQ,OAAO,eAAe,sBAAsB;EAC1D,MAAM,SAAS,OAAO,WAAW,KAAK;EACtC,MAAM,SAAS,OAAO,kBAAkB,KAAK;EAC7C,MAAM,aAAa,OAAO,SAAS,MAAM,QACrC,MAAM,MAAM,QAAQ,CAAC,CAAC,KAAK,MAAM,QAAQ,MAAM,QAAQ,gBAAgB,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAC1F;EACA,OAAO,SAAS,GAAG;GACf,uBAAuB,QAAQ;GAC/B,SAAS,OAAO,WAAW,WAAW,WAAW;IAC7C,MAAM,UAAU,OAAO,WAAW,cAAc,OAAO,SAAS,CAAC;IACjE,OAAO,QAAQ,IAAI,SAAS,OAAO;GACvC,CAAC;EACL,CAAC;CACL,CAAC,CACL;AACR"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -0,0 +1,26 @@
1
+ import { RuntimeError } from "./Runtime.js";
2
+ import { Effect } from "effect";
3
+ //#region src/capacity.d.ts
4
+ /** Estimates describe the named shared resource, not a reservation for this partition. */
5
+ export interface CapacityEstimate {
6
+ readonly scope: "origin" | "filesystem" | "process" | "isolate" | "database";
7
+ readonly usedBytes?: number;
8
+ readonly limitBytes?: number;
9
+ readonly availableBytes?: number;
10
+ }
11
+ export interface ResourceCapacity {
12
+ readonly memory: Effect.Effect<CapacityEstimate | undefined, RuntimeError>;
13
+ readonly storage: Effect.Effect<CapacityEstimate | undefined, RuntimeError>;
14
+ }
15
+ /** Workers expose an isolate limit, not measurable free heap. DO SQLite exposes
16
+ * databaseSize; its quota is supplied explicitly because plans can differ.
17
+ */
18
+ export declare const cloudflareCapacity: (options?: {
19
+ readonly sql?: {
20
+ readonly databaseSize: number;
21
+ };
22
+ readonly storageLimitBytes?: number;
23
+ readonly memoryLimitBytes?: number;
24
+ }) => ResourceCapacity;
25
+ //#endregion
26
+ //# sourceMappingURL=capacity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacity.d.ts","names":[],"sources":["../src/capacity.ts"],"mappings":";;;;iBAIiB;WACJ;WACA;WACA;WACA;;iBAEI;WACJ,QAAQ,OAAO,OAAO,8BAA8B;WACpD,SAAS,OAAO,OAAO,8BAA8B;;;;;qBAMrD,qBAAkB;WAClB;aAAiB;;WACjB;WACA;MACT"}
@@ -0,0 +1,28 @@
1
+ import { RuntimeError } from "./Runtime.js";
2
+ import { Effect } from "effect";
3
+ //#region src/capacity.ts
4
+ /** Workers expose an isolate limit, not measurable free heap. DO SQLite exposes
5
+ * databaseSize; its quota is supplied explicitly because plans can differ.
6
+ */
7
+ const cloudflareCapacity = (options) => ({
8
+ memory: Effect.sync(() => ({
9
+ scope: "isolate",
10
+ limitBytes: options?.memoryLimitBytes ?? 134217728
11
+ })),
12
+ storage: Effect.try({
13
+ try: () => options?.sql ? {
14
+ scope: "database",
15
+ usedBytes: options.sql.databaseSize,
16
+ limitBytes: options.storageLimitBytes,
17
+ availableBytes: options.storageLimitBytes === void 0 ? void 0 : Math.max(0, options.storageLimitBytes - options.sql.databaseSize)
18
+ } : void 0,
19
+ catch: (cause) => new RuntimeError({
20
+ operation: "capacity.storage",
21
+ cause
22
+ })
23
+ })
24
+ });
25
+ //#endregion
26
+ export { cloudflareCapacity };
27
+
28
+ //# sourceMappingURL=capacity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacity.js","names":[],"sources":["../src/capacity.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { RuntimeError } from \"./Runtime.js\";\n\n/** Estimates describe the named shared resource, not a reservation for this partition. */\nexport interface CapacityEstimate {\n readonly scope: \"origin\" | \"filesystem\" | \"process\" | \"isolate\" | \"database\";\n readonly usedBytes?: number;\n readonly limitBytes?: number;\n readonly availableBytes?: number;\n}\nexport interface ResourceCapacity {\n readonly memory: Effect.Effect<CapacityEstimate | undefined, RuntimeError>;\n readonly storage: Effect.Effect<CapacityEstimate | undefined, RuntimeError>;\n}\n\n/** Workers expose an isolate limit, not measurable free heap. DO SQLite exposes\n * databaseSize; its quota is supplied explicitly because plans can differ.\n */\nexport const cloudflareCapacity = (options?: {\n readonly sql?: { readonly databaseSize: number };\n readonly storageLimitBytes?: number;\n readonly memoryLimitBytes?: number;\n}): ResourceCapacity => ({\n memory: Effect.sync(() => ({\n scope: \"isolate\",\n limitBytes: options?.memoryLimitBytes ?? 128 * 1024 * 1024,\n })),\n storage: Effect.try({\n try: () =>\n options?.sql\n ? {\n scope: \"database\" as const,\n usedBytes: options.sql.databaseSize,\n limitBytes: options.storageLimitBytes,\n availableBytes:\n options.storageLimitBytes === undefined\n ? undefined\n : Math.max(0, options.storageLimitBytes - options.sql.databaseSize),\n }\n : undefined,\n catch: (cause) => new RuntimeError({ operation: \"capacity.storage\", cause }),\n }),\n});\n"],"mappings":";;;;;;AAkBA,MAAa,sBAAsB,aAIV;CACrB,QAAQ,OAAO,YAAY;EACvB,OAAO;EACP,YAAY,SAAS,oBAAoB;CAC7C,EAAE;CACF,SAAS,OAAO,IAAI;EAChB,WACI,SAAS,MACH;GACI,OAAO;GACP,WAAW,QAAQ,IAAI;GACvB,YAAY,QAAQ;GACpB,gBACI,QAAQ,sBAAsB,KAAA,IACxB,KAAA,IACA,KAAK,IAAI,GAAG,QAAQ,oBAAoB,QAAQ,IAAI,YAAY;EAC9E,IACA,KAAA;EACV,QAAQ,UAAU,IAAI,aAAa;GAAE,WAAW;GAAoB;EAAM,CAAC;CAC/E,CAAC;AACL"}
@@ -0,0 +1,36 @@
1
+ import { RuntimeError } from "./Runtime.js";
2
+ import { Effect } from "effect";
3
+ import { EncryptionError, EncryptionKey } from "@party-stack/ontology-storage/encrypted";
4
+ //#region src/encryptionKeys.d.ts
5
+ /** Platform key-material persistence used underneath the encryption keyring. */
6
+ export interface KeyMaterialStore {
7
+ readonly get: (id: string) => Effect.Effect<string | undefined, RuntimeError>;
8
+ readonly set: (id: string, value: string) => Effect.Effect<void, RuntimeError>;
9
+ readonly delete: (id: string) => Effect.Effect<void, RuntimeError>;
10
+ }
11
+ export interface KeyMaterialCodec {
12
+ readonly generate: () => Promise<string>;
13
+ readonly import: (encoded: string) => Promise<EncryptionKey>;
14
+ }
15
+ /** Keys and the active key ID stay in the platform secret store. Unique immutable
16
+ * key slots make concurrent first creation safe without a database lock or CAS:
17
+ * both creators retain their keys, whichever active ID is published last wins.
18
+ * Never hold a database transaction open while waiting for the OS keychain.
19
+ */
20
+ export declare const makeKeyMaterialStoreKeyring: (secrets: KeyMaterialStore, codec?: KeyMaterialCodec | undefined) => Effect.Effect<{
21
+ active: Effect.Effect<{
22
+ id: string;
23
+ key: EncryptionKey;
24
+ }, EncryptionError, never>;
25
+ get: (id: string) => Effect.Effect<EncryptionKey | undefined, EncryptionError, never>;
26
+ }, never, never>;
27
+ /** Ephemeral keys for isolated memory runtimes; no key material is persisted. */
28
+ export declare const makeMemoryEncryptionKeyring: () => Effect.Effect<{
29
+ active: Effect.Effect<{
30
+ id: `${string}-${string}-${string}-${string}-${string}`;
31
+ key: CryptoKey;
32
+ }, EncryptionError, never>;
33
+ get: (requested: string) => Effect.Effect<undefined, never, never> | Effect.Effect<CryptoKey, EncryptionError, never>;
34
+ }, never, never>;
35
+ //#endregion
36
+ //# sourceMappingURL=encryptionKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryptionKeys.d.ts","names":[],"sources":["../src/encryptionKeys.ts"],"mappings":";;;;;iBAUiB;WACJ,MAAM,eAAe,OAAO,2BAA2B;WACvD,MAAM,YAAY,kBAAkB,OAAO,aAAa;WACxD,SAAS,eAAe,OAAO,aAAa;;iBAGxC;WACJ,gBAAgB;WAChB,SAAS,oBAAoB,QAAQ;;;;;;;qBAqBrC,8BAA2B,SAAA,kBAAA,QAAA,iCAAA,OAAA;;;;;EAYnB,MAAA,eAAM,OAAA,OAAA,2BAAA;;;qBA8Bd,mCAA2B,OAAA;;;;;EAgBf,MAAA,sBAAM,OAAA,kCAAA,OAAA,OAAA,WAAA"}
@@ -0,0 +1,84 @@
1
+ import { Effect, Exit, Result } from "effect";
2
+ import { EncryptionError } from "@party-stack/ontology-storage/encrypted";
3
+ import * as Base64 from "effect/encoding/Base64";
4
+ //#region src/encryptionKeys.ts
5
+ const webCryptoKeys = {
6
+ generate: async () => Base64.encode(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(32))),
7
+ import: async (encoded) => {
8
+ const decoded = Base64.decode(encoded);
9
+ if (Result.isFailure(decoded)) throw new Error("Invalid encryption key.");
10
+ return crypto.subtle.importKey("raw", new Uint8Array(decoded.success), "AES-GCM", false, ["encrypt", "decrypt"]);
11
+ }
12
+ };
13
+ /** Keys and the active key ID stay in the platform secret store. Unique immutable
14
+ * key slots make concurrent first creation safe without a database lock or CAS:
15
+ * both creators retain their keys, whichever active ID is published last wins.
16
+ * Never hold a database transaction open while waiting for the OS keychain.
17
+ */
18
+ const makeKeyMaterialStoreKeyring = Effect.fnUntraced(function* (secrets, codec = webCryptoKeys) {
19
+ const failure = () => new EncryptionError({
20
+ operation: "key",
21
+ kind: "Crypto",
22
+ message: "Platform encryption key access failed."
23
+ });
24
+ const attempt = (run) => Effect.tryPromise({
25
+ try: run,
26
+ catch: failure
27
+ });
28
+ const slot = (id) => `encryption:key:${id}`;
29
+ const get = (id) => Effect.gen(function* () {
30
+ const encoded = yield* secrets.get(slot(id));
31
+ return encoded === void 0 ? void 0 : yield* attempt(() => codec.import(encoded));
32
+ }).pipe(Effect.mapError(failure));
33
+ return {
34
+ active: yield* Effect.cachedWithTTL(Effect.gen(function* () {
35
+ const existing = yield* secrets.get("encryption:active");
36
+ if (existing) {
37
+ const key = yield* get(existing);
38
+ if (!key) return yield* failure();
39
+ return {
40
+ id: existing,
41
+ key
42
+ };
43
+ }
44
+ const id = crypto.randomUUID();
45
+ const encoded = yield* attempt(codec.generate);
46
+ const key = yield* attempt(() => codec.import(encoded));
47
+ yield* Effect.uninterruptible(Effect.gen(function* () {
48
+ yield* secrets.set(slot(id), encoded);
49
+ yield* secrets.set("encryption:active", id);
50
+ }));
51
+ return {
52
+ id,
53
+ key
54
+ };
55
+ }).pipe(Effect.mapError(failure)), (exit) => Exit.isSuccess(exit) ? Infinity : 0),
56
+ get
57
+ };
58
+ });
59
+ /** Ephemeral keys for isolated memory runtimes; no key material is persisted. */
60
+ const makeMemoryEncryptionKeyring = Effect.fnUntraced(function* () {
61
+ const id = crypto.randomUUID();
62
+ const key = yield* Effect.cached(Effect.tryPromise({
63
+ try: () => crypto.subtle.generateKey({
64
+ name: "AES-GCM",
65
+ length: 256
66
+ }, false, ["encrypt", "decrypt"]),
67
+ catch: () => new EncryptionError({
68
+ operation: "key",
69
+ kind: "Crypto",
70
+ message: "Could not create an ephemeral encryption key."
71
+ })
72
+ }));
73
+ return {
74
+ active: Effect.map(key, (key) => ({
75
+ id,
76
+ key
77
+ })),
78
+ get: (requested) => requested === id ? key : Effect.succeed(void 0)
79
+ };
80
+ });
81
+ //#endregion
82
+ export { makeKeyMaterialStoreKeyring, makeMemoryEncryptionKeyring };
83
+
84
+ //# sourceMappingURL=encryptionKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryptionKeys.js","names":[],"sources":["../src/encryptionKeys.ts"],"sourcesContent":["import {\n EncryptionError,\n type EncryptionKey,\n type EncryptionKeyringService,\n} from \"@party-stack/ontology-storage/encrypted\";\nimport { Effect, Exit, Result } from \"effect\";\nimport * as Base64 from \"effect/encoding/Base64\";\nimport type { RuntimeError } from \"./Runtime.js\";\n\n/** Platform key-material persistence used underneath the encryption keyring. */\nexport interface KeyMaterialStore {\n readonly get: (id: string) => Effect.Effect<string | undefined, RuntimeError>;\n readonly set: (id: string, value: string) => Effect.Effect<void, RuntimeError>;\n readonly delete: (id: string) => Effect.Effect<void, RuntimeError>;\n}\n\nexport interface KeyMaterialCodec {\n readonly generate: () => Promise<string>;\n readonly import: (encoded: string) => Promise<EncryptionKey>;\n}\n// TODO(Effect 4.1): use its crypto services for generation/import where compatible.\n// Provide those services explicitly: 4.1 removes crypto from platform *Services\n// bundles. This store still owns durable active IDs and OS keyring persistence.\nconst webCryptoKeys: KeyMaterialCodec = {\n generate: async () => Base64.encode(crypto.getRandomValues(new Uint8Array(32))),\n import: async (encoded) => {\n const decoded = Base64.decode(encoded);\n if (Result.isFailure(decoded)) throw new Error(\"Invalid encryption key.\");\n return crypto.subtle.importKey(\"raw\", new Uint8Array(decoded.success), \"AES-GCM\", false, [\n \"encrypt\",\n \"decrypt\",\n ]);\n },\n};\n/** Keys and the active key ID stay in the platform secret store. Unique immutable\n * key slots make concurrent first creation safe without a database lock or CAS:\n * both creators retain their keys, whichever active ID is published last wins.\n * Never hold a database transaction open while waiting for the OS keychain.\n */\nexport const makeKeyMaterialStoreKeyring = Effect.fnUntraced(function* (\n secrets: KeyMaterialStore,\n codec: KeyMaterialCodec = webCryptoKeys\n) {\n const failure = () =>\n new EncryptionError({\n operation: \"key\",\n kind: \"Crypto\",\n message: \"Platform encryption key access failed.\",\n });\n const attempt = <A>(run: () => Promise<A>) => Effect.tryPromise({ try: run, catch: failure });\n const slot = (id: string) => `encryption:key:${id}`;\n const get = (id: string) =>\n Effect.gen(function* () {\n const encoded = yield* secrets.get(slot(id));\n return encoded === undefined ? undefined : yield* attempt(() => codec.import(encoded));\n }).pipe(Effect.mapError(failure));\n const active = yield* Effect.cachedWithTTL(\n Effect.gen(function* () {\n const existing = yield* secrets.get(\"encryption:active\");\n if (existing) {\n const key = yield* get(existing);\n if (!key) return yield* failure();\n return { id: existing, key };\n }\n const id = crypto.randomUUID();\n const encoded = yield* attempt(codec.generate);\n const key = yield* attempt(() => codec.import(encoded));\n yield* Effect.uninterruptible(\n Effect.gen(function* () {\n yield* secrets.set(slot(id), encoded);\n yield* secrets.set(\"encryption:active\", id);\n })\n );\n return { id, key };\n }).pipe(Effect.mapError(failure)),\n (exit) => (Exit.isSuccess(exit) ? Infinity : 0)\n );\n return { active, get } satisfies EncryptionKeyringService;\n});\n\n/** Ephemeral keys for isolated memory runtimes; no key material is persisted. */\nexport const makeMemoryEncryptionKeyring = Effect.fnUntraced(function* () {\n const id = crypto.randomUUID();\n const key = yield* Effect.cached(\n Effect.tryPromise({\n try: () =>\n crypto.subtle.generateKey({ name: \"AES-GCM\", length: 256 }, false, [\"encrypt\", \"decrypt\"]),\n catch: () =>\n new EncryptionError({\n operation: \"key\",\n kind: \"Crypto\",\n message: \"Could not create an ephemeral encryption key.\",\n }),\n })\n );\n return {\n active: Effect.map(key, (key) => ({ id, key })),\n get: (requested: string) => (requested === id ? key : Effect.succeed(undefined)),\n } satisfies EncryptionKeyringService;\n});\n"],"mappings":";;;;AAuBA,MAAM,gBAAkC;CACpC,UAAU,YAAY,OAAO,OAAO,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,CAAC;CAC9E,QAAQ,OAAO,YAAY;EACvB,MAAM,UAAU,OAAO,OAAO,OAAO;EACrC,IAAI,OAAO,UAAU,OAAO,GAAG,MAAM,IAAI,MAAM,yBAAyB;EACxE,OAAO,OAAO,OAAO,UAAU,OAAO,IAAI,WAAW,QAAQ,OAAO,GAAG,WAAW,OAAO,CACrF,WACA,SACJ,CAAC;CACL;AACJ;;;;;;AAMA,MAAa,8BAA8B,OAAO,WAAW,WACzD,SACA,QAA0B,eAC5B;CACE,MAAM,gBACF,IAAI,gBAAgB;EAChB,WAAW;EACX,MAAM;EACN,SAAS;CACb,CAAC;CACL,MAAM,WAAc,QAA0B,OAAO,WAAW;EAAE,KAAK;EAAK,OAAO;CAAQ,CAAC;CAC5F,MAAM,QAAQ,OAAe,kBAAkB;CAC/C,MAAM,OAAO,OACT,OAAO,IAAI,aAAa;EACpB,MAAM,UAAU,OAAO,QAAQ,IAAI,KAAK,EAAE,CAAC;EAC3C,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY,OAAO,cAAc,MAAM,OAAO,OAAO,CAAC;CACzF,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,OAAO,CAAC;CAsBpC,OAAO;EAAE,QAAA,OArBa,OAAO,cACzB,OAAO,IAAI,aAAa;GACpB,MAAM,WAAW,OAAO,QAAQ,IAAI,mBAAmB;GACvD,IAAI,UAAU;IACV,MAAM,MAAM,OAAO,IAAI,QAAQ;IAC/B,IAAI,CAAC,KAAK,OAAO,OAAO,QAAQ;IAChC,OAAO;KAAE,IAAI;KAAU;IAAI;GAC/B;GACA,MAAM,KAAK,OAAO,WAAW;GAC7B,MAAM,UAAU,OAAO,QAAQ,MAAM,QAAQ;GAC7C,MAAM,MAAM,OAAO,cAAc,MAAM,OAAO,OAAO,CAAC;GACtD,OAAO,OAAO,gBACV,OAAO,IAAI,aAAa;IACpB,OAAO,QAAQ,IAAI,KAAK,EAAE,GAAG,OAAO;IACpC,OAAO,QAAQ,IAAI,qBAAqB,EAAE;GAC9C,CAAC,CACL;GACA,OAAO;IAAE;IAAI;GAAI;EACrB,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,OAAO,CAAC,IAC/B,SAAU,KAAK,UAAU,IAAI,IAAI,WAAW,CACjD;EACiB;CAAI;AACzB,CAAC;;AAGD,MAAa,8BAA8B,OAAO,WAAW,aAAa;CACtE,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,MAAM,OAAO,OAAO,OACtB,OAAO,WAAW;EACd,WACI,OAAO,OAAO,YAAY;GAAE,MAAM;GAAW,QAAQ;EAAI,GAAG,OAAO,CAAC,WAAW,SAAS,CAAC;EAC7F,aACI,IAAI,gBAAgB;GAChB,WAAW;GACX,MAAM;GACN,SAAS;EACb,CAAC;CACT,CAAC,CACL;CACA,OAAO;EACH,QAAQ,OAAO,IAAI,MAAM,SAAS;GAAE;GAAI;EAAI,EAAE;EAC9C,MAAM,cAAuB,cAAc,KAAK,MAAM,OAAO,QAAQ,KAAA,CAAS;CAClF;AACJ,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { createPersistedCollectionCoordinator } from "./coordinator/createPersistedCollectionCoordinator.js";
2
- import "./coordinator/index.js";
3
- import { BlobBytesStore, BrowserAuthentication, BrowserAuthenticationPresentation, BrowserAuthenticationSession, NetworkConnectivity, PersistenceAdapter, RuntimeAdapter, RuntimeAdapterProvider, SecretStore } from "./types.js";
4
- import { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
5
- import { defineRuntime } from "./utils/defineRuntime.js";
6
- import { createCollectionPersistence } from "./utils/createCollectionPersistence.js";
7
- import { createLocalCollection } from "./utils/createLocalCollection.js";
1
+ import { BrowserAuthenticationError } from "./BrowserAuthenticationError.js";
2
+ import { RuntimePartition } from "./RuntimePartition.js";
3
+ import { CapacityEstimate, ResourceCapacity, cloudflareCapacity } from "./capacity.js";
4
+ import { BrowserAuthentication, BrowserAuthenticationPresentation, BrowserAuthenticationSession, NetworkConnectivity, RuntimeAcquisitionError, RuntimeOptions } from "./types.js";
5
+ import { Runtime, RuntimeError, RuntimeService } from "./Runtime.js";
6
+ import { MemoryRuntime_d_exports } from "./MemoryRuntime.js";
7
+ import { alwaysOnlineConnectivity, makeNetworkConnectivity } from "./NetworkConnectivity.js";
8
+ import { RuntimeLayer, Runtimes, RuntimesLayer } from "./Runtimes.js";
9
+ import { KeyMaterialCodec, KeyMaterialStore, makeKeyMaterialStoreKeyring, makeMemoryEncryptionKeyring } from "./encryptionKeys.js";
8
10
  import { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
9
- import { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
10
- import { Coordination, CoordinationCallOptions, CoordinationClient, CoordinationClosedError, CoordinationError, CoordinationErrorCode, CoordinationHost, CoordinationMethodInput, CoordinationMethodResult, CoordinationOptions, CoordinationProtocolError, CoordinationService, CoordinationServiceClient, CoordinationServiceError, CoordinationServiceEvents, CoordinationServiceHandler, CoordinationServiceHandlers, CoordinationServiceMethods, CoordinationServicePublisher, CoordinationServiceServer, CoordinationTaskContext, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, LockBroadcastCoordinationOptions, SingleProcessCoordination, isCoordinationHost } from "@party-stack/coordination";
11
- export { type BlobBytesStore, type BrowserAuthentication, BrowserAuthenticationCancelledError, type BrowserAuthenticationPresentation, type BrowserAuthenticationSession, type Coordination, type CoordinationCallOptions, type CoordinationClient, CoordinationClosedError, CoordinationError, type CoordinationErrorCode, type CoordinationHost, type CoordinationMethodInput, type CoordinationMethodResult, type CoordinationOptions, CoordinationProtocolError, type CoordinationService, type CoordinationServiceClient, CoordinationServiceError, type CoordinationServiceEvents, type CoordinationServiceHandler, type CoordinationServiceHandlers, type CoordinationServiceMethods, type CoordinationServicePublisher, type CoordinationServiceServer, type CoordinationTaskContext, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, type LockBroadcastCoordinationOptions, MemoryBlobBytesStore, type NetworkConnectivity, type PersistenceAdapter, type RuntimeAdapter, type RuntimeAdapterProvider, type SecretStore, SingleProcessCoordination, createCollectionPersistence, createDefaultRuntime, createLocalCollection, createPersistedCollectionCoordinator, defineRuntime, isCoordinationHost };
11
+ import { BlobBytesService, ByteInput, ByteSource, byteChunks, byteIO, byteSource, collectByteBlob, readableByteSource } from "@party-stack/ontology-storage/blobs";
12
+ export { type BlobBytesService, type BrowserAuthentication, BrowserAuthenticationError, type BrowserAuthenticationPresentation, type BrowserAuthenticationSession, type ByteInput, type ByteSource, type CapacityEstimate, type KeyMaterialCodec, type KeyMaterialStore, MemoryBlobBytesStore, MemoryRuntime_d_exports as MemoryRuntime, type NetworkConnectivity, type ResourceCapacity, Runtime, type RuntimeAcquisitionError, RuntimeError, type RuntimeLayer, type RuntimeOptions, RuntimePartition, RuntimeService, Runtimes, type RuntimesLayer, alwaysOnlineConnectivity, byteChunks, byteIO, byteSource, cloudflareCapacity, collectByteBlob, makeKeyMaterialStoreKeyring, makeMemoryEncryptionKeyring, makeNetworkConnectivity, readableByteSource };
package/lib/index.js CHANGED
@@ -1,10 +1,11 @@
1
- import { createPersistedCollectionCoordinator } from "./coordinator/createPersistedCollectionCoordinator.js";
2
- import "./coordinator/index.js";
1
+ import { BrowserAuthenticationError } from "./BrowserAuthenticationError.js";
2
+ import { makeKeyMaterialStoreKeyring, makeMemoryEncryptionKeyring } from "./encryptionKeys.js";
3
3
  import { MemoryBlobBytesStore } from "./memory/MemoryBlobBytesStore.js";
4
- import { defineRuntime } from "./utils/defineRuntime.js";
5
- import { createDefaultRuntime } from "./utils/createDefaultRuntime.js";
6
- import { createCollectionPersistence } from "./utils/createCollectionPersistence.js";
7
- import { createLocalCollection } from "./utils/createLocalCollection.js";
8
- import { BrowserAuthenticationCancelledError } from "./utils/BrowserAuthenticationCancelledError.js";
9
- import { CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, SingleProcessCoordination, isCoordinationHost } from "@party-stack/coordination";
10
- export { BrowserAuthenticationCancelledError, CoordinationClosedError, CoordinationError, CoordinationProtocolError, CoordinationServiceError, CoordinationTaskRejectedError, CoordinationTransportError, LockBroadcastCoordination, MemoryBlobBytesStore, SingleProcessCoordination, createCollectionPersistence, createDefaultRuntime, createLocalCollection, createPersistedCollectionCoordinator, defineRuntime, isCoordinationHost };
4
+ import { alwaysOnlineConnectivity, makeNetworkConnectivity } from "./NetworkConnectivity.js";
5
+ import { RuntimePartition } from "./RuntimePartition.js";
6
+ import { Runtime, RuntimeError } from "./Runtime.js";
7
+ import { MemoryRuntime_exports } from "./MemoryRuntime.js";
8
+ import { Runtimes } from "./Runtimes.js";
9
+ import { cloudflareCapacity } from "./capacity.js";
10
+ import { byteChunks, byteIO, byteSource, collectByteBlob, readableByteSource } from "@party-stack/ontology-storage/blobs";
11
+ export { BrowserAuthenticationError, MemoryBlobBytesStore, MemoryRuntime_exports as MemoryRuntime, Runtime, RuntimeError, RuntimePartition, Runtimes, alwaysOnlineConnectivity, byteChunks, byteIO, byteSource, cloudflareCapacity, collectByteBlob, makeKeyMaterialStoreKeyring, makeMemoryEncryptionKeyring, makeNetworkConnectivity, readableByteSource };
@@ -1,11 +1,12 @@
1
- import { BlobBytesStore } from "../types.js";
1
+ import { Effect } from "effect";
2
+ import { BlobBytesService, ByteInput } from "@party-stack/ontology-storage/blobs";
2
3
  //#region src/memory/MemoryBlobBytesStore.d.ts
3
- export declare class MemoryBlobBytesStore implements BlobBytesStore {
4
+ export declare class MemoryBlobBytesStore implements BlobBytesService {
4
5
  readonly blobs: Map<string, Blob>;
5
6
  constructor(blobs?: Map<string, Blob>);
6
- write(id: string, blob: Blob): Promise<void>;
7
- read(id: string): Promise<Blob>;
8
- delete(id: string): Promise<void>;
7
+ readonly write: (id: string, value: ByteInput) => Effect.Effect<void, unknown, never>;
8
+ readonly read: (id: string) => Effect.Effect<import("@party-stack/ontology-storage/blobs").ByteSource | undefined, never, never>;
9
+ readonly delete: (id: string) => Effect.Effect<void, never, never>;
9
10
  }
10
11
  //#endregion
11
12
  //# sourceMappingURL=MemoryBlobBytesStore.d.ts.map