target-supabase-sdk 0.2.2 → 0.2.4
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/README.md +24 -18
- package/dist/browser.d.ts +11 -4
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +3 -3
- package/dist/chunks/{enable-log-persist-BH-tbKEj.js → enable-log-persist-B8rg_wXG.js} +41 -8
- package/dist/chunks/enable-log-persist-B8rg_wXG.js.map +1 -0
- package/dist/chunks/{create-logger-DyH3mZ8p.js → list.api-Ab9v8yOg.js} +66 -57
- package/dist/chunks/list.api-Ab9v8yOg.js.map +1 -0
- package/dist/chunks/{word.interface-DLgRobKV.js → word.interface-B_fbVFOW.js} +1078 -97
- package/dist/chunks/word.interface-B_fbVFOW.js.map +1 -0
- package/dist/extraction/extraction.api.d.ts +117 -0
- package/dist/extraction/extraction.api.d.ts.map +1 -0
- package/dist/extraction/extraction.interface.d.ts +43 -0
- package/dist/extraction/extraction.interface.d.ts.map +1 -0
- package/dist/list/list.interface.d.ts +2 -2
- package/dist/list/list.interface.d.ts.map +1 -1
- package/dist/node/env/index.d.ts +2 -2
- package/dist/node/env/index.d.ts.map +1 -1
- package/dist/node/env/init-supabase-from-env.d.ts +1 -1
- package/dist/node/env/init-supabase-from-env.d.ts.map +1 -1
- package/dist/node/env/load-env.d.ts +15 -1
- package/dist/node/env/load-env.d.ts.map +1 -1
- package/dist/node/node-runtime.base.d.ts +13 -1
- package/dist/node/node-runtime.base.d.ts.map +1 -1
- package/dist/node/preload/run-service-preload.d.ts +1 -1
- package/dist/node/preload/run-service-preload.d.ts.map +1 -1
- package/dist/node/process/create-managed-child-processes.d.ts +12 -0
- package/dist/node/process/create-managed-child-processes.d.ts.map +1 -0
- package/dist/node/process/index.d.ts +3 -1
- package/dist/node/process/index.d.ts.map +1 -1
- package/dist/node/process/managed-child-processes.d.ts +15 -2
- package/dist/node/process/managed-child-processes.d.ts.map +1 -1
- package/dist/node/runtime-state/create-service-runtime-state-store.d.ts +23 -0
- package/dist/node/runtime-state/create-service-runtime-state-store.d.ts.map +1 -0
- package/dist/node/runtime-state/index.d.ts +4 -0
- package/dist/node/runtime-state/index.d.ts.map +1 -0
- package/dist/node/runtime-state/service-runtime-state.types.d.ts +57 -0
- package/dist/node/runtime-state/service-runtime-state.types.d.ts.map +1 -0
- package/dist/node/service-guard/index.d.ts +9 -0
- package/dist/node/service-guard/index.d.ts.map +1 -0
- package/dist/node/service-guard/register-service-guard-runner.d.ts +9 -0
- package/dist/node/service-guard/register-service-guard-runner.d.ts.map +1 -0
- package/dist/node/service-guard/run-readiness-gate.d.ts +11 -0
- package/dist/node/service-guard/run-readiness-gate.d.ts.map +1 -0
- package/dist/node/service-guard/run-service-guard-tick.d.ts +7 -0
- package/dist/node/service-guard/run-service-guard-tick.d.ts.map +1 -0
- package/dist/node/service-guard/service-guard-node.d.ts +18 -0
- package/dist/node/service-guard/service-guard-node.d.ts.map +1 -0
- package/dist/node/service-guard/service-guard.interface.d.ts +58 -0
- package/dist/node/service-guard/service-guard.interface.d.ts.map +1 -0
- package/dist/node/service-guard/worker-spawn-cooldown.d.ts +4 -0
- package/dist/node/service-guard/worker-spawn-cooldown.d.ts.map +1 -0
- package/dist/node/service-host/index.d.ts +9 -0
- package/dist/node/service-host/index.d.ts.map +1 -0
- package/dist/node/service-host/registry-slot-guard-step.d.ts +21 -0
- package/dist/node/service-host/registry-slot-guard-step.d.ts.map +1 -0
- package/dist/node/service-host/service-host.d.ts +36 -0
- package/dist/node/service-host/service-host.d.ts.map +1 -0
- package/dist/node/service-host/single-process-service.d.ts +21 -0
- package/dist/node/service-host/single-process-service.d.ts.map +1 -0
- package/dist/node.d.ts +17 -4
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +2088 -1495
- package/dist/node.js.map +1 -1
- package/dist/preload.js +5 -4
- package/dist/preload.js.map +1 -1
- package/dist/service/config.api.d.ts +143 -0
- package/dist/service/config.api.d.ts.map +1 -0
- package/dist/service/config.interface.d.ts +22 -0
- package/dist/service/config.interface.d.ts.map +1 -0
- package/dist/service/index.d.ts +16 -17
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/registry-lifecycle.d.ts +43 -0
- package/dist/service/registry-lifecycle.d.ts.map +1 -0
- package/dist/service/registry.service.d.ts +94 -0
- package/dist/service/registry.service.d.ts.map +1 -0
- package/dist/service/service-bootstrap.d.ts +28 -0
- package/dist/service/service-bootstrap.d.ts.map +1 -0
- package/dist/service/service.api.d.ts +160 -0
- package/dist/service/service.api.d.ts.map +1 -1
- package/dist/service/service.interface.d.ts +32 -1
- package/dist/service/service.interface.d.ts.map +1 -1
- package/dist/shared/log/index.d.ts +4 -0
- package/dist/shared/log/index.d.ts.map +1 -1
- package/dist/shared/log/log-batch.d.ts +44 -0
- package/dist/shared/log/log-batch.d.ts.map +1 -0
- package/dist/shared/log/log-persist-coordinator.d.ts +37 -0
- package/dist/shared/log/log-persist-coordinator.d.ts.map +1 -0
- package/dist/shared/log/log-persist-flush.d.ts.map +1 -1
- package/dist/shared/log/log-persist.config.d.ts +0 -1
- package/dist/shared/log/log-persist.config.d.ts.map +1 -1
- package/dist/shared/log/log-persist.interface.d.ts +8 -0
- package/dist/shared/log/log-persist.interface.d.ts.map +1 -1
- package/dist/shared/utils/config-path.utils.d.ts +21 -0
- package/dist/shared/utils/config-path.utils.d.ts.map +1 -1
- package/dist/shared/utils/get-value-at-path.d.ts +3 -0
- package/dist/shared/utils/get-value-at-path.d.ts.map +1 -0
- package/dist/task/index.d.ts +2 -0
- package/dist/task/index.d.ts.map +1 -1
- package/dist/task/task-manager.d.ts +1 -1
- package/dist/task/task-manager.d.ts.map +1 -1
- package/dist/task/task-post-retry.api.d.ts +24 -0
- package/dist/task/task-post-retry.api.d.ts.map +1 -0
- package/dist/task/task-repo-context.d.ts +7 -1
- package/dist/task/task-repo-context.d.ts.map +1 -1
- package/dist/trigger/trigger-manager.d.ts +1 -1
- package/dist/trigger/trigger-manager.d.ts.map +1 -1
- package/dist/trigger/trigger-node.d.ts +1 -0
- package/dist/trigger/trigger-node.d.ts.map +1 -1
- package/dist/trigger/trigger.constant.d.ts +1 -1
- package/dist/trigger/trigger.constant.d.ts.map +1 -1
- package/dist/trigger/trigger.interface.d.ts +10 -0
- package/dist/trigger/trigger.interface.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/browser.ts +98 -4
- package/src/extraction/extraction.api.ts +232 -0
- package/src/extraction/extraction.interface.ts +45 -0
- package/src/list/list.interface.ts +2 -2
- package/src/node/env/index.ts +13 -2
- package/src/node/env/init-supabase-from-env.ts +1 -1
- package/src/node/env/load-env.ts +48 -2
- package/src/node/node-runtime.base.ts +37 -6
- package/src/node/preload/run-service-preload.ts +3 -2
- package/src/node/process/create-managed-child-processes.ts +27 -0
- package/src/node/process/index.ts +4 -0
- package/src/node/process/managed-child-processes.ts +48 -15
- package/src/node/runtime-state/create-service-runtime-state-store.ts +125 -0
- package/src/node/runtime-state/index.ts +17 -0
- package/src/node/runtime-state/service-runtime-state.types.ts +64 -0
- package/src/node/service-guard/index.ts +17 -0
- package/src/node/service-guard/register-service-guard-runner.ts +64 -0
- package/src/node/service-guard/run-readiness-gate.ts +34 -0
- package/src/node/service-guard/run-service-guard-tick.ts +106 -0
- package/src/node/service-guard/service-guard-node.ts +52 -0
- package/src/node/service-guard/service-guard.interface.ts +64 -0
- package/src/node/service-guard/worker-spawn-cooldown.ts +13 -0
- package/src/node/service-host/index.ts +30 -0
- package/src/node/service-host/registry-slot-guard-step.ts +57 -0
- package/src/node/service-host/service-host.ts +168 -0
- package/src/node/service-host/single-process-service.ts +58 -0
- package/src/node.ts +76 -0
- package/src/service/config.api.ts +224 -0
- package/src/service/config.interface.ts +25 -0
- package/src/service/index.ts +74 -149
- package/src/service/registry-lifecycle.ts +144 -0
- package/src/service/registry.service.ts +564 -0
- package/src/service/service-bootstrap.ts +74 -0
- package/src/service/service.api.ts +13 -0
- package/src/service/service.interface.ts +36 -1
- package/src/shared/log/index.ts +13 -0
- package/src/shared/log/log-batch.ts +156 -0
- package/src/shared/log/log-persist-coordinator.ts +107 -0
- package/src/shared/log/log-persist-flush.ts +3 -3
- package/src/shared/log/log-persist.config.ts +0 -2
- package/src/shared/log/log-persist.interface.ts +10 -0
- package/src/shared/utils/config-path.utils.ts +35 -0
- package/src/shared/utils/get-value-at-path.ts +17 -0
- package/src/task/index.ts +2 -0
- package/src/task/task-manager.ts +10 -4
- package/src/task/task-post-retry.api.ts +61 -0
- package/src/task/task-repo-context.ts +8 -1
- package/src/trigger/trigger-manager.ts +4 -2
- package/src/trigger/trigger-node.ts +10 -4
- package/src/trigger/trigger.constant.ts +1 -1
- package/src/trigger/trigger.interface.ts +10 -0
- package/dist/chunks/create-logger-DyH3mZ8p.js.map +0 -1
- package/dist/chunks/enable-log-persist-BH-tbKEj.js.map +0 -1
- package/dist/chunks/word.interface-DLgRobKV.js.map +0 -1
|
@@ -12,6 +12,7 @@ import type { TriggerNodeOptions } from "./trigger.interface";
|
|
|
12
12
|
*/
|
|
13
13
|
declare class TriggerNode extends BaseNodeRuntime {
|
|
14
14
|
private readonly requireRunners;
|
|
15
|
+
private readonly loopIntervalMs;
|
|
15
16
|
constructor(options?: TriggerNodeOptions);
|
|
16
17
|
protected getLoopIntervalMs(): number;
|
|
17
18
|
protected loopLoggerMinLevel(): LogLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-node.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EAA6B,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D;;;;;;;;GAQG;AACH,cAAM,WAAY,SAAQ,eAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;
|
|
1
|
+
{"version":3,"file":"trigger-node.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EAA6B,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG9D;;;;;;;;GAQG;AACH,cAAM,WAAY,SAAQ,eAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAU;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAE5B,OAAO,CAAC,EAAE,kBAAkB;IAUxC,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAIrC,SAAS,CAAC,kBAAkB,IAAI,QAAQ;cAIxB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;cA+B5D,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAc1F;AAED,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const LOG_TOPIC_TRIGGER = "trigger";
|
|
2
|
-
/**
|
|
2
|
+
/** Default main-loop interval for {@link TriggerNode} when `loopIntervalMs` is omitted (ms). */
|
|
3
3
|
export declare const TRIGGER_LOOP_INTERVAL_MS = 60000;
|
|
4
4
|
/** Default extra retries after first failure within one runner tick. */
|
|
5
5
|
export declare const TRIGGER_RUNNER_DEFAULT_RETRY_COUNT = 3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.constant.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"trigger.constant.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger.constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C,wEAAwE;AACxE,eAAO,MAAM,kCAAkC,IAAI,CAAC;AAEpD,sEAAsE;AACtE,eAAO,MAAM,qCAAqC,IAAI,CAAC"}
|
|
@@ -83,5 +83,15 @@ export interface TriggerNodeOptions {
|
|
|
83
83
|
* Default `false` (warn and idle loop).
|
|
84
84
|
*/
|
|
85
85
|
requireRunners?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Main loop tick interval (ms). Runners are evaluated each tick; effective runner
|
|
88
|
+
* precision is bounded by this value. Default {@link TRIGGER_LOOP_INTERVAL_MS} (60s).
|
|
89
|
+
*/
|
|
90
|
+
loopIntervalMs?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Called after node logout, immediately before `process.exit`.
|
|
93
|
+
* Typical use: {@link unregisterServiceAtShutdown} for single-process L3 services.
|
|
94
|
+
*/
|
|
95
|
+
beforeProcessExit?: () => void | Promise<void>;
|
|
86
96
|
}
|
|
87
97
|
//# sourceMappingURL=trigger.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.interface.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,eAAe;IACvB,OAAO,YAAY;CACtB;AAED,oBAAY,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,MAAM,WAAW;CACpB;AAED,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAElD,MAAM,WAAW,OAAQ,SAAQ,MAAM;IACnC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAID,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAElF,MAAM,WAAW,4BAA4B;IACzC,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"trigger.interface.d.ts","sourceRoot":"","sources":["../../src/trigger/trigger.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,oBAAY,eAAe;IACvB,OAAO,YAAY;CACtB;AAED,oBAAY,aAAa;IACrB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,MAAM,WAAW;CACpB;AAED,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAElD,MAAM,WAAW,OAAQ,SAAQ,MAAM;IACnC,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,wFAAwF;IACxF,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAID,gDAAgD;AAChD,MAAM,WAAW,oBAAoB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAElF,MAAM,WAAW,4BAA4B;IACzC,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,eAAe,CAAC;IACpB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAC/B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "target-supabase-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Supabase client initializer and data access APIs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "KyLoc20",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
],
|
|
48
48
|
"scripts": {
|
|
49
49
|
"clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true })\"",
|
|
50
|
-
"build": "pnpm clean && rollup -c && tsc -p tsconfig.dts.json && node scripts/verify-browser-entry.mjs",
|
|
50
|
+
"build": "pnpm clean && rollup -c && node --input-type=module -e \"console.log('[build] emitting declarations (tsc)...')\" && tsc -p tsconfig.dts.json && node scripts/verify-browser-entry.mjs",
|
|
51
51
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
52
52
|
"typecheck:scripts": "tsc -p tsconfig.scripts.json",
|
|
53
53
|
"format": "biome check --write .",
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
"worker:trigger": "tsx scripts/run-trigger-node.ts",
|
|
57
57
|
"post-command": "tsx scripts/post-command.ts",
|
|
58
58
|
"post-trigger": "tsx scripts/post-trigger.ts",
|
|
59
|
+
"seed:system-registry": "tsx scripts/seed-system-registry.ts",
|
|
60
|
+
"reset:system-registry": "tsx scripts/reset-system-registry.ts",
|
|
59
61
|
"parcel:split": "tsx scripts/parcel-split-local.ts",
|
|
60
62
|
"parcel:restore": "tsx scripts/parcel-restore-local.ts",
|
|
61
63
|
"dev": "rollup -c --watch",
|
package/src/browser.ts
CHANGED
|
@@ -9,6 +9,24 @@ export type { SupabaseClient } from "@supabase/supabase-js";
|
|
|
9
9
|
export * from "./core.api";
|
|
10
10
|
export * from "./core.interface";
|
|
11
11
|
export * from "./core.utils";
|
|
12
|
+
export type {
|
|
13
|
+
GetExtractionPayload,
|
|
14
|
+
PatchExtractionObjectsPayload,
|
|
15
|
+
PostExtractionPayload,
|
|
16
|
+
ScanExtractionListPayload,
|
|
17
|
+
} from "./extraction/extraction.api";
|
|
18
|
+
export {
|
|
19
|
+
getExtraction,
|
|
20
|
+
getExtractionSchema,
|
|
21
|
+
patchExtractionObjects,
|
|
22
|
+
patchExtractionObjectsSchema,
|
|
23
|
+
postExtraction,
|
|
24
|
+
postExtractionSchema,
|
|
25
|
+
scanExtractionList,
|
|
26
|
+
scanExtractionListSchema,
|
|
27
|
+
} from "./extraction/extraction.api";
|
|
28
|
+
export type { Extraction, ExtractionDetails } from "./extraction/extraction.interface";
|
|
29
|
+
export { CategoryExtraction } from "./extraction/extraction.interface";
|
|
12
30
|
export * from "./idea/idea.interface";
|
|
13
31
|
export * from "./link/link.api";
|
|
14
32
|
export * from "./link/link.interface";
|
|
@@ -86,32 +104,84 @@ export * from "./repo/repo.interface";
|
|
|
86
104
|
export type {
|
|
87
105
|
Api,
|
|
88
106
|
ApiDetails,
|
|
89
|
-
|
|
107
|
+
ClaimRegistrySlotInput,
|
|
108
|
+
Config,
|
|
109
|
+
ConfigDetails,
|
|
90
110
|
GetApiPayload,
|
|
111
|
+
GetConfigPayload,
|
|
91
112
|
GetServicePayload,
|
|
113
|
+
PatchServiceRuntimeInput,
|
|
92
114
|
PostApiPayload,
|
|
115
|
+
PostServiceInstanceOptions,
|
|
93
116
|
PostServicePayload,
|
|
117
|
+
PostSystemRegistryConfigPayload,
|
|
118
|
+
RegisterServiceInput,
|
|
119
|
+
RegistrySlotGuardResult,
|
|
120
|
+
RegistrySlotRuntimeState,
|
|
121
|
+
ResetSystemRegistryConfigPayload,
|
|
94
122
|
Service,
|
|
123
|
+
ServiceBootstrapResult,
|
|
95
124
|
ServiceDetails,
|
|
125
|
+
ServiceNodeSnapshot,
|
|
126
|
+
ServiceRegistrySession,
|
|
127
|
+
ServiceRuntime,
|
|
128
|
+
ServiceSlot,
|
|
129
|
+
SystemRegistrySeedSlot,
|
|
130
|
+
TargetSystemRegistrySlotView,
|
|
131
|
+
TargetSystemRegistryView,
|
|
96
132
|
} from "./service/index";
|
|
97
133
|
export {
|
|
98
134
|
ApiMethod,
|
|
99
135
|
apiDetailsSchema,
|
|
136
|
+
assertRegistrySlotAvailable,
|
|
137
|
+
assertRegistrySlotOwner,
|
|
138
|
+
buildEmptyServiceSlots,
|
|
139
|
+
buildSystemRegistryConfigDetails,
|
|
140
|
+
CategoryConfig,
|
|
100
141
|
CategoryService,
|
|
101
|
-
|
|
142
|
+
claimServiceRegistrySlot,
|
|
143
|
+
createActiveServiceLifecycle,
|
|
144
|
+
createClaimedRegistrySlotRuntimeState,
|
|
145
|
+
DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS,
|
|
146
|
+
defaultL3ServiceDetails,
|
|
147
|
+
EMPTY_REGISTRY_SLOT_RUNTIME_STATE,
|
|
102
148
|
fieldDefinitionSchema,
|
|
103
149
|
getApi,
|
|
104
150
|
getApiSchema,
|
|
151
|
+
getConfig,
|
|
152
|
+
getConfigSchema,
|
|
105
153
|
getService,
|
|
106
154
|
getServiceSchema,
|
|
155
|
+
getTargetSystemRegistry,
|
|
156
|
+
parseServiceSlot,
|
|
157
|
+
parseServiceSlots,
|
|
158
|
+
patchServiceRuntime,
|
|
107
159
|
postApi,
|
|
108
160
|
postApiSchema,
|
|
109
161
|
postService,
|
|
162
|
+
postServiceInstance,
|
|
110
163
|
postServiceSchema,
|
|
164
|
+
postSystemRegistryConfig,
|
|
165
|
+
postSystemRegistryConfigSchema,
|
|
166
|
+
registerService,
|
|
167
|
+
registerServiceAtStartup,
|
|
168
|
+
registrySlotRuntimePatchFromGuardResult,
|
|
169
|
+
resetSystemRegistryConfig,
|
|
170
|
+
resetSystemRegistryConfigSchema,
|
|
171
|
+
resolveActiveRegistryServiceId,
|
|
172
|
+
runRegistrySlotGuardCheck,
|
|
111
173
|
ServiceLifecycleStatus,
|
|
174
|
+
ServiceRegistryError,
|
|
175
|
+
ServiceSlotStatus,
|
|
112
176
|
schemaDefinitionSchema,
|
|
113
177
|
serviceDetailsSchema,
|
|
114
178
|
serviceLifecycleSchema,
|
|
179
|
+
serviceNodeSnapshotSchema,
|
|
180
|
+
serviceRuntimeSchema,
|
|
181
|
+
systemRegistrySeedSlotSchema,
|
|
182
|
+
TARGET_SYSTEM_REGISTRY_KEY,
|
|
183
|
+
unregisterService,
|
|
184
|
+
unregisterServiceAtShutdown,
|
|
115
185
|
} from "./service/index";
|
|
116
186
|
export type { FetchInitFactory, FetchRetryOptions } from "./shared/http/fetch-retry";
|
|
117
187
|
export {
|
|
@@ -120,9 +190,31 @@ export {
|
|
|
120
190
|
isRetryableHttpStatus,
|
|
121
191
|
requestHasBody,
|
|
122
192
|
} from "./shared/http/fetch-retry";
|
|
123
|
-
export type {
|
|
124
|
-
|
|
193
|
+
export type {
|
|
194
|
+
CreateLoggerInput,
|
|
195
|
+
DecodedLogBatch,
|
|
196
|
+
FlatLogEntry,
|
|
197
|
+
LogEntry,
|
|
198
|
+
LoggerWithScope,
|
|
199
|
+
LogScope,
|
|
200
|
+
LogScopePatch,
|
|
201
|
+
} from "./shared/log";
|
|
202
|
+
export {
|
|
203
|
+
createLogger,
|
|
204
|
+
decodeLogBatch,
|
|
205
|
+
decodeLogBatchList,
|
|
206
|
+
flattenLogBatch,
|
|
207
|
+
flattenLogBatches,
|
|
208
|
+
isLogBatchList,
|
|
209
|
+
isLogEntry,
|
|
210
|
+
LOG_BATCH_LOADER_KEY,
|
|
211
|
+
LOG_PERSIST_LOADER_KEY,
|
|
212
|
+
LogLevel,
|
|
213
|
+
logManager,
|
|
214
|
+
parseLogBatchMeta,
|
|
215
|
+
} from "./shared/log";
|
|
125
216
|
export { isHttpUrl, resolveFetchUrl } from "./shared/utils/fetch-url";
|
|
217
|
+
export { getValueAtPath } from "./shared/utils/get-value-at-path";
|
|
126
218
|
export type {
|
|
127
219
|
ClassifiedNetworkError,
|
|
128
220
|
FormatNetworkErrorOptions,
|
|
@@ -160,6 +252,8 @@ export {
|
|
|
160
252
|
} from "./task/task.interface";
|
|
161
253
|
export type { PostTaskPayload } from "./task/task-post.api";
|
|
162
254
|
export { postTask, postTaskSchema } from "./task/task-post.api";
|
|
255
|
+
export type { PostTaskWithRetryOptions, PostTaskWithRetryResult } from "./task/task-post-retry.api";
|
|
256
|
+
export { POST_TASK_DEFAULT_MAX_ATTEMPTS, postTaskWithRetry } from "./task/task-post-retry.api";
|
|
163
257
|
export type { TaskStatusCount } from "./task/task-queue";
|
|
164
258
|
export { countTasksByType, summarizeTaskQueue } from "./task/task-queue";
|
|
165
259
|
export * from "./word/word.interface";
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
createTarget,
|
|
4
|
+
getPossibleTarget,
|
|
5
|
+
getTarget,
|
|
6
|
+
isCreateTargetAlreadyExistsError,
|
|
7
|
+
type QueryFilter,
|
|
8
|
+
scanTargetList,
|
|
9
|
+
updateTargetDetails,
|
|
10
|
+
validateWithSchema,
|
|
11
|
+
} from "../core.api";
|
|
12
|
+
import type { SupabaseResponse } from "../core.interface";
|
|
13
|
+
import { generateResponse } from "../core.interface";
|
|
14
|
+
import { createLogger } from "../shared/log";
|
|
15
|
+
import { CategoryExtraction, type Extraction, type ExtractionDetails } from "./extraction.interface";
|
|
16
|
+
|
|
17
|
+
const targetIdSchema = z.string().trim().min(1);
|
|
18
|
+
const loaderKeySchema = z.string().trim().min(1);
|
|
19
|
+
|
|
20
|
+
export const postExtractionSchema = z.object({
|
|
21
|
+
name: z.string().trim().min(1),
|
|
22
|
+
/** Source Target id — for log analysis this is the producing Task id. */
|
|
23
|
+
sourceId: targetIdSchema,
|
|
24
|
+
loaderKey: loaderKeySchema,
|
|
25
|
+
meta: z.unknown().optional(),
|
|
26
|
+
objects: z.array(z.unknown()).min(1),
|
|
27
|
+
tagList: z.array(z.string()).optional().default([]),
|
|
28
|
+
extra: z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type PostExtractionPayload = z.infer<typeof postExtractionSchema>;
|
|
32
|
+
|
|
33
|
+
export const getExtractionSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
id: targetIdSchema.optional(),
|
|
36
|
+
sourceId: targetIdSchema.optional(),
|
|
37
|
+
loaderKey: loaderKeySchema.optional(),
|
|
38
|
+
})
|
|
39
|
+
.refine(
|
|
40
|
+
(payload) => {
|
|
41
|
+
const hasId = payload.id != null && payload.id !== "";
|
|
42
|
+
const hasSource = payload.sourceId != null && payload.sourceId !== "";
|
|
43
|
+
if (hasId) {
|
|
44
|
+
return !hasSource;
|
|
45
|
+
}
|
|
46
|
+
return hasSource && payload.loaderKey != null && payload.loaderKey !== "";
|
|
47
|
+
},
|
|
48
|
+
{ message: "Provide id, or both sourceId and loaderKey" },
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
export type GetExtractionPayload = z.infer<typeof getExtractionSchema>;
|
|
52
|
+
|
|
53
|
+
export const scanExtractionListSchema = z.object({
|
|
54
|
+
loaderKey: loaderKeySchema.optional(),
|
|
55
|
+
sourceId: targetIdSchema.optional(),
|
|
56
|
+
maxRows: z.number().int().min(1).max(500).optional(),
|
|
57
|
+
ascending: z.boolean().optional(),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export type ScanExtractionListPayload = z.infer<typeof scanExtractionListSchema>;
|
|
61
|
+
|
|
62
|
+
export const patchExtractionObjectsSchema = z.object({
|
|
63
|
+
id: targetIdSchema,
|
|
64
|
+
objects: z.array(z.unknown()).min(1),
|
|
65
|
+
meta: z.unknown().optional(),
|
|
66
|
+
expectedRevision: z.number().int().min(0).optional(),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export type PatchExtractionObjectsPayload = z.infer<typeof patchExtractionObjectsSchema>;
|
|
70
|
+
|
|
71
|
+
const extractionCategoryFilter: QueryFilter = {
|
|
72
|
+
field: "category",
|
|
73
|
+
operator: "eq",
|
|
74
|
+
value: CategoryExtraction.EXTRACTION,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function extractionRedundancyFilters(sourceId: string, loaderKey: string): QueryFilter[] {
|
|
78
|
+
return [
|
|
79
|
+
extractionCategoryFilter,
|
|
80
|
+
{ field: "value", operator: "eq", value: sourceId },
|
|
81
|
+
{ field: "details->>loaderKey", operator: "eq", value: loaderKey },
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function normalizeExtractionMeta(meta: unknown, patch?: unknown): Record<string, unknown> {
|
|
86
|
+
const base =
|
|
87
|
+
meta != null && typeof meta === "object" && !Array.isArray(meta)
|
|
88
|
+
? { ...(meta as Record<string, unknown>) }
|
|
89
|
+
: {};
|
|
90
|
+
if (patch != null && typeof patch === "object" && !Array.isArray(patch)) {
|
|
91
|
+
Object.assign(base, patch as Record<string, unknown>);
|
|
92
|
+
}
|
|
93
|
+
const revision = typeof base.revision === "number" && Number.isInteger(base.revision) ? base.revision : 0;
|
|
94
|
+
base.revision = revision;
|
|
95
|
+
base.updatedAt = new Date().toISOString();
|
|
96
|
+
return base;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Create an Extraction row for `(sourceId, loaderKey)`. Idempotent on redundancy key. */
|
|
100
|
+
export const postExtraction = validateWithSchema(
|
|
101
|
+
postExtractionSchema,
|
|
102
|
+
"postExtractionSchema",
|
|
103
|
+
)(async (payload): Promise<SupabaseResponse<Extraction>> => {
|
|
104
|
+
const logger = createLogger({ module: "postExtraction" });
|
|
105
|
+
const meta = normalizeExtractionMeta(payload.meta, { revision: 0 });
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
return await createTarget<Extraction, PostExtractionPayload>({
|
|
109
|
+
payload,
|
|
110
|
+
checkRedundancyFilterList: extractionRedundancyFilters(payload.sourceId, payload.loaderKey),
|
|
111
|
+
createFn: () => ({
|
|
112
|
+
name: payload.name,
|
|
113
|
+
value: payload.sourceId,
|
|
114
|
+
category: CategoryExtraction.EXTRACTION,
|
|
115
|
+
tagList: payload.tagList,
|
|
116
|
+
extra: payload.extra,
|
|
117
|
+
details: {
|
|
118
|
+
manifestVersion: 0,
|
|
119
|
+
loaderKey: payload.loaderKey,
|
|
120
|
+
meta,
|
|
121
|
+
objects: payload.objects,
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (isCreateTargetAlreadyExistsError(error)) {
|
|
127
|
+
logger.warn("Extraction already exists for source + loaderKey", {
|
|
128
|
+
topic: "extraction",
|
|
129
|
+
data: { sourceId: payload.sourceId, loaderKey: payload.loaderKey },
|
|
130
|
+
});
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/** Fetch one Extraction by row id, or by `(sourceId, loaderKey)`. */
|
|
138
|
+
export const getExtraction = validateWithSchema(
|
|
139
|
+
getExtractionSchema,
|
|
140
|
+
"getExtractionSchema",
|
|
141
|
+
)(async (payload): Promise<SupabaseResponse<Extraction>> => {
|
|
142
|
+
if (payload.id != null && payload.id !== "") {
|
|
143
|
+
const result = await getTarget({
|
|
144
|
+
id: payload.id,
|
|
145
|
+
filterList: [extractionCategoryFilter],
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
...result,
|
|
149
|
+
data: result.data as Extraction | undefined,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const result = await getPossibleTarget({
|
|
154
|
+
filterList: extractionRedundancyFilters(payload.sourceId!, payload.loaderKey!),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (result.data == null) {
|
|
158
|
+
return generateResponse.error("Extraction not found", undefined, "NOT_FOUND") as SupabaseResponse<Extraction>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
...result,
|
|
163
|
+
data: result.data as Extraction,
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
/** Scan Extraction rows (newest first by default). */
|
|
168
|
+
export const scanExtractionList = validateWithSchema(
|
|
169
|
+
scanExtractionListSchema,
|
|
170
|
+
"scanExtractionListSchema",
|
|
171
|
+
)(async (payload) => {
|
|
172
|
+
const filterList: QueryFilter[] = [extractionCategoryFilter];
|
|
173
|
+
if (payload.loaderKey != null) {
|
|
174
|
+
filterList.push({ field: "details->>loaderKey", operator: "eq", value: payload.loaderKey });
|
|
175
|
+
}
|
|
176
|
+
if (payload.sourceId != null) {
|
|
177
|
+
filterList.push({ field: "value", operator: "eq", value: payload.sourceId });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return scanTargetList<Extraction>({
|
|
181
|
+
category: CategoryExtraction.EXTRACTION,
|
|
182
|
+
filterList,
|
|
183
|
+
maxRows: payload.maxRows ?? 100,
|
|
184
|
+
orderBy: { field: "created_at", ascending: payload.ascending ?? false },
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
/** Replace {@link ExtractionDetails.objects} and bump `meta.revision`. */
|
|
189
|
+
export const patchExtractionObjects = validateWithSchema(
|
|
190
|
+
patchExtractionObjectsSchema,
|
|
191
|
+
"patchExtractionObjectsSchema",
|
|
192
|
+
)(async (payload): Promise<SupabaseResponse<Extraction>> => {
|
|
193
|
+
const optimisticLockFilterList: QueryFilter[] = [];
|
|
194
|
+
if (payload.expectedRevision != null) {
|
|
195
|
+
optimisticLockFilterList.push({
|
|
196
|
+
field: "details->meta->>revision",
|
|
197
|
+
operator: "eq",
|
|
198
|
+
value: String(payload.expectedRevision),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const data = await updateTargetDetails<Extraction, ExtractionDetails>({
|
|
204
|
+
id: payload.id,
|
|
205
|
+
optimisticLockFilterList,
|
|
206
|
+
updateFn: (current) => {
|
|
207
|
+
const currentMeta =
|
|
208
|
+
current.meta != null && typeof current.meta === "object" && !Array.isArray(current.meta)
|
|
209
|
+
? (current.meta as Record<string, unknown>)
|
|
210
|
+
: {};
|
|
211
|
+
const revision =
|
|
212
|
+
typeof currentMeta.revision === "number" && Number.isInteger(currentMeta.revision)
|
|
213
|
+
? currentMeta.revision + 1
|
|
214
|
+
: 1;
|
|
215
|
+
return {
|
|
216
|
+
...current,
|
|
217
|
+
meta: normalizeExtractionMeta(current.meta, {
|
|
218
|
+
...(payload.meta != null && typeof payload.meta === "object" && !Array.isArray(payload.meta)
|
|
219
|
+
? payload.meta
|
|
220
|
+
: {}),
|
|
221
|
+
revision,
|
|
222
|
+
}),
|
|
223
|
+
objects: payload.objects,
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
return generateResponse.success(data as Extraction);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
230
|
+
return generateResponse.error(message, undefined, "PATCH_FAILED") as SupabaseResponse<Extraction>;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Target } from "../core.interface";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interpretation layer for a source Target: pipeline output (systems, models, algorithms)
|
|
5
|
+
* materialized as structured data. Not a process (see Task) or raw bytes (see Parcel).
|
|
6
|
+
*
|
|
7
|
+
* @see `.cursor/skills/extraction/SKILL.md`
|
|
8
|
+
*/
|
|
9
|
+
export interface Extraction extends Target {
|
|
10
|
+
/** Human-readable label. */
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Source Target id — the single input this row interprets (any category).
|
|
14
|
+
* Immutable after create. Indexed for lookup: all Extractions where `value = sourceId`.
|
|
15
|
+
* Not a dedup hash or pipeline run id.
|
|
16
|
+
*/
|
|
17
|
+
value: string;
|
|
18
|
+
category: CategoryExtraction;
|
|
19
|
+
details: ExtractionDetails;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum CategoryExtraction {
|
|
23
|
+
EXTRACTION = "extraction",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ExtractionDetails {
|
|
27
|
+
manifestVersion: 0;
|
|
28
|
+
/**
|
|
29
|
+
* Extractor identifier. Together with {@link Extraction.value} (source id) forms the
|
|
30
|
+
* logical unique key: one Extraction row per `(sourceTargetId, loaderKey)`.
|
|
31
|
+
* Determines how to parse and render {@link objects} (Extractor-owned schema).
|
|
32
|
+
*/
|
|
33
|
+
loaderKey: string;
|
|
34
|
+
/**
|
|
35
|
+
* Extractor-owned metadata for this interpretation (e.g. revision, updatedAt, pipeline).
|
|
36
|
+
* Updated alongside {@link objects}; kept `unknown` at SDK boundary — see Extractor module.
|
|
37
|
+
*/
|
|
38
|
+
meta: unknown;
|
|
39
|
+
/**
|
|
40
|
+
* Latest mutable analysis results for this source + Extractor — not an immutable snapshot.
|
|
41
|
+
* Shape is defined by the Extractor for {@link loaderKey}; SDK keeps `unknown[]` at core.
|
|
42
|
+
* Large payloads should reference Parcel (or similar) rather than inline in this array.
|
|
43
|
+
*/
|
|
44
|
+
objects: Array<unknown>;
|
|
45
|
+
}
|
|
@@ -13,8 +13,8 @@ export interface List extends Target {
|
|
|
13
13
|
|
|
14
14
|
export interface ListDetails {
|
|
15
15
|
manifestVersion: number;
|
|
16
|
-
/**
|
|
17
|
-
meta:
|
|
16
|
+
/** Optional list metadata (shape depends on `loaderKey`). */
|
|
17
|
+
meta: unknown;
|
|
18
18
|
/** If string, it is the url of the preview TODO */
|
|
19
19
|
preview: string;
|
|
20
20
|
/** How to render the List */
|
package/src/node/env/index.ts
CHANGED
|
@@ -2,8 +2,19 @@ export type { EnvIntOptions, EnvNumberOptions } from "./env-parsers";
|
|
|
2
2
|
export { envBool, envInt, envMs, envNumber, envPort } from "./env-parsers";
|
|
3
3
|
export type { InitSupabaseFromStandardEnvOptions } from "./init-supabase-from-env";
|
|
4
4
|
export { initSupabaseFromStandardEnv } from "./init-supabase-from-env";
|
|
5
|
-
export type { LoadEnvFilesOptions } from "./load-env";
|
|
6
|
-
export {
|
|
5
|
+
export type { EnvProfileFromProcessOptions, LoadEnvFilesOptions } from "./load-env";
|
|
6
|
+
export {
|
|
7
|
+
CLI_PROD_FLAG,
|
|
8
|
+
envProfileFromProcess,
|
|
9
|
+
loadEnvFiles,
|
|
10
|
+
parseEnvFile,
|
|
11
|
+
parseEnvFileContent,
|
|
12
|
+
parseEnvLine,
|
|
13
|
+
pinEnvProfileFromArgv,
|
|
14
|
+
resolveDefaultEnvFiles,
|
|
15
|
+
SERVICE_ENV_PROFILE_ENV_KEY,
|
|
16
|
+
SERVICE_ENV_PROFILE_PROD,
|
|
17
|
+
} from "./load-env";
|
|
7
18
|
export { resolveProjectRootByPackageName, resolveProjectRootFromModule } from "./project-root";
|
|
8
19
|
export type { PublicBaseUrlFromEnvOptions } from "./public-base-url";
|
|
9
20
|
export { publicBaseUrlFromEnv } from "./public-base-url";
|
|
@@ -5,7 +5,7 @@ import { readEnv, requireEnv } from "./require-env";
|
|
|
5
5
|
export interface InitSupabaseFromStandardEnvOptions {
|
|
6
6
|
/** Project root for `.env` files (required when `loadEnv` is true). */
|
|
7
7
|
root?: string;
|
|
8
|
-
/** Load
|
|
8
|
+
/** Load env files before initialize (default true). Uses `.env.prod` when profile is `prod`. */
|
|
9
9
|
loadEnv?: boolean;
|
|
10
10
|
/** Hook after env files loaded (legacy aliases, etc.). */
|
|
11
11
|
afterLoadEnv?: () => void;
|
package/src/node/env/load-env.ts
CHANGED
|
@@ -2,6 +2,51 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
|
|
4
4
|
const DEFAULT_ENV_FILES = [".env.local", ".env"] as const;
|
|
5
|
+
const PROD_ENV_FILES = [".env.prod"] as const;
|
|
6
|
+
|
|
7
|
+
export const SERVICE_ENV_PROFILE_ENV_KEY = "SERVICE_ENV_PROFILE" as const;
|
|
8
|
+
export const SERVICE_ENV_PROFILE_PROD = "prod" as const;
|
|
9
|
+
export const CLI_PROD_FLAG = "--prod" as const;
|
|
10
|
+
|
|
11
|
+
export interface EnvProfileFromProcessOptions {
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
argv?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Resolve active env profile from `SERVICE_ENV_PROFILE` or `--prod` on argv. */
|
|
17
|
+
export function envProfileFromProcess(options?: EnvProfileFromProcessOptions): string | undefined {
|
|
18
|
+
const env = options?.env ?? process.env;
|
|
19
|
+
const argv = options?.argv ?? process.argv;
|
|
20
|
+
const fromEnv = env[SERVICE_ENV_PROFILE_ENV_KEY]?.trim();
|
|
21
|
+
if (fromEnv != null && fromEnv !== "") {
|
|
22
|
+
return fromEnv;
|
|
23
|
+
}
|
|
24
|
+
if (argv.includes(CLI_PROD_FLAG)) {
|
|
25
|
+
return SERVICE_ENV_PROFILE_PROD;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Default env file list for a profile (`prod` → `.env.prod`; otherwise `.env.local` → `.env`). */
|
|
31
|
+
export function resolveDefaultEnvFiles(profile?: string): readonly string[] {
|
|
32
|
+
if (profile === SERVICE_ENV_PROFILE_PROD) {
|
|
33
|
+
return PROD_ENV_FILES;
|
|
34
|
+
}
|
|
35
|
+
return DEFAULT_ENV_FILES;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Pin `SERVICE_ENV_PROFILE=prod` when `--prod` is on argv (for child process inheritance). */
|
|
39
|
+
export function pinEnvProfileFromArgv(
|
|
40
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
41
|
+
argv: readonly string[] = process.argv,
|
|
42
|
+
): void {
|
|
43
|
+
if (env[SERVICE_ENV_PROFILE_ENV_KEY]?.trim()) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (argv.includes(CLI_PROD_FLAG)) {
|
|
47
|
+
env[SERVICE_ENV_PROFILE_ENV_KEY] = SERVICE_ENV_PROFILE_PROD;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
5
50
|
|
|
6
51
|
export interface LoadEnvFilesOptions {
|
|
7
52
|
/** Files to load in order (later files do not override existing env). */
|
|
@@ -52,12 +97,13 @@ export function parseEnvFile(filePath: string, env: NodeJS.ProcessEnv): void {
|
|
|
52
97
|
}
|
|
53
98
|
|
|
54
99
|
/**
|
|
55
|
-
* Load
|
|
100
|
+
* Load env files into `process.env` (or `options.env`).
|
|
101
|
+
* Default files: `.env.local` → `.env`, or `.env.prod` when profile is `prod` / `--prod`.
|
|
56
102
|
* Existing non-empty env values are not overwritten.
|
|
57
103
|
*/
|
|
58
104
|
export function loadEnvFiles(root: string, options?: LoadEnvFilesOptions): void {
|
|
59
105
|
const env = options?.env ?? process.env;
|
|
60
|
-
const files = options?.files ??
|
|
106
|
+
const files = options?.files ?? resolveDefaultEnvFiles(envProfileFromProcess({ env }));
|
|
61
107
|
|
|
62
108
|
for (const name of files) {
|
|
63
109
|
parseEnvFile(resolve(root, name), env);
|