@kici-dev/shared 0.1.12 → 0.1.14
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/dist/cold-store/chunk-encoder.js +1 -1
- package/dist/cold-store/chunk-id.js +1 -1
- package/dist/cold-store/cold-store.js +1 -1
- package/dist/db-admin.d.ts +10 -0
- package/dist/db-admin.js +4 -0
- package/dist/env/define-env.js +27 -6
- package/dist/env/logger-env.d.ts +1 -1
- package/dist/graceful-shutdown.js +1 -1
- package/dist/idempotency.d.ts +1 -67
- package/dist/idempotency.js +2 -48
- package/dist/index.d.ts +1 -7
- package/dist/index.js +2 -8
- package/dist/package-manager-types.d.ts +1 -21
- package/dist/package-manager-types.js +2 -34
- package/dist/package-manager.d.ts +1 -51
- package/dist/package-manager.js +2 -130
- package/dist/ts-loader-hook.d.ts +1 -25
- package/dist/ts-loader-hook.js +2 -47
- package/package.json +3 -2
- package/sbom.spdx.json +60 -5
- package/dist/crypto.d.ts +0 -33
- package/dist/crypto.js +0 -67
- package/dist/error.d.ts +0 -16
- package/dist/error.js +0 -58
- package/dist/error.test.d.ts +0 -2
- package/dist/format-bytes.d.ts +0 -5
- package/dist/format-bytes.js +0 -15
- package/dist/format-bytes.test.d.ts +0 -2
- package/dist/format-duration.d.ts +0 -11
- package/dist/format-duration.js +0 -32
- package/dist/format-duration.test.d.ts +0 -2
- package/dist/idempotency.test.d.ts +0 -2
- package/dist/logger.d.ts +0 -60
- package/dist/logger.js +0 -181
- package/dist/logger.test.d.ts +0 -2
- package/dist/package-manager.test.d.ts +0 -2
- package/dist/request-context.d.ts +0 -42
- package/dist/request-context.js +0 -37
- package/dist/zx.d.ts +0 -8
- package/dist/zx.js +0 -78
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "../chunk-gOLHoazu.js";
|
|
2
|
-
import { sha256 } from "../crypto.js";
|
|
3
2
|
import { createS3Client } from "../s3-client.js";
|
|
4
3
|
import { chunkObjectKey, encodeKeySegment, tablePrefix, tenantDayPrefix } from "./key.js";
|
|
5
4
|
import { coldDaysToBucket, isLongerColdRetention } from "./bucket.js";
|
|
@@ -7,6 +6,7 @@ import { computeChunkId } from "./chunk-id.js";
|
|
|
7
6
|
import { decodeChunk, encodeChunk } from "./chunk-encoder.js";
|
|
8
7
|
import { parseManifest, serializeManifest } from "./manifest.js";
|
|
9
8
|
import { coldStoreArchiveBytesTotal, coldStoreArchiveCyclesTotal, coldStoreArchiveDurationSeconds, coldStoreArchiveRowsTotal, coldStorePurgeBytesTotal, coldStorePurgeChunksTotal, coldStorePurgeDurationSeconds, coldStoreRehydrateBytesTotal, coldStoreRehydrateDurationSeconds, coldStoreRehydrateRequestsTotal, coldStoreReplayDurationSeconds, coldStoreReplayRowsTotal, coldStoreVerifyFailuresTotal } from "./metrics.js";
|
|
9
|
+
import { sha256 } from "@kici-dev/core";
|
|
10
10
|
import { DeleteObjectCommand, GetObjectCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand } from "@aws-sdk/client-s3";
|
|
11
11
|
//#region src/cold-store/cold-store.ts
|
|
12
12
|
/**
|
package/dist/db-admin.d.ts
CHANGED
|
@@ -60,6 +60,16 @@ export interface EnsureDatabaseOpts {
|
|
|
60
60
|
* grant is a no-op).
|
|
61
61
|
*/
|
|
62
62
|
revokeConnectFromPublic?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* After creating (or finding) the database — and after the optional
|
|
65
|
+
* `REVOKE CONNECT … FROM PUBLIC` — `GRANT CONNECT ON DATABASE "<name>"
|
|
66
|
+
* TO "<role>"` for each role here. Pairs with `revokeConnectFromPublic`
|
|
67
|
+
* to re-grant CONNECT to the specific non-PUBLIC roles that legitimately
|
|
68
|
+
* need it once the default PUBLIC grant is revoked. Idempotent (GRANT on
|
|
69
|
+
* an already-present grant is a no-op). Each name is validated as a SQL
|
|
70
|
+
* identifier before interpolation.
|
|
71
|
+
*/
|
|
72
|
+
grantConnectToRoles?: string[];
|
|
63
73
|
}
|
|
64
74
|
/**
|
|
65
75
|
* CREATE DATABASE IF NOT EXISTS (idempotent). With no `opts`, the URL's
|
package/dist/db-admin.js
CHANGED
|
@@ -111,6 +111,10 @@ async function ensureDatabase(databaseUrl, opts = {}) {
|
|
|
111
111
|
outcome = "created";
|
|
112
112
|
}
|
|
113
113
|
if (opts.revokeConnectFromPublic) await pool.query(`REVOKE CONNECT ON DATABASE "${dbName}" FROM PUBLIC`);
|
|
114
|
+
for (const role of opts.grantConnectToRoles ?? []) {
|
|
115
|
+
assertValidIdentifier(role, "grant-connect role");
|
|
116
|
+
await pool.query(`GRANT CONNECT ON DATABASE "${dbName}" TO "${role}"`);
|
|
117
|
+
}
|
|
114
118
|
return outcome;
|
|
115
119
|
});
|
|
116
120
|
}
|
package/dist/env/define-env.js
CHANGED
|
@@ -60,9 +60,11 @@ function extractDefault(field) {
|
|
|
60
60
|
const def = t.def;
|
|
61
61
|
if (!def) return void 0;
|
|
62
62
|
if (def.type === "default" && def.defaultValue !== void 0) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const probe1 = def.defaultValue;
|
|
64
|
+
const probe2 = def.defaultValue;
|
|
65
|
+
if (typeof probe1 === "function" || probe1 !== probe2) return "\"<computed>\"";
|
|
66
|
+
if (probe1 === "" || probe1 === void 0) return void 0;
|
|
67
|
+
return JSON.stringify(probe1);
|
|
66
68
|
}
|
|
67
69
|
if (def.in) {
|
|
68
70
|
t = def.in;
|
|
@@ -80,7 +82,7 @@ function isOptional(field) {
|
|
|
80
82
|
for (let i = 0; i < 6; i++) {
|
|
81
83
|
const def = t.def;
|
|
82
84
|
if (!def) return false;
|
|
83
|
-
if (def.type === "optional" || def.type === "default") return true;
|
|
85
|
+
if (def.type === "optional" || def.type === "default" || def.type === "prefault") return true;
|
|
84
86
|
if (def.in) {
|
|
85
87
|
t = def.in;
|
|
86
88
|
continue;
|
|
@@ -93,6 +95,26 @@ function isOptional(field) {
|
|
|
93
95
|
}
|
|
94
96
|
return false;
|
|
95
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Walk through `.optional()` / `.default(...)` / `.prefault(...)` wrappers to
|
|
100
|
+
* find a nested ZodObject's `.shape`. Returns undefined if `field` does not
|
|
101
|
+
* (eventually) wrap a ZodObject. Mirrors the unwrap loop in
|
|
102
|
+
* `extractDefault` / `isOptional` so that a nested object can be wrapped in
|
|
103
|
+
* any of the common compositional modifiers and still be walked for docs.
|
|
104
|
+
*/
|
|
105
|
+
function findInnerShape(field) {
|
|
106
|
+
let t = field;
|
|
107
|
+
for (let i = 0; i < 8; i++) {
|
|
108
|
+
const node = t;
|
|
109
|
+
if (node.shape) return node.shape;
|
|
110
|
+
if (node.def?.shape) return node.def.shape;
|
|
111
|
+
if (node.def?.innerType) {
|
|
112
|
+
t = node.def.innerType;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
96
118
|
function describeFieldRecursive(shape, envMap, fieldPath, descriptions, out) {
|
|
97
119
|
for (const [name, field] of Object.entries(shape)) {
|
|
98
120
|
const path = fieldPath ? `${fieldPath}.${name}` : name;
|
|
@@ -113,8 +135,7 @@ function describeFieldRecursive(shape, envMap, fieldPath, descriptions, out) {
|
|
|
113
135
|
description: explicitDesc ?? zodDesc ?? def2?.description
|
|
114
136
|
});
|
|
115
137
|
} else {
|
|
116
|
-
const
|
|
117
|
-
const innerShape = nested.shape ?? nested.def?.shape;
|
|
138
|
+
const innerShape = findInnerShape(field);
|
|
118
139
|
if (innerShape) describeFieldRecursive(innerShape, mapping, path, descriptions, out);
|
|
119
140
|
}
|
|
120
141
|
}
|
package/dist/env/logger-env.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare const LoggerEnvSchema: z.ZodObject<{
|
|
|
20
20
|
KICI_LOG_MAX_SIZE: z.ZodDefault<z.ZodString>;
|
|
21
21
|
KICI_LOG_RETENTION_DAYS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
22
22
|
KICI_LOG_FORMAT: z.ZodDefault<z.ZodEnum<{
|
|
23
|
-
plain: "plain";
|
|
24
23
|
json: "json";
|
|
25
24
|
auto: "auto";
|
|
25
|
+
plain: "plain";
|
|
26
26
|
}>>;
|
|
27
27
|
KICI_CLUSTER_INSTANCE_ID: z.ZodOptional<z.ZodString>;
|
|
28
28
|
KICI_AGENT_ID: z.ZodOptional<z.ZodString>;
|
package/dist/idempotency.d.ts
CHANGED
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Idempotent-step primitive: a check / prompt / apply runner that is
|
|
3
|
-
* UI-agnostic and embeddable across the product.
|
|
4
|
-
*
|
|
5
|
-
* The pattern: every destructive operation on shared state (prod infra,
|
|
6
|
-
* npm, git remotes, DNS, TF state, workflow step side effects) is wrapped
|
|
7
|
-
* as an IdempotentStep whose check() returns a typed drift value or null.
|
|
8
|
-
* Null means the system is already in the desired state — the runner
|
|
9
|
-
* silently skips, optionally invoking whenInSync() to surface the
|
|
10
|
-
* already-satisfied resource (e.g. an existing resource id). A non-null
|
|
11
|
-
* drift means apply() would change state — the runner asks the caller's
|
|
12
|
-
* confirm() before invoking apply(), unless yes or dryRun overrides are
|
|
13
|
-
* set. apply() returns the typed result of the change for the caller.
|
|
14
|
-
*
|
|
15
|
-
* The runner has no UI dependency. CLI consumers pass an inquirer-backed
|
|
16
|
-
* confirm; future SDK / agent consumers pass their own policy function.
|
|
17
|
-
* See `.claude/rules/idempotency.md` for the full rule and adopters.
|
|
18
|
-
*/
|
|
19
|
-
export interface IdempotentStep<TDrift, TInSync = void, TApplied = void> {
|
|
20
|
-
/** Human-readable name; appears in logs and the confirm prompt. */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Read-only inspection. Returns drift value if apply() would change
|
|
23
|
-
* state, or null if the system is already in the desired state. */
|
|
24
|
-
check: () => Promise<TDrift | null>;
|
|
25
|
-
/** Multi-line description of what apply() would do, given drift. */
|
|
26
|
-
summarize: (drift: TDrift) => string;
|
|
27
|
-
/** Destructive action that brings the system into the desired state.
|
|
28
|
-
* Its return value is surfaced in StepResult.result on the 'applied'
|
|
29
|
-
* outcome. */
|
|
30
|
-
apply: (drift: TDrift) => Promise<TApplied>;
|
|
31
|
-
/** Optional: runs when check() returns null. Use this to fetch the
|
|
32
|
-
* already-satisfied resource (e.g. read the existing id when a
|
|
33
|
-
* create-if-missing was already done). Return value is surfaced in
|
|
34
|
-
* StepResult.result on the 'skipped' outcome. */
|
|
35
|
-
whenInSync?: () => Promise<TInSync>;
|
|
36
|
-
}
|
|
37
|
-
export type ConfirmFn = (message: string) => Promise<boolean>;
|
|
38
|
-
export interface RunOptions {
|
|
39
|
-
/** Pluggable confirm. Required unless `yes` or `dryRun` is set. */
|
|
40
|
-
confirm?: ConfirmFn;
|
|
41
|
-
/** Breakglass: skip prompts, apply on drift. The CALLER prints any
|
|
42
|
-
* loud "auto-confirm" banner before invoking the runner. */
|
|
43
|
-
yes?: boolean;
|
|
44
|
-
/** Report only; bypass confirm; never call apply(). */
|
|
45
|
-
dryRun?: boolean;
|
|
46
|
-
/** Sink for `name`-prefixed status lines. Defaults to console.log. */
|
|
47
|
-
log?: (line: string) => void;
|
|
48
|
-
}
|
|
49
|
-
export type StepOutcome = 'skipped' | 'applied' | 'declined' | 'dry-run';
|
|
50
|
-
export type StepResult<TDrift, TInSync = void, TApplied = void> = {
|
|
51
|
-
outcome: 'skipped';
|
|
52
|
-
drift: null;
|
|
53
|
-
result: TInSync;
|
|
54
|
-
} | {
|
|
55
|
-
outcome: 'applied';
|
|
56
|
-
drift: TDrift;
|
|
57
|
-
result: TApplied;
|
|
58
|
-
} | {
|
|
59
|
-
outcome: 'declined';
|
|
60
|
-
drift: TDrift;
|
|
61
|
-
result: undefined;
|
|
62
|
-
} | {
|
|
63
|
-
outcome: 'dry-run';
|
|
64
|
-
drift: TDrift;
|
|
65
|
-
result: undefined;
|
|
66
|
-
};
|
|
67
|
-
export declare function runIdempotentStep<TDrift, TInSync = void, TApplied = void>(step: IdempotentStep<TDrift, TInSync, TApplied>, opts?: RunOptions): Promise<StepResult<TDrift, TInSync, TApplied>>;
|
|
1
|
+
export * from '@kici-dev/core/idempotency';
|
|
68
2
|
//# sourceMappingURL=idempotency.d.ts.map
|
package/dist/idempotency.js
CHANGED
|
@@ -1,49 +1,3 @@
|
|
|
1
1
|
import "./chunk-gOLHoazu.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const log = opts.log ?? ((line) => console.log(line));
|
|
5
|
-
const drift = await step.check();
|
|
6
|
-
if (drift === null) {
|
|
7
|
-
log(`✓ ${step.name} — in sync, skipping`);
|
|
8
|
-
return {
|
|
9
|
-
outcome: "skipped",
|
|
10
|
-
drift: null,
|
|
11
|
-
result: step.whenInSync ? await step.whenInSync() : void 0
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
log(`! ${step.name} — drift detected:`);
|
|
15
|
-
for (const line of step.summarize(drift).split("\n")) log(` ${line}`);
|
|
16
|
-
if (opts.dryRun) {
|
|
17
|
-
log(` (dry-run; would apply)`);
|
|
18
|
-
return {
|
|
19
|
-
outcome: "dry-run",
|
|
20
|
-
drift,
|
|
21
|
-
result: void 0
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
let approved;
|
|
25
|
-
if (opts.yes) approved = true;
|
|
26
|
-
else {
|
|
27
|
-
if (!opts.confirm) throw new Error(`runIdempotentStep(${step.name}): drift detected but no confirm callback provided and yes/dryRun not set. Pass opts.confirm, opts.yes, or opts.dryRun.`);
|
|
28
|
-
approved = await opts.confirm(`Apply ${step.name}?`);
|
|
29
|
-
}
|
|
30
|
-
if (!approved) {
|
|
31
|
-
log(` declined; skipping`);
|
|
32
|
-
return {
|
|
33
|
-
outcome: "declined",
|
|
34
|
-
drift,
|
|
35
|
-
result: void 0
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const appliedResult = await step.apply(drift);
|
|
39
|
-
log(`✓ ${step.name} — applied`);
|
|
40
|
-
return {
|
|
41
|
-
outcome: "applied",
|
|
42
|
-
drift,
|
|
43
|
-
result: appliedResult
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//#endregion
|
|
47
|
-
export { runIdempotentStep };
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=idempotency.js.map
|
|
2
|
+
export * from "@kici-dev/core/idempotency";
|
|
3
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
+
export * from '@kici-dev/core';
|
|
1
2
|
export { RingBuffer } from './ring-buffer.js';
|
|
2
|
-
export { toErrorMessage, serializeError } from './error.js';
|
|
3
3
|
export { createPool, createDb } from './db.js';
|
|
4
4
|
export { parseDatabaseUrl, maskDatabaseUrl, dropAndCreateDatabase, dropDatabaseDirect, ensureDatabase, type EnsureDatabaseOpts, createDbRole, createReadOnlyDbUser, computeMigrationsHash, storeMigrationContentHash, readStoredMigrationContentHash, isSchemaCurrent, clearDispatchQueueDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, purgeScopedSecretsDirect, seedEnvironmentDirect, seedEnvironmentBindingDirect, setEnvironmentPolicyDirect, listEnvironmentsDirect, showEnvironmentDirect, createEnvironmentTemplateDirect, setEnvironmentSecretDirect, listQueueDirect, showQueueEntryDirect, listExecutionRunsDirect, showExecutionRunDirect, listExecutionJobsDirect, listRegistrationsDirect, showRegistrationDirect, registerWorkflowManualDirect, resetRaftStateDirect, emitKiciEventDirect, seedGenericWebhookSourceDirect, purgeSecretBackendsDirect, apiKeyExistsDirect, seedApiKeyInlineDirect, platformConnectionExistsDirect, countWebhookSourcesByConnectionIdDirect, getWebhookSourceByRoutingKeyDirect, findAnyUserApiKeyIdDirect, seedSyntheticGithubSourceDirect, seedWebhookSecretDirect, seedSourcePrivateKeyDirect, bumpRegistryVersionDirect, pollKiciEventsDirect, waitForPostgresDirect, waitForRunCompletionDirect, cleanupExecutionRowsDirect, isSchemaCurrentFromFilesDirect, storeMigrationContentHashInTableDirect, createJoinTokenDirect, updateSourceRoutingKeyDirect, prunePeerCredentialsDirect, waitForPlatformRegistrationsDirect, seedUniversalGitSourceDirect, seedCiSecurityFixturesDirect, waitForExecutionRunStatusSinceDirect, latestExecutionRunByStatusDirect, waitForLatestExecutionJobStatusDirect, describeTableColumnsDirect, tableExistsDirect, insertKiciEventRawDirect, showKiciEventDirect, listKiciEventsDirect, deleteKiciEventsDirect, verifyKiciEventNotifyDirect, seedCrossRepoTrustDirect, listCrossRepoTrustBySourceRoutingKeyDirect, deleteCrossRepoTrustDirect, insertCrossRepoTrustStrictDirect, deleteWorkflowRegistrationsDirect, getWorkflowRegistrationByIdDirect, listRegistrationsByRoutingKeyDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, updateWorkflowRegistrationCommitShaDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, getRegistryVersionDirect, bumpRegistryVersionSimpleDirect, upsertCronLastFiredDirect, countCronLastFiredDirect, insertCronLastFiredNowDirect, deleteCronLastFiredDirect, deleteExecutionRunsByWorkflowNameDirect, getGenericWebhookSourceByRoutingKeyDirect, listActiveGenericWebhookSourcesDirect, updateGenericWebhookVerificationConfigDirect, deleteGenericWebhookSourcesByNameDirect, restoreSoftDeletedGenericWebhookSourceDirect, upsertOrgSettingsGlobalWorkflowsDirect, updateOrgSettingsDeniedReposDirect, deleteOrgSettingsByCustomerIdDirect, getExecutionRunSecurityDirect, getHeldRunByIdDirect, countHeldRunsByRunIdDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForEventLogRowByDeliveryIdDirect, resolvePlatformWebhookSourceRoutingKeyDirect, ensureOrgOwnerMemberDirect, deletePeerCredentialsByInstanceIdLikeDirect, insertPeerCredentialExpiredDirect, getPeerCredentialRevokedAtDirect, listActivePeerCredentialsExcludingDirect, clearPeerCredentialsRevokedAtByIdsDirect, countActivePeerCredentialsByInstanceDirect, type ColumnInfo, type KiciEventRow, type CrossRepoTrustRow, type WorkflowRegistrationFullRow, type RegistrationsScopedResult, type LatestExecutionRunResult, type WaitForLatestJobResult, type ExecutionRunSecurityRow, type HeldRunSecurityRow, type EventLogRow as PlatformEventLogRow, type UpsertOrgSettingsOpts, type OrgSettingsRepoPatternEntry, type InsertKiciEventRawOpts, type EmitKiciEventOpts, type SeedGenericWebhookSourceOpts, REGISTERABLE_TRIGGER_TYPES, MIGRATION_HASH_TABLE, type PurgeStaleExecutionResult, type PurgeStaleSourcesResult, type SeedEnvironmentOpts, type SeedEnvironmentResult, type SeedEnvironmentBindingOpts, type SetEnvironmentPolicyOpts, type EnvironmentRow, type EnvironmentVariableRow, type EnvironmentBindingRow, type ShowEnvironmentResult, type CreateEnvironmentTemplateOpts, type SetEnvironmentSecretOpts, type DispatchQueueRow, type ListQueueOpts, type ExecutionRunRow, type ExecutionJobRow, type ListExecutionRunsOpts, type WorkflowRegistrationRow, type ListRegistrationsOpts, type ListRegistrationsResult, type ShowRegistrationResult, type RegisterWorkflowManualOpts, type RegisterWorkflowManualResult, } from './db-admin.js';
|
|
5
5
|
export { createMetricsRoutes, type MetricsRoutesDeps } from './routes/metrics.js';
|
|
6
6
|
export { createHealthRoutes, type HealthRoutesDeps } from './routes/health.js';
|
|
7
|
-
export { initZx } from './zx.js';
|
|
8
|
-
export { createLogger, guardStartup, logger, setServiceName, type LogLevel, type Logger, } from './logger.js';
|
|
9
|
-
export { requestContext, getRequestContext, enrichRequestContext, type RequestContext, } from './request-context.js';
|
|
10
7
|
export { getReconnectDelay } from './reconnect-delay.js';
|
|
11
|
-
export { formatBytes } from './format-bytes.js';
|
|
12
|
-
export { formatDuration, formatUptime } from './format-duration.js';
|
|
13
|
-
export { sha256, sha256File, deriveSharedSecret, normalizeLineEndings } from './crypto.js';
|
|
14
8
|
export { initTelemetry, getPrometheusExporter, collectRuntimeMetricNames, createMeter, type TelemetryConfig, } from './telemetry/index.js';
|
|
15
9
|
export { setupGracefulShutdown, type ShutdownStep, type ShutdownLogger, type ShutdownHandle, type GracefulShutdownOptions, } from './graceful-shutdown.js';
|
|
16
10
|
export { validateRequiredTools, type ToolRequirement } from './tool-check.js';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import "./chunk-gOLHoazu.js";
|
|
2
|
-
import { deriveSharedSecret, normalizeLineEndings, sha256, sha256File } from "./crypto.js";
|
|
3
2
|
import { createDb, createPool } from "./db.js";
|
|
4
3
|
import { MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, apiKeyExistsDirect, bumpRegistryVersionDirect, bumpRegistryVersionSimpleDirect, cleanupExecutionRowsDirect, clearDispatchQueueDirect, clearPeerCredentialsRevokedAtByIdsDirect, computeMigrationsHash, countActivePeerCredentialsByInstanceDirect, countCronLastFiredDirect, countHeldRunsByRunIdDirect, countWebhookSourcesByConnectionIdDirect, createDbRole, createEnvironmentTemplateDirect, createJoinTokenDirect, createReadOnlyDbUser, deleteCronLastFiredDirect, deleteCrossRepoTrustDirect, deleteExecutionRunsByWorkflowNameDirect, deleteGenericWebhookSourcesByNameDirect, deleteKiciEventsDirect, deleteOrgSettingsByCustomerIdDirect, deletePeerCredentialsByInstanceIdLikeDirect, deleteWorkflowRegistrationsDirect, describeTableColumnsDirect, dropAndCreateDatabase, dropDatabaseDirect, emitKiciEventDirect, ensureDatabase, ensureOrgOwnerMemberDirect, findAnyUserApiKeyIdDirect, getExecutionRunSecurityDirect, getGenericWebhookSourceByRoutingKeyDirect, getHeldRunByIdDirect, getPeerCredentialRevokedAtDirect, getRegistryVersionDirect, getWebhookSourceByRoutingKeyDirect, getWorkflowRegistrationByIdDirect, insertCronLastFiredNowDirect, insertCrossRepoTrustStrictDirect, insertKiciEventRawDirect, insertPeerCredentialExpiredDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, isSchemaCurrent, isSchemaCurrentFromFilesDirect, latestExecutionRunByStatusDirect, listActiveGenericWebhookSourcesDirect, listActivePeerCredentialsExcludingDirect, listCrossRepoTrustBySourceRoutingKeyDirect, listEnvironmentsDirect, listExecutionJobsDirect, listExecutionRunsDirect, listKiciEventsDirect, listQueueDirect, listRegistrationsByRoutingKeyDirect, listRegistrationsDirect, maskDatabaseUrl, parseDatabaseUrl, platformConnectionExistsDirect, pollKiciEventsDirect, prunePeerCredentialsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, registerWorkflowManualDirect, resetRaftStateDirect, resolvePlatformWebhookSourceRoutingKeyDirect, restoreSoftDeletedGenericWebhookSourceDirect, seedApiKeyInlineDirect, seedCiSecurityFixturesDirect, seedCrossRepoTrustDirect, seedEnvironmentBindingDirect, seedEnvironmentDirect, seedGenericWebhookSourceDirect, seedSourcePrivateKeyDirect, seedSyntheticGithubSourceDirect, seedUniversalGitSourceDirect, seedWebhookSecretDirect, setEnvironmentPolicyDirect, setEnvironmentSecretDirect, showEnvironmentDirect, showExecutionRunDirect, showKiciEventDirect, showQueueEntryDirect, showRegistrationDirect, storeMigrationContentHash, storeMigrationContentHashInTableDirect, tableExistsDirect, updateGenericWebhookVerificationConfigDirect, updateOrgSettingsDeniedReposDirect, updateSourceRoutingKeyDirect, updateWorkflowRegistrationCommitShaDirect, upsertCronLastFiredDirect, upsertOrgSettingsGlobalWorkflowsDirect, verifyKiciEventNotifyDirect, waitForEventLogRowByDeliveryIdDirect, waitForExecutionRunStatusSinceDirect, waitForLatestExecutionJobStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformRegistrationsDirect, waitForPostgresDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, waitForRunCompletionDirect } from "./db-admin.js";
|
|
5
|
-
import { serializeError, toErrorMessage } from "./error.js";
|
|
6
|
-
import { formatBytes } from "./format-bytes.js";
|
|
7
|
-
import { formatDuration, formatUptime } from "./format-duration.js";
|
|
8
4
|
import { setupGracefulShutdown } from "./graceful-shutdown.js";
|
|
9
5
|
import { RingBuffer } from "./ring-buffer.js";
|
|
10
6
|
import { createMetricsRoutes } from "./routes/metrics.js";
|
|
11
7
|
import { createHealthRoutes } from "./routes/health.js";
|
|
12
|
-
import { initZx } from "./zx.js";
|
|
13
|
-
import { enrichRequestContext, getRequestContext, requestContext } from "./request-context.js";
|
|
14
|
-
import { createLogger, guardStartup, logger, setServiceName } from "./logger.js";
|
|
15
8
|
import { getReconnectDelay } from "./reconnect-delay.js";
|
|
16
9
|
import { collectRuntimeMetricNames, getPrometheusExporter, initTelemetry } from "./telemetry/init.js";
|
|
17
10
|
import { createMeter } from "./telemetry/metrics.js";
|
|
@@ -28,4 +21,5 @@ import { BaseColdStore } from "./cold-store/cold-store.js";
|
|
|
28
21
|
import { ChunkLru } from "./cold-store/lru.js";
|
|
29
22
|
import { DEFAULT_TABLE_CONFIG, resolveTableConfig } from "./cold-store/config.js";
|
|
30
23
|
import "./cold-store/index.js";
|
|
31
|
-
export
|
|
24
|
+
export * from "@kici-dev/core";
|
|
25
|
+
export { BaseColdStore, COLD_BUCKET_NAMES, ChunkLru, DEFAULT_TABLE_CONFIG, MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, RingBuffer, apiKeyExistsDirect, bumpRegistryVersionDirect, bumpRegistryVersionSimpleDirect, chunkObjectKey, cleanupExecutionRowsDirect, clearDispatchQueueDirect, clearPeerCredentialsRevokedAtByIdsDirect, coldDaysToBucket, coldStoreArchiveBytesTotal, coldStoreArchiveCyclesTotal, coldStoreArchiveDurationSeconds, coldStoreArchiveRowsTotal, coldStorePurgeBytesTotal, coldStorePurgeChunksTotal, coldStorePurgeDurationSeconds, coldStoreRehydrateBytesTotal, coldStoreRehydrateDurationSeconds, coldStoreRehydrateRequestsTotal, coldStoreReplayDurationSeconds, coldStoreReplayRowsTotal, coldStoreVerifyFailuresTotal, collectRuntimeMetricNames, computeChunkId, computeMigrationsHash, countActivePeerCredentialsByInstanceDirect, countCronLastFiredDirect, countHeldRunsByRunIdDirect, countWebhookSourcesByConnectionIdDirect, createDb, createDbRole, createEnvironmentTemplateDirect, createHealthRoutes, createJoinTokenDirect, createMeter, createMetricsRoutes, createPool, createReadOnlyDbUser, createS3Client, decodeChunk, deleteCronLastFiredDirect, deleteCrossRepoTrustDirect, deleteExecutionRunsByWorkflowNameDirect, deleteGenericWebhookSourcesByNameDirect, deleteKiciEventsDirect, deleteOrgSettingsByCustomerIdDirect, deletePeerCredentialsByInstanceIdLikeDirect, deleteWorkflowRegistrationsDirect, describeTableColumnsDirect, dropAndCreateDatabase, dropDatabaseDirect, emitKiciEventDirect, encodeChunk, encodeKeySegment, ensureDatabase, ensureOrgOwnerMemberDirect, findAnyUserApiKeyIdDirect, getExecutionRunSecurityDirect, getGenericWebhookSourceByRoutingKeyDirect, getHeldRunByIdDirect, getPeerCredentialRevokedAtDirect, getPrometheusExporter, getReconnectDelay, getRegistryVersionDirect, getWebhookSourceByRoutingKeyDirect, getWorkflowRegistrationByIdDirect, initTelemetry, insertCronLastFiredNowDirect, insertCrossRepoTrustStrictDirect, insertKiciEventRawDirect, insertPeerCredentialExpiredDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, isLongerColdRetention, isSchemaCurrent, isSchemaCurrentFromFilesDirect, latestExecutionRunByStatusDirect, listActiveGenericWebhookSourcesDirect, listActivePeerCredentialsExcludingDirect, listCrossRepoTrustBySourceRoutingKeyDirect, listEnvironmentsDirect, listExecutionJobsDirect, listExecutionRunsDirect, listKiciEventsDirect, listQueueDirect, listRegistrationsByRoutingKeyDirect, listRegistrationsDirect, maskDatabaseUrl, parseDatabaseUrl, parseManifest, platformConnectionExistsDirect, pollKiciEventsDirect, prunePeerCredentialsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, registerWorkflowManualDirect, resetRaftStateDirect, resolvePlatformWebhookSourceRoutingKeyDirect, resolveTableConfig, restoreSoftDeletedGenericWebhookSourceDirect, seedApiKeyInlineDirect, seedCiSecurityFixturesDirect, seedCrossRepoTrustDirect, seedEnvironmentBindingDirect, seedEnvironmentDirect, seedGenericWebhookSourceDirect, seedSourcePrivateKeyDirect, seedSyntheticGithubSourceDirect, seedUniversalGitSourceDirect, seedWebhookSecretDirect, serializeManifest, setEnvironmentPolicyDirect, setEnvironmentSecretDirect, setupGracefulShutdown, showEnvironmentDirect, showExecutionRunDirect, showKiciEventDirect, showQueueEntryDirect, showRegistrationDirect, storeMigrationContentHash, storeMigrationContentHashInTableDirect, tableExistsDirect, tablePrefix, tenantDayBucketPrefix, tenantDayPrefix, updateGenericWebhookVerificationConfigDirect, updateOrgSettingsDeniedReposDirect, updateSourceRoutingKeyDirect, updateWorkflowRegistrationCommitShaDirect, upsertCronLastFiredDirect, upsertOrgSettingsGlobalWorkflowsDirect, validateRequiredTools, verifyKiciEventNotifyDirect, waitForEventLogRowByDeliveryIdDirect, waitForExecutionRunStatusSinceDirect, waitForLatestExecutionJobStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformRegistrationsDirect, waitForPostgresDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, waitForRunCompletionDirect };
|
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Package-manager identity — the enum and pure helpers, with no filesystem
|
|
3
|
-
* dependency. Kept separate from `package-manager.ts` (which reads the disk to
|
|
4
|
-
* detect the manager) so browser-safe consumers — the engine protocol schemas
|
|
5
|
-
* and lock-file types the dashboard transitively imports — can reference the
|
|
6
|
-
* enum without pulling `node:fs` into a browser bundle.
|
|
7
|
-
*/
|
|
8
|
-
/** Supported package managers. */
|
|
9
|
-
export declare enum PackageManager {
|
|
10
|
-
Npm = "npm",
|
|
11
|
-
Pnpm = "pnpm",
|
|
12
|
-
Yarn = "yarn"
|
|
13
|
-
}
|
|
14
|
-
/** All package-manager identifiers, for flag/schema validation. */
|
|
15
|
-
export declare const PACKAGE_MANAGERS: readonly PackageManager[];
|
|
16
|
-
/**
|
|
17
|
-
* Parse a raw string into a {@link PackageManager}, or `null` when it does not
|
|
18
|
-
* name a supported manager. Accepts bare names (`pnpm`) used by the CLI flag
|
|
19
|
-
* and the env-var / packageManager-field tiers.
|
|
20
|
-
*/
|
|
21
|
-
export declare function parsePackageManager(value: string): PackageManager | null;
|
|
1
|
+
export * from '@kici-dev/core/package-manager-types';
|
|
22
2
|
//# sourceMappingURL=package-manager-types.d.ts.map
|
|
@@ -1,35 +1,3 @@
|
|
|
1
1
|
import "./chunk-gOLHoazu.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Package-manager identity — the enum and pure helpers, with no filesystem
|
|
5
|
-
* dependency. Kept separate from `package-manager.ts` (which reads the disk to
|
|
6
|
-
* detect the manager) so browser-safe consumers — the engine protocol schemas
|
|
7
|
-
* and lock-file types the dashboard transitively imports — can reference the
|
|
8
|
-
* enum without pulling `node:fs` into a browser bundle.
|
|
9
|
-
*/
|
|
10
|
-
/** Supported package managers. */
|
|
11
|
-
let PackageManager = /* @__PURE__ */ function(PackageManager) {
|
|
12
|
-
PackageManager["Npm"] = "npm";
|
|
13
|
-
PackageManager["Pnpm"] = "pnpm";
|
|
14
|
-
PackageManager["Yarn"] = "yarn";
|
|
15
|
-
return PackageManager;
|
|
16
|
-
}({});
|
|
17
|
-
/** All package-manager identifiers, for flag/schema validation. */
|
|
18
|
-
const PACKAGE_MANAGERS = Object.values(PackageManager);
|
|
19
|
-
/**
|
|
20
|
-
* Parse a raw string into a {@link PackageManager}, or `null` when it does not
|
|
21
|
-
* name a supported manager. Accepts bare names (`pnpm`) used by the CLI flag
|
|
22
|
-
* and the env-var / packageManager-field tiers.
|
|
23
|
-
*/
|
|
24
|
-
function parsePackageManager(value) {
|
|
25
|
-
switch (value) {
|
|
26
|
-
case "npm": return "npm";
|
|
27
|
-
case "pnpm": return "pnpm";
|
|
28
|
-
case "yarn": return "yarn";
|
|
29
|
-
default: return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { PACKAGE_MANAGERS, PackageManager, parsePackageManager };
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=package-manager-types.js.map
|
|
2
|
+
export * from "@kici-dev/core/package-manager-types";
|
|
3
|
+
export {};
|
|
@@ -1,52 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Package-manager detection.
|
|
3
|
-
*
|
|
4
|
-
* Determines which package manager (npm / pnpm / yarn) a project relies on, so
|
|
5
|
-
* dependency operations use the manager that matches the rest of the user's
|
|
6
|
-
* repository instead of always assuming npm. Used by `kici init` (to generate a
|
|
7
|
-
* lockfile that matches the user's repo) and by the agent (to install `.kici/`
|
|
8
|
-
* dependencies with the manager that can resolve the repo's dependency graph,
|
|
9
|
-
* including pnpm/yarn `workspace:` siblings).
|
|
10
|
-
*
|
|
11
|
-
* The {@link PackageManager} enum + pure helpers live in the node-free
|
|
12
|
-
* `./package-manager-types.js` module and are re-exported here so existing
|
|
13
|
-
* `@kici-dev/shared/package-manager` consumers keep one import site.
|
|
14
|
-
*/
|
|
15
|
-
import { PackageManager } from './package-manager-types.js';
|
|
16
|
-
export { PackageManager, PACKAGE_MANAGERS, parsePackageManager } from './package-manager-types.js';
|
|
17
|
-
/** Map a detected manager to its install command argv (binary + args). */
|
|
18
|
-
export declare function installCommand(pm: PackageManager): [string, 'install'];
|
|
19
|
-
/**
|
|
20
|
-
* Detect the package manager the user's project relies on.
|
|
21
|
-
*
|
|
22
|
-
* Priority order (first match wins):
|
|
23
|
-
* 1. `packageManager` field in `<projectDir>/package.json` (Corepack
|
|
24
|
-
* convention, e.g. `"packageManager": "pnpm@9.x"`). Only the name before
|
|
25
|
-
* `@` is parsed; an unrecognized name falls through.
|
|
26
|
-
* 2. A lockfile in the project root (`pnpm-lock.yaml` > `yarn.lock` >
|
|
27
|
-
* `package-lock.json`).
|
|
28
|
-
* 3. The `npm_config_user_agent` env var (set by `pnpm dlx` / `yarn dlx` /
|
|
29
|
-
* `npx`); the leading `<name>/` segment names the manager.
|
|
30
|
-
* 4. Default to npm when nothing matches, so we never guess wrong and emit a
|
|
31
|
-
* lockfile the user did not ask for.
|
|
32
|
-
*
|
|
33
|
-
* @param projectDir - The project root to inspect.
|
|
34
|
-
*/
|
|
35
|
-
export declare function detectPackageManager(projectDir: string): Promise<PackageManager>;
|
|
36
|
-
/**
|
|
37
|
-
* Detect the package manager from a directory's **committed manifests only** —
|
|
38
|
-
* tiers 1 (`packageManager` field) and 2 (lockfile). Returns `null` when the
|
|
39
|
-
* directory carries no package-manager signal, so callers can distinguish
|
|
40
|
-
* "explicitly npm" from "no signal".
|
|
41
|
-
*
|
|
42
|
-
* This deliberately excludes the `npm_config_user_agent` tier: a consumer
|
|
43
|
-
* inspecting a cloned repository (the agent) must key off the repo's own files,
|
|
44
|
-
* not the ambient env of the process that happens to be reading them.
|
|
45
|
-
*/
|
|
46
|
-
export declare function detectPackageManagerFromManifests(projectDir: string): Promise<PackageManager | null>;
|
|
47
|
-
/**
|
|
48
|
-
* Synchronous {@link detectPackageManager}. Used by the compiler's lock-file
|
|
49
|
-
* generation, which is synchronous; identical tiering and precedence.
|
|
50
|
-
*/
|
|
51
|
-
export declare function detectPackageManagerSync(projectDir: string): PackageManager;
|
|
1
|
+
export * from '@kici-dev/core/package-manager';
|
|
52
2
|
//# sourceMappingURL=package-manager.d.ts.map
|
package/dist/package-manager.js
CHANGED
|
@@ -1,131 +1,3 @@
|
|
|
1
1
|
import "./chunk-gOLHoazu.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { accessSync, readFileSync } from "node:fs";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
//#region src/package-manager.ts
|
|
7
|
-
/**
|
|
8
|
-
* Package-manager detection.
|
|
9
|
-
*
|
|
10
|
-
* Determines which package manager (npm / pnpm / yarn) a project relies on, so
|
|
11
|
-
* dependency operations use the manager that matches the rest of the user's
|
|
12
|
-
* repository instead of always assuming npm. Used by `kici init` (to generate a
|
|
13
|
-
* lockfile that matches the user's repo) and by the agent (to install `.kici/`
|
|
14
|
-
* dependencies with the manager that can resolve the repo's dependency graph,
|
|
15
|
-
* including pnpm/yarn `workspace:` siblings).
|
|
16
|
-
*
|
|
17
|
-
* The {@link PackageManager} enum + pure helpers live in the node-free
|
|
18
|
-
* `./package-manager-types.js` module and are re-exported here so existing
|
|
19
|
-
* `@kici-dev/shared/package-manager` consumers keep one import site.
|
|
20
|
-
*/
|
|
21
|
-
/** Map a detected manager to its install command argv (binary + args). */
|
|
22
|
-
function installCommand(pm) {
|
|
23
|
-
return [pm, "install"];
|
|
24
|
-
}
|
|
25
|
-
/** Lockfile basenames mapped to the manager that produces them, in priority order. */
|
|
26
|
-
const LOCKFILES = [
|
|
27
|
-
["pnpm-lock.yaml", "pnpm"],
|
|
28
|
-
["yarn.lock", "yarn"],
|
|
29
|
-
["package-lock.json", "npm"]
|
|
30
|
-
];
|
|
31
|
-
/**
|
|
32
|
-
* Detect the package manager the user's project relies on.
|
|
33
|
-
*
|
|
34
|
-
* Priority order (first match wins):
|
|
35
|
-
* 1. `packageManager` field in `<projectDir>/package.json` (Corepack
|
|
36
|
-
* convention, e.g. `"packageManager": "pnpm@9.x"`). Only the name before
|
|
37
|
-
* `@` is parsed; an unrecognized name falls through.
|
|
38
|
-
* 2. A lockfile in the project root (`pnpm-lock.yaml` > `yarn.lock` >
|
|
39
|
-
* `package-lock.json`).
|
|
40
|
-
* 3. The `npm_config_user_agent` env var (set by `pnpm dlx` / `yarn dlx` /
|
|
41
|
-
* `npx`); the leading `<name>/` segment names the manager.
|
|
42
|
-
* 4. Default to npm when nothing matches, so we never guess wrong and emit a
|
|
43
|
-
* lockfile the user did not ask for.
|
|
44
|
-
*
|
|
45
|
-
* @param projectDir - The project root to inspect.
|
|
46
|
-
*/
|
|
47
|
-
async function detectPackageManager(projectDir) {
|
|
48
|
-
const fromManifests = await detectPackageManagerFromManifests(projectDir);
|
|
49
|
-
if (fromManifests) return fromManifests;
|
|
50
|
-
const fromUserAgent = parseUserAgent(process.env.npm_config_user_agent);
|
|
51
|
-
if (fromUserAgent) return fromUserAgent;
|
|
52
|
-
return "npm";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Detect the package manager from a directory's **committed manifests only** —
|
|
56
|
-
* tiers 1 (`packageManager` field) and 2 (lockfile). Returns `null` when the
|
|
57
|
-
* directory carries no package-manager signal, so callers can distinguish
|
|
58
|
-
* "explicitly npm" from "no signal".
|
|
59
|
-
*
|
|
60
|
-
* This deliberately excludes the `npm_config_user_agent` tier: a consumer
|
|
61
|
-
* inspecting a cloned repository (the agent) must key off the repo's own files,
|
|
62
|
-
* not the ambient env of the process that happens to be reading them.
|
|
63
|
-
*/
|
|
64
|
-
async function detectPackageManagerFromManifests(projectDir) {
|
|
65
|
-
const fromField = parsePackageManagerField(await readPackageJson(projectDir));
|
|
66
|
-
if (fromField) return fromField;
|
|
67
|
-
for (const [file, pm] of LOCKFILES) if (await fileExists(path.join(projectDir, file))) return pm;
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Synchronous {@link detectPackageManager}. Used by the compiler's lock-file
|
|
72
|
-
* generation, which is synchronous; identical tiering and precedence.
|
|
73
|
-
*/
|
|
74
|
-
function detectPackageManagerSync(projectDir) {
|
|
75
|
-
const fromField = parsePackageManagerField(readPackageJsonSync(projectDir));
|
|
76
|
-
if (fromField) return fromField;
|
|
77
|
-
for (const [file, pm] of LOCKFILES) if (fileExistsSync(path.join(projectDir, file))) return pm;
|
|
78
|
-
const fromUserAgent = parseUserAgent(process.env.npm_config_user_agent);
|
|
79
|
-
if (fromUserAgent) return fromUserAgent;
|
|
80
|
-
return "npm";
|
|
81
|
-
}
|
|
82
|
-
/** Tier 1: parse the Corepack `packageManager` field, if present. */
|
|
83
|
-
function parsePackageManagerField(content) {
|
|
84
|
-
if (content === null) return null;
|
|
85
|
-
try {
|
|
86
|
-
const pkg = JSON.parse(content);
|
|
87
|
-
if (typeof pkg.packageManager !== "string") return null;
|
|
88
|
-
return parsePackageManager(pkg.packageManager.split("@", 1)[0]);
|
|
89
|
-
} catch {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/** Tier 3: the `npm_config_user_agent` env var, whose leading segment names the manager. */
|
|
94
|
-
function parseUserAgent(userAgent) {
|
|
95
|
-
if (!userAgent) return null;
|
|
96
|
-
return parsePackageManager(userAgent.split("/", 1)[0]);
|
|
97
|
-
}
|
|
98
|
-
async function readPackageJson(projectDir) {
|
|
99
|
-
try {
|
|
100
|
-
return await readFile(path.join(projectDir, "package.json"), "utf-8");
|
|
101
|
-
} catch {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function readPackageJsonSync(projectDir) {
|
|
106
|
-
try {
|
|
107
|
-
return readFileSync(path.join(projectDir, "package.json"), "utf-8");
|
|
108
|
-
} catch {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
async function fileExists(target) {
|
|
113
|
-
try {
|
|
114
|
-
await access(target);
|
|
115
|
-
return true;
|
|
116
|
-
} catch {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function fileExistsSync(target) {
|
|
121
|
-
try {
|
|
122
|
-
accessSync(target);
|
|
123
|
-
return true;
|
|
124
|
-
} catch {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
//#endregion
|
|
129
|
-
export { PACKAGE_MANAGERS, PackageManager, detectPackageManager, detectPackageManagerFromManifests, detectPackageManagerSync, installCommand, parsePackageManager };
|
|
130
|
-
|
|
131
|
-
//# sourceMappingURL=package-manager.js.map
|
|
2
|
+
export * from "@kici-dev/core/package-manager";
|
|
3
|
+
export {};
|
package/dist/ts-loader-hook.d.ts
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
parentURL?: string;
|
|
3
|
-
conditions: string[];
|
|
4
|
-
importAttributes: Record<string, string>;
|
|
5
|
-
};
|
|
6
|
-
type ResolveResult = {
|
|
7
|
-
url: string;
|
|
8
|
-
shortCircuit?: boolean;
|
|
9
|
-
format?: string | null;
|
|
10
|
-
};
|
|
11
|
-
type NextResolve = (specifier: string, context?: ResolveContext) => ResolveResult | Promise<ResolveResult>;
|
|
12
|
-
type LoadContext = {
|
|
13
|
-
format?: string | null;
|
|
14
|
-
importAttributes: Record<string, string>;
|
|
15
|
-
conditions: string[];
|
|
16
|
-
};
|
|
17
|
-
type LoadResult = {
|
|
18
|
-
format: string;
|
|
19
|
-
source?: string | ArrayBuffer | Uint8Array;
|
|
20
|
-
shortCircuit?: boolean;
|
|
21
|
-
};
|
|
22
|
-
type NextLoad = (url: string, context?: LoadContext) => LoadResult | Promise<LoadResult>;
|
|
23
|
-
export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): ResolveResult | Promise<ResolveResult>;
|
|
24
|
-
export declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
25
|
-
export {};
|
|
1
|
+
export * from '@kici-dev/core/ts-loader-hook';
|
|
26
2
|
//# sourceMappingURL=ts-loader-hook.d.ts.map
|