target-supabase-sdk 0.2.15 → 0.2.17

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 (99) hide show
  1. package/README.md +20 -0
  2. package/dist/browser.d.ts +6 -2
  3. package/dist/browser.d.ts.map +1 -1
  4. package/dist/browser.js +1 -1
  5. package/dist/chunks/{task-queue-DCY_0Qj0.js → task-queue-DufG7PlX.js} +295 -121
  6. package/dist/chunks/task-queue-DufG7PlX.js.map +1 -0
  7. package/dist/config/config.api.d.ts +61 -0
  8. package/dist/config/config.api.d.ts.map +1 -0
  9. package/dist/{service → config}/config.interface.d.ts +1 -3
  10. package/dist/config/config.interface.d.ts.map +1 -0
  11. package/dist/config/index.d.ts +9 -0
  12. package/dist/config/index.d.ts.map +1 -0
  13. package/dist/node/runtime-state/service-runtime-state.types.d.ts +1 -1
  14. package/dist/node/runtime-state/service-runtime-state.types.d.ts.map +1 -1
  15. package/dist/node/service-guard/registry-slot-guard-step.d.ts +1 -1
  16. package/dist/node/service-guard/registry-slot-guard-step.d.ts.map +1 -1
  17. package/dist/node/service-guard/service-guard.interface.d.ts +1 -1
  18. package/dist/node/service-guard/service-guard.interface.d.ts.map +1 -1
  19. package/dist/node/service-host/claim-registry-slot.d.ts +1 -1
  20. package/dist/node/service-host/claim-registry-slot.d.ts.map +1 -1
  21. package/dist/node/service-host/service-host.d.ts +1 -1
  22. package/dist/node/service-host/service-host.d.ts.map +1 -1
  23. package/dist/node/service-host/single-process-service.d.ts +1 -1
  24. package/dist/node/service-host/single-process-service.d.ts.map +1 -1
  25. package/dist/node.d.ts +2 -0
  26. package/dist/node.d.ts.map +1 -1
  27. package/dist/node.js +211 -6
  28. package/dist/node.js.map +1 -1
  29. package/dist/service/index.d.ts +5 -10
  30. package/dist/service/index.d.ts.map +1 -1
  31. package/dist/service/registry/index.d.ts +14 -0
  32. package/dist/service/registry/index.d.ts.map +1 -0
  33. package/dist/service/{registry-lifecycle.d.ts → registry/registry-lifecycle.d.ts} +1 -1
  34. package/dist/service/registry/registry-lifecycle.d.ts.map +1 -0
  35. package/dist/service/{config.api.d.ts → registry/registry.api.d.ts} +5 -65
  36. package/dist/service/registry/registry.api.d.ts.map +1 -0
  37. package/dist/service/registry/registry.constant.d.ts +23 -0
  38. package/dist/service/registry/registry.constant.d.ts.map +1 -0
  39. package/dist/service/registry/registry.interface.d.ts +15 -0
  40. package/dist/service/registry/registry.interface.d.ts.map +1 -0
  41. package/dist/service/{registry.service.d.ts → registry/registry.service.d.ts} +23 -15
  42. package/dist/service/registry/registry.service.d.ts.map +1 -0
  43. package/dist/service/service.interface.d.ts +0 -10
  44. package/dist/service/service.interface.d.ts.map +1 -1
  45. package/dist/shared/media/index.d.ts +14 -0
  46. package/dist/shared/media/index.d.ts.map +1 -0
  47. package/dist/shared/media/media.build.d.ts +20 -0
  48. package/dist/shared/media/media.build.d.ts.map +1 -0
  49. package/dist/shared/media/media.interface.d.ts +38 -0
  50. package/dist/shared/media/media.interface.d.ts.map +1 -0
  51. package/dist/shared/media/media.mime.d.ts +4 -0
  52. package/dist/shared/media/media.mime.d.ts.map +1 -0
  53. package/dist/shared/media/media.name.d.ts +6 -0
  54. package/dist/shared/media/media.name.d.ts.map +1 -0
  55. package/dist/shared/media/media.query.d.ts +8 -0
  56. package/dist/shared/media/media.query.d.ts.map +1 -0
  57. package/dist/shared/media/node/index.d.ts +9 -0
  58. package/dist/shared/media/node/index.d.ts.map +1 -0
  59. package/dist/shared/media/node/media.access.d.ts +40 -0
  60. package/dist/shared/media/node/media.access.d.ts.map +1 -0
  61. package/dist/shared/media/node/media.service.d.ts +30 -0
  62. package/dist/shared/media/node/media.service.d.ts.map +1 -0
  63. package/package.json +1 -1
  64. package/src/browser.ts +21 -9
  65. package/src/config/config.api.ts +72 -0
  66. package/src/{service → config}/config.interface.ts +1 -4
  67. package/src/config/index.ts +9 -0
  68. package/src/node/runtime-state/create-service-runtime-state-store.ts +1 -1
  69. package/src/node/runtime-state/service-runtime-state.types.ts +1 -1
  70. package/src/node/service-guard/registry-slot-guard-step.ts +4 -1
  71. package/src/node/service-guard/run-service-guard-tick.ts +1 -1
  72. package/src/node/service-guard/service-guard.interface.ts +1 -1
  73. package/src/node/service-host/claim-registry-slot.ts +2 -2
  74. package/src/node/service-host/service-host.ts +2 -2
  75. package/src/node/service-host/single-process-service.ts +1 -1
  76. package/src/node.ts +13 -0
  77. package/src/service/index.ts +30 -40
  78. package/src/service/registry/index.ts +65 -0
  79. package/src/service/{registry-lifecycle.ts → registry/registry-lifecycle.ts} +3 -3
  80. package/src/service/{config.api.ts → registry/registry.api.ts} +6 -80
  81. package/src/service/registry/registry.constant.ts +17 -0
  82. package/src/service/registry/registry.interface.ts +16 -0
  83. package/src/service/{registry.service.ts → registry/registry.service.ts} +66 -65
  84. package/src/service/service.interface.ts +0 -12
  85. package/src/shared/media/README.md +109 -0
  86. package/src/shared/media/index.ts +19 -0
  87. package/src/shared/media/media.build.ts +69 -0
  88. package/src/shared/media/media.interface.ts +45 -0
  89. package/src/shared/media/media.mime.ts +64 -0
  90. package/src/shared/media/media.name.ts +33 -0
  91. package/src/shared/media/media.query.ts +13 -0
  92. package/src/shared/media/node/index.ts +13 -0
  93. package/src/shared/media/node/media.access.ts +148 -0
  94. package/src/shared/media/node/media.service.ts +129 -0
  95. package/dist/chunks/task-queue-DCY_0Qj0.js.map +0 -1
  96. package/dist/service/config.api.d.ts.map +0 -1
  97. package/dist/service/config.interface.d.ts.map +0 -1
  98. package/dist/service/registry-lifecycle.d.ts.map +0 -1
  99. package/dist/service/registry.service.d.ts.map +0 -1
package/src/browser.ts CHANGED
@@ -6,6 +6,12 @@
6
6
  */
7
7
 
8
8
  export type { SupabaseClient } from "@supabase/supabase-js";
9
+ export type {
10
+ Config,
11
+ ConfigDetails,
12
+ GetConfigPayload,
13
+ } from "./config/index";
14
+ export { CategoryConfig, getConfig, getConfigSchema } from "./config/index";
9
15
  export * from "./core.api";
10
16
  export * from "./core.interface";
11
17
  export * from "./core.schema";
@@ -102,13 +108,10 @@ export * from "./repo/repo.interface";
102
108
  export type {
103
109
  Api,
104
110
  ApiDetails,
105
- AppendSystemRegistrySlotsInput,
106
- AppendSystemRegistrySlotsOutcome,
111
+ AppendSystemRegistryEmptySlotsInput,
112
+ AppendSystemRegistryEmptySlotsOutcome,
107
113
  ClaimRegistrySlotInput,
108
- Config,
109
- ConfigDetails,
110
114
  GetApiPayload,
111
- GetConfigPayload,
112
115
  GetServicePayload,
113
116
  PatchServiceRuntimeInput,
114
117
  PostApiPayload,
@@ -136,12 +139,11 @@ export type {
136
139
  export {
137
140
  ApiMethod,
138
141
  apiDetailsSchema,
139
- appendSystemRegistrySlots,
142
+ appendSystemRegistryEmptySlots,
140
143
  assertRegistrySlotAvailable,
141
144
  assertRegistrySlotOwner,
142
145
  buildEmptyServiceSlots,
143
146
  buildSystemRegistryConfigDetails,
144
- CategoryConfig,
145
147
  CategoryService,
146
148
  claimServiceRegistrySlot,
147
149
  createActiveServiceLifecycle,
@@ -152,8 +154,6 @@ export {
152
154
  fieldDefinitionSchema,
153
155
  getApi,
154
156
  getApiSchema,
155
- getConfig,
156
- getConfigSchema,
157
157
  getService,
158
158
  getServiceSchema,
159
159
  getTargetSystemRegistry,
@@ -189,6 +189,7 @@ export {
189
189
  unregisterService,
190
190
  unregisterServiceAtShutdown,
191
191
  } from "./service/index";
192
+
192
193
  export type { FetchInitFactory, FetchRetryOptions } from "./shared/http/fetch-retry";
193
194
  export {
194
195
  fetchBinaryWithRetry,
@@ -222,6 +223,17 @@ export {
222
223
  parseLogBatchMeta,
223
224
  resolveLogMinLevel,
224
225
  } from "./shared/log";
226
+ export type { BuildMediaLinkDraftInput, MediaOriginal, MediaValue } from "./shared/media";
227
+ export {
228
+ buildMediaLinkDraft,
229
+ buildMediaNameFromLocator,
230
+ guessMediaMime,
231
+ isMediaValue,
232
+ MEDIA_CONTENT_HASH_ALGORITHM,
233
+ MEDIA_CONTENT_HASH_PREFIX_LENGTH,
234
+ MEDIA_VALUES,
235
+ mediaLinkDedupFilters,
236
+ } from "./shared/media";
225
237
  export { isHttpUrl, resolveFetchUrl } from "./shared/utils/fetch-url";
226
238
  export { getValueAtPath } from "./shared/utils/get-value-at-path";
227
239
  export type {
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ import { getPossibleTarget, getTarget, type QueryFilter, validateWithSchema } from "../core.api";
3
+ import { CategoryConfig, type Config } from "./config.interface";
4
+
5
+ const targetIdSchema = z.string().trim().min(1);
6
+
7
+ export const getConfigSchema = z
8
+ .object({
9
+ id: targetIdSchema.optional(),
10
+ value: z.string().trim().min(1).optional(),
11
+ })
12
+ .refine(
13
+ (payload) => {
14
+ const hasId = payload.id != null && payload.id !== "";
15
+ const hasValue = payload.value != null && payload.value !== "";
16
+ return hasId !== hasValue;
17
+ },
18
+ { message: "Provide exactly one of id or value" },
19
+ );
20
+
21
+ export type GetConfigPayload = z.infer<typeof getConfigSchema>;
22
+
23
+ const configCategoryFilter: QueryFilter = {
24
+ field: "category",
25
+ operator: "eq",
26
+ value: CategoryConfig.CONFIG,
27
+ };
28
+
29
+ function buildConfigLookupFilters(payload: GetConfigPayload): QueryFilter[] {
30
+ const filters: QueryFilter[] = [configCategoryFilter];
31
+
32
+ if (payload.id == null || payload.id === "") {
33
+ filters.push({ field: "value", operator: "eq", value: payload.value! });
34
+ }
35
+
36
+ return filters;
37
+ }
38
+
39
+ /** Fetch a Config by id or by {@link Config.value} key (`category=config`). */
40
+ export const getConfig = validateWithSchema(
41
+ getConfigSchema,
42
+ "getConfigSchema",
43
+ )(async (payload) => {
44
+ const filterList = buildConfigLookupFilters(payload);
45
+
46
+ if (payload.id != null && payload.id !== "") {
47
+ const result = await getTarget({
48
+ id: payload.id,
49
+ filterList,
50
+ });
51
+ return {
52
+ ...result,
53
+ data: result.data as Config,
54
+ };
55
+ }
56
+
57
+ const result = await getPossibleTarget({
58
+ filterList,
59
+ });
60
+
61
+ if (result.data == null) {
62
+ return {
63
+ ...result,
64
+ data: undefined,
65
+ };
66
+ }
67
+
68
+ return {
69
+ ...result,
70
+ data: result.data as Config,
71
+ };
72
+ });
@@ -3,7 +3,7 @@ import type { Target } from "../core.interface";
3
3
  export interface Config extends Target {
4
4
  /** Human readable name */
5
5
  name: string;
6
- /** Unique key, like TARGET_SYSTEM_REGISTRY_KEY */
6
+ /** Unique key (e.g. system registry Config value) */
7
7
  value: string;
8
8
  category: CategoryConfig;
9
9
  details: ConfigDetails;
@@ -13,9 +13,6 @@ export enum CategoryConfig {
13
13
  CONFIG = "config",
14
14
  }
15
15
 
16
- /** Globally unique Config key for the declarative system service registry. */
17
- export const TARGET_SYSTEM_REGISTRY_KEY = "target-system-registry";
18
-
19
16
  export interface ConfigDetails {
20
17
  manifestVersion: number;
21
18
  /** How to resolve the Config */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Config domain public API — curated re-exports only.
3
+ * System registry seed / claim APIs live in `src/service/registry/`.
4
+ */
5
+
6
+ export type { GetConfigPayload } from "./config.api";
7
+ export { getConfig, getConfigSchema } from "./config.api";
8
+ export type { Config, ConfigDetails } from "./config.interface";
9
+ export { CategoryConfig } from "./config.interface";
@@ -1,4 +1,4 @@
1
- import { EMPTY_REGISTRY_SLOT_RUNTIME_STATE } from "../../service/registry-lifecycle";
1
+ import { EMPTY_REGISTRY_SLOT_RUNTIME_STATE } from "../../service/registry/registry-lifecycle";
2
2
  import type { JsonStatePatch } from "../fs/json-state-store";
3
3
  import { createShardedJsonFileStateStore } from "../fs/sharded-json-state-store";
4
4
  import type {
@@ -1,4 +1,4 @@
1
- import type { RegistrySlotRuntimeState } from "../../service/registry-lifecycle";
1
+ import type { RegistrySlotRuntimeState } from "../../service/registry/registry-lifecycle";
2
2
 
3
3
  export type ReadinessStatus = "pending" | "passed" | "failed";
4
4
 
@@ -1,4 +1,7 @@
1
- import { registrySlotRuntimePatchFromGuardResult, runRegistrySlotGuardCheck } from "../../service/registry-lifecycle";
1
+ import {
2
+ registrySlotRuntimePatchFromGuardResult,
3
+ runRegistrySlotGuardCheck,
4
+ } from "../../service/registry/registry-lifecycle";
2
5
  import type { LoggerWithScope } from "../../shared/log";
3
6
 
4
7
  export interface ApplyRegistrySlotGuardInput {
@@ -1,5 +1,5 @@
1
1
  import { scanTargetList } from "../../core.api";
2
- import { patchServiceRuntime } from "../../service/registry.service";
2
+ import { patchServiceRuntime } from "../../service/registry/registry.service";
3
3
  import { CategoryNode, type Node } from "../node.interface";
4
4
  import { evaluateBusyNodeLiveness } from "../node-liveness";
5
5
  import { applyRegistrySlotGuardStep } from "./registry-slot-guard-step";
@@ -1,4 +1,4 @@
1
- import type { RegistrySlotRuntimeState } from "../../service/registry-lifecycle";
1
+ import type { RegistrySlotRuntimeState } from "../../service/registry/registry-lifecycle";
2
2
  import type { LoggerWithScope } from "../../shared/log";
3
3
  import type { Node } from "../node.interface";
4
4
  import type { ReadinessCheck, ReadinessReport } from "../readiness/readiness.types";
@@ -1,5 +1,5 @@
1
- import { ServiceRegistryError } from "../../service/registry.service";
2
- import { claimServiceRegistrySlot, type ServiceRegistrySession } from "../../service/registry-lifecycle";
1
+ import { ServiceRegistryError } from "../../service/registry/registry.service";
2
+ import { claimServiceRegistrySlot, type ServiceRegistrySession } from "../../service/registry/registry-lifecycle";
3
3
  import type { Service } from "../../service/service.interface";
4
4
  import type { LoggerWithScope } from "../../shared/log";
5
5
 
@@ -1,5 +1,5 @@
1
- import { ServiceRegistryError } from "../../service/registry.service";
2
- import type { ServiceRegistrySession } from "../../service/registry-lifecycle";
1
+ import { ServiceRegistryError } from "../../service/registry/registry.service";
2
+ import type { ServiceRegistrySession } from "../../service/registry/registry-lifecycle";
3
3
  import type { Service } from "../../service/service.interface";
4
4
  import { createLogger, type LoggerWithScope } from "../../shared/log";
5
5
  import { LOG_SPOOL_SERVICE_ID_ENV } from "../../shared/log/spool/config";
@@ -1,4 +1,4 @@
1
- import type { ServiceRegistrySession } from "../../service/registry-lifecycle";
1
+ import type { ServiceRegistrySession } from "../../service/registry/registry-lifecycle";
2
2
  import type { Service } from "../../service/service.interface";
3
3
  import { createLogger, type LoggerWithScope } from "../../shared/log";
4
4
  import { claimRegistrySlotOrExit } from "./claim-registry-slot";
package/src/node.ts CHANGED
@@ -165,6 +165,19 @@ export {
165
165
  shutdownLogSpool,
166
166
  } from "./shared/log/spool/service-lifecycle";
167
167
  export type { LogBatchMeta, LogPersistLane } from "./shared/log/upload/interface";
168
+ export type {
169
+ CheckMediaAvailabilityInput,
170
+ FindMediaLinkInput,
171
+ MediaAvailabilityResult,
172
+ RegisterMediaLinkInput,
173
+ RegisterMediaLinkResult,
174
+ } from "./shared/media/node";
175
+ export {
176
+ checkMediaAvailability,
177
+ findMediaLink,
178
+ probeMediaOriginal,
179
+ registerMediaLink,
180
+ } from "./shared/media/node";
168
181
  export type {
169
182
  ConfigSchema,
170
183
  LoadCachedJsConfigOptions,
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Service domain public API — curated re-exports only.
3
+ * System registry: `./registry/` (seed, claim, slot views).
3
4
  */
4
5
 
5
6
  export type {
@@ -10,68 +11,58 @@ export type {
10
11
  } from "./base.interface";
11
12
  export { ServiceLifecycleStatus } from "./base.interface";
12
13
  export type {
13
- GetConfigPayload,
14
- PostSystemRegistryConfigPayload,
15
- ResetSystemRegistryConfigPayload,
16
- SystemRegistrySeedSlot,
17
- } from "./config.api";
18
- export {
19
- buildEmptyServiceSlots,
20
- buildSystemRegistryConfigDetails,
21
- DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS,
22
- getConfig,
23
- getConfigSchema,
24
- postSystemRegistryConfig,
25
- postSystemRegistryConfigSchema,
26
- resetSystemRegistryConfig,
27
- resetSystemRegistryConfigSchema,
28
- systemRegistrySeedSlotSchema,
29
- } from "./config.api";
30
- export type { Config, ConfigDetails } from "./config.interface";
31
- export { CategoryConfig, TARGET_SYSTEM_REGISTRY_KEY } from "./config.interface";
32
- export type {
33
- AppendSystemRegistrySlotsInput,
34
- AppendSystemRegistrySlotsOutcome,
14
+ AppendSystemRegistryEmptySlotsInput,
15
+ AppendSystemRegistryEmptySlotsOutcome,
16
+ ClaimRegistrySlotInput,
35
17
  PatchServiceRuntimeInput,
18
+ PostSystemRegistryConfigPayload,
36
19
  RegisterServiceInput,
20
+ RegistrySlotGuardResult,
21
+ RegistrySlotRuntimeState,
37
22
  ReleasedRegistrySlot,
38
23
  ReleaseSystemRegistrySlotsByServiceIdInput,
39
24
  ReleaseSystemRegistrySlotsByServiceIdOutcome,
40
25
  ReleaseSystemRegistrySlotsInput,
41
26
  ReleaseSystemRegistrySlotsOutcome,
27
+ ResetSystemRegistryConfigPayload,
28
+ ServiceRegistrySession,
29
+ ServiceSlot,
30
+ SystemRegistrySeedSlot,
42
31
  TargetSystemRegistrySlotView,
43
32
  TargetSystemRegistryView,
44
- } from "./registry.service";
33
+ } from "./registry/index";
45
34
  export {
46
- appendSystemRegistrySlots,
35
+ appendSystemRegistryEmptySlots,
47
36
  assertRegistrySlotAvailable,
48
37
  assertRegistrySlotOwner,
38
+ buildEmptyServiceSlots,
39
+ buildSystemRegistryConfigDetails,
40
+ claimServiceRegistrySlot,
41
+ createClaimedRegistrySlotRuntimeState,
42
+ DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS,
43
+ EMPTY_REGISTRY_SLOT_RUNTIME_STATE,
49
44
  getTargetSystemRegistry,
50
45
  parseServiceSlot,
51
46
  parseServiceSlots,
52
47
  patchServiceRuntime,
48
+ postSystemRegistryConfig,
49
+ postSystemRegistryConfigSchema,
53
50
  registerService,
54
51
  registerServiceAtStartup,
52
+ registrySlotRuntimePatchFromGuardResult,
55
53
  releaseSystemRegistrySlots,
56
54
  releaseSystemRegistrySlotsByServiceId,
55
+ resetSystemRegistryConfig,
56
+ resetSystemRegistryConfigSchema,
57
57
  resolveActiveRegistryServiceId,
58
+ runRegistrySlotGuardCheck,
58
59
  ServiceRegistryError,
60
+ ServiceSlotStatus,
61
+ systemRegistrySeedSlotSchema,
62
+ TARGET_SYSTEM_REGISTRY_KEY,
59
63
  unregisterService,
60
64
  unregisterServiceAtShutdown,
61
- } from "./registry.service";
62
- export type {
63
- ClaimRegistrySlotInput,
64
- RegistrySlotGuardResult,
65
- RegistrySlotRuntimeState,
66
- ServiceRegistrySession,
67
- } from "./registry-lifecycle";
68
- export {
69
- claimServiceRegistrySlot,
70
- createClaimedRegistrySlotRuntimeState,
71
- EMPTY_REGISTRY_SLOT_RUNTIME_STATE,
72
- registrySlotRuntimePatchFromGuardResult,
73
- runRegistrySlotGuardCheck,
74
- } from "./registry-lifecycle";
65
+ } from "./registry/index";
75
66
  export type { GetApiPayload, GetServicePayload, PostApiPayload, PostServicePayload } from "./service.api";
76
67
  export {
77
68
  apiDetailsSchema,
@@ -97,9 +88,8 @@ export type {
97
88
  ServiceDetails,
98
89
  ServiceNodeSnapshot,
99
90
  ServiceRuntime,
100
- ServiceSlot,
101
91
  } from "./service.interface";
102
- export { ApiMethod, CategoryApi, CategoryService, ServiceSlotStatus } from "./service.interface";
92
+ export { ApiMethod, CategoryApi, CategoryService } from "./service.interface";
103
93
  export type { PostServiceInstanceOptions, ServiceBootstrapResult } from "./service-bootstrap";
104
94
  export {
105
95
  createActiveServiceLifecycle,
@@ -0,0 +1,65 @@
1
+ /**
2
+ * System service registry — curated re-exports only.
3
+ * Generic Config CRUD lives in `src/config/`.
4
+ */
5
+
6
+ export type {
7
+ PostSystemRegistryConfigPayload,
8
+ ResetSystemRegistryConfigPayload,
9
+ SystemRegistrySeedSlot,
10
+ } from "./registry.api";
11
+ export {
12
+ buildEmptyServiceSlots,
13
+ buildSystemRegistryConfigDetails,
14
+ postSystemRegistryConfig,
15
+ postSystemRegistryConfigSchema,
16
+ resetSystemRegistryConfig,
17
+ resetSystemRegistryConfigSchema,
18
+ systemRegistrySeedSlotSchema,
19
+ } from "./registry.api";
20
+ export { DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS, TARGET_SYSTEM_REGISTRY_KEY } from "./registry.constant";
21
+ export type { ServiceSlot } from "./registry.interface";
22
+ export { ServiceSlotStatus } from "./registry.interface";
23
+ export type {
24
+ AppendSystemRegistryEmptySlotsInput,
25
+ AppendSystemRegistryEmptySlotsOutcome,
26
+ PatchServiceRuntimeInput,
27
+ RegisterServiceInput,
28
+ ReleasedRegistrySlot,
29
+ ReleaseSystemRegistrySlotsByServiceIdInput,
30
+ ReleaseSystemRegistrySlotsByServiceIdOutcome,
31
+ ReleaseSystemRegistrySlotsInput,
32
+ ReleaseSystemRegistrySlotsOutcome,
33
+ TargetSystemRegistrySlotView,
34
+ TargetSystemRegistryView,
35
+ } from "./registry.service";
36
+ export {
37
+ appendSystemRegistryEmptySlots,
38
+ assertRegistrySlotAvailable,
39
+ assertRegistrySlotOwner,
40
+ getTargetSystemRegistry,
41
+ parseServiceSlot,
42
+ parseServiceSlots,
43
+ patchServiceRuntime,
44
+ registerService,
45
+ registerServiceAtStartup,
46
+ releaseSystemRegistrySlots,
47
+ releaseSystemRegistrySlotsByServiceId,
48
+ resolveActiveRegistryServiceId,
49
+ ServiceRegistryError,
50
+ unregisterService,
51
+ unregisterServiceAtShutdown,
52
+ } from "./registry.service";
53
+ export type {
54
+ ClaimRegistrySlotInput,
55
+ RegistrySlotGuardResult,
56
+ RegistrySlotRuntimeState,
57
+ ServiceRegistrySession,
58
+ } from "./registry-lifecycle";
59
+ export {
60
+ claimServiceRegistrySlot,
61
+ createClaimedRegistrySlotRuntimeState,
62
+ EMPTY_REGISTRY_SLOT_RUNTIME_STATE,
63
+ registrySlotRuntimePatchFromGuardResult,
64
+ runRegistrySlotGuardCheck,
65
+ } from "./registry-lifecycle";
@@ -1,5 +1,6 @@
1
- import { deleteTarget } from "../core.api";
2
- import { createLogger } from "../shared/log";
1
+ import { deleteTarget } from "../../core.api";
2
+ import { createLogger } from "../../shared/log";
3
+ import type { Service } from "../service.interface";
3
4
  import {
4
5
  assertRegistrySlotAvailable,
5
6
  assertRegistrySlotOwner,
@@ -7,7 +8,6 @@ import {
7
8
  ServiceRegistryError,
8
9
  unregisterServiceAtShutdown,
9
10
  } from "./registry.service";
10
- import type { Service } from "./service.interface";
11
11
 
12
12
  const LOG_TOPIC = "service-registry-lifecycle";
13
13
 
@@ -1,34 +1,16 @@
1
1
  import { z } from "zod";
2
+ import { getConfig } from "../../config/config.api";
3
+ import { CategoryConfig, type Config, type ConfigDetails } from "../../config/config.interface";
2
4
  import {
3
5
  createTarget,
4
- getPossibleTarget,
5
- getTarget,
6
6
  isOptimisticLockError,
7
7
  type QueryFilter,
8
8
  updateTargetDetails,
9
9
  validateWithSchema,
10
- } from "../core.api";
11
- import { generateResponse } from "../core.interface";
12
- import { CategoryConfig, type Config, type ConfigDetails, TARGET_SYSTEM_REGISTRY_KEY } from "./config.interface";
13
- import { type ServiceSlot, ServiceSlotStatus } from "./service.interface";
14
-
15
- const targetIdSchema = z.string().trim().min(1);
16
-
17
- export const getConfigSchema = z
18
- .object({
19
- id: targetIdSchema.optional(),
20
- value: z.string().trim().min(1).optional(),
21
- })
22
- .refine(
23
- (payload) => {
24
- const hasId = payload.id != null && payload.id !== "";
25
- const hasValue = payload.value != null && payload.value !== "";
26
- return hasId !== hasValue;
27
- },
28
- { message: "Provide exactly one of id or value" },
29
- );
30
-
31
- export type GetConfigPayload = z.infer<typeof getConfigSchema>;
10
+ } from "../../core.api";
11
+ import { generateResponse } from "../../core.interface";
12
+ import { DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS, TARGET_SYSTEM_REGISTRY_KEY } from "./registry.constant";
13
+ import { type ServiceSlot, ServiceSlotStatus } from "./registry.interface";
32
14
 
33
15
  /** One declarative EMPTY slot entry for seeding the system registry. */
34
16
  export const systemRegistrySeedSlotSchema = z.object({
@@ -53,33 +35,12 @@ export type ResetSystemRegistryConfigPayload = PostSystemRegistryConfigPayload;
53
35
  const DEFAULT_RESET_RETRY_ATTEMPTS = 5;
54
36
  const RESET_RETRY_DELAY_MS = 50;
55
37
 
56
- /** Default one EMPTY slot per known L3 service (override via payload or seed file). */
57
- export const DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS: readonly SystemRegistrySeedSlot[] = [
58
- { serviceValue: "log-service" },
59
- { serviceValue: "watch-service" },
60
- { serviceValue: "download-service" },
61
- { serviceValue: "storage-service" },
62
- { serviceValue: "gc-service" },
63
- { serviceValue: "upload-service" },
64
- { serviceValue: "cv-service" },
65
- ] as const;
66
-
67
38
  const configCategoryFilter: QueryFilter = {
68
39
  field: "category",
69
40
  operator: "eq",
70
41
  value: CategoryConfig.CONFIG,
71
42
  };
72
43
 
73
- function buildConfigLookupFilters(payload: GetConfigPayload): QueryFilter[] {
74
- const filters: QueryFilter[] = [configCategoryFilter];
75
-
76
- if (payload.id == null || payload.id === "") {
77
- filters.push({ field: "value", operator: "eq", value: payload.value! });
78
- }
79
-
80
- return filters;
81
- }
82
-
83
44
  /** Build EMPTY {@link ServiceSlot} rows from seed entries (one slot per array item). */
84
45
  export function buildEmptyServiceSlots(seedSlots: readonly SystemRegistrySeedSlot[]): ServiceSlot[] {
85
46
  return seedSlots.map(({ serviceValue }) => ({
@@ -113,41 +74,6 @@ export function buildSystemRegistryConfigDetails(slots: readonly ServiceSlot[]):
113
74
  };
114
75
  }
115
76
 
116
- /** Fetch a Config by id or by {@link Config.value} key (`category=config`). */
117
- export const getConfig = validateWithSchema(
118
- getConfigSchema,
119
- "getConfigSchema",
120
- )(async (payload) => {
121
- const filterList = buildConfigLookupFilters(payload);
122
-
123
- if (payload.id != null && payload.id !== "") {
124
- const result = await getTarget({
125
- id: payload.id,
126
- filterList,
127
- });
128
- return {
129
- ...result,
130
- data: result.data as Config,
131
- };
132
- }
133
-
134
- const result = await getPossibleTarget({
135
- filterList,
136
- });
137
-
138
- if (result.data == null) {
139
- return {
140
- ...result,
141
- data: undefined,
142
- };
143
- }
144
-
145
- return {
146
- ...result,
147
- data: result.data as Config,
148
- };
149
- });
150
-
151
77
  /**
152
78
  * Insert the globally unique system registry Config (`category=config`,
153
79
  * `value=target-system-registry`). Rejects duplicates via `checkRedundancyFilterList`.
@@ -0,0 +1,17 @@
1
+ /** Globally unique Config key for the declarative system service registry. */
2
+ export const TARGET_SYSTEM_REGISTRY_KEY = "target-system-registry";
3
+
4
+ /**
5
+ * Default one EMPTY slot per known L3 service.
6
+ * Override via `postSystemRegistryConfig` / `resetSystemRegistryConfig` payload or gc-service seed file.
7
+ * Replica count = how many times the same `serviceValue` appears (not a separate maxInstances field).
8
+ */
9
+ export const DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS = [
10
+ { serviceValue: "log-service" },
11
+ { serviceValue: "watch-service" },
12
+ { serviceValue: "download-service" },
13
+ { serviceValue: "storage-service" },
14
+ { serviceValue: "gc-service" },
15
+ { serviceValue: "upload-service" },
16
+ { serviceValue: "cv-service" },
17
+ ] as const;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Capacity slots on the system registry Config (`details.objects`).
3
+ * Not fields on a Service Target row — see {@link Service} in `service.interface.ts`.
4
+ */
5
+
6
+ export enum ServiceSlotStatus {
7
+ EMPTY = "EMPTY",
8
+ ACTIVE = "ACTIVE",
9
+ }
10
+
11
+ export interface ServiceSlot {
12
+ serviceValue: string;
13
+ /** Bound Service.id when {@link ServiceSlotStatus.ACTIVE}; null when EMPTY. */
14
+ serviceId: string | null;
15
+ status: ServiceSlotStatus;
16
+ }