@gadgetinc/dateilager 0.7.9 → 0.7.11

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.
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Thrown when a project already exists in the DL server
3
+ */
1
4
  export declare class ProjectAlreadyExistsError extends Error {
2
5
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectAlreadyExistsError = void 0;
4
+ /**
5
+ * Thrown when a project already exists in the DL server
6
+ */
4
7
  class ProjectAlreadyExistsError extends Error {
5
8
  }
6
9
  exports.ProjectAlreadyExistsError = ProjectAlreadyExistsError;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,yBAA0B,SAAQ,KAAK;CAAG;AAAvD,8DAAuD","sourcesContent":["export class ProjectAlreadyExistsError extends Error {}\n"]}
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK;CAAG;AAAvD,8DAAuD","sourcesContent":["/**\n * Thrown when a project already exists in the DL server\n */\nexport class ProjectAlreadyExistsError extends Error {}\n"]}
@@ -25,38 +25,32 @@ export interface DateiLagerBinaryClientOptions {
25
25
  token: string | (() => Promise<string>);
26
26
  /**
27
27
  * The path to the dateilager-client executable.
28
- *
29
28
  * @default "dateilager-client"
30
29
  */
31
30
  command?: string;
32
31
  /**
33
32
  * The default number of milliseconds to wait before terminating any command.
34
- *
35
33
  * @default 0 No timeout.
36
34
  */
37
35
  timeout?: number | {
38
36
  /**
39
37
  * The default number of milliseconds to wait before terminating the update command.
40
- *
41
38
  * @default 0 No timeout.
42
39
  */
43
40
  update?: number;
44
41
  /**
45
42
  * The default number of milliseconds to wait before terminating the rebuild command.
46
- *
47
43
  * @default 0 No timeout.
48
44
  */
49
45
  rebuild?: number;
50
46
  /**
51
47
  * The default number of milliseconds to wait before terminating the gc command.
52
- *
53
48
  * @default 0 No timeout.
54
49
  */
55
50
  gc?: number;
56
51
  };
57
52
  /**
58
53
  * Whether the dateilager binary client should enable tracing.
59
- *
60
54
  * @default false
61
55
  */
62
56
  tracing?: boolean;
@@ -114,19 +108,17 @@ export declare class DateiLagerBinaryClient {
114
108
  constructor(options: DateiLagerBinaryClientOptions);
115
109
  /**
116
110
  * Update objects in a project based on the differences in a local directory.
117
- *
118
111
  * @param project The id of the project.
119
112
  * @param directory The path of the directory to send updates from.
120
113
  * @param options Object of options.
121
114
  * @param options.timeout Number of milliseconds to wait before terminating the process.
122
- * @returns The latest project version or `null` if something went wrong.
115
+ * @returns The latest project version or `null` if something went wrong.
123
116
  */
124
117
  update(project: bigint, directory: string, options?: {
125
118
  timeout?: number;
126
119
  }): Promise<bigint | null>;
127
120
  /**
128
121
  * Rebuild the local filesystem.
129
- *
130
122
  * @param project The id of the project.
131
123
  * @param to The version of the project to rebuild the filesystem to.
132
124
  * @param directory The path of the directory to rebuild the filesystem at.
@@ -137,7 +129,7 @@ export declare class DateiLagerBinaryClient {
137
129
  * @param options.cacheDir Path where the cache directory is mounted.
138
130
  * @param options.matchInclude Set fileMatch to true if the written files are matched by this glob pattern
139
131
  * @param options.matchExclude Set fileMatch to false if the written files are matched by this glob pattern
140
- * @returns The latest project version or `null` if something went wrong.
132
+ * @returns The latest project version or `null` if something went wrong.
141
133
  */
142
134
  rebuild(project: bigint, to: bigint | null, directory: string, options?: {
143
135
  timeout?: number;
@@ -44,12 +44,11 @@ export class DateiLagerBinaryClient {
44
44
  }
45
45
  /**
46
46
  * Update objects in a project based on the differences in a local directory.
47
- *
48
47
  * @param project The id of the project.
49
48
  * @param directory The path of the directory to send updates from.
50
49
  * @param options Object of options.
51
50
  * @param options.timeout Number of milliseconds to wait before terminating the process.
52
- * @returns The latest project version or `null` if something went wrong.
51
+ * @returns The latest project version or `null` if something went wrong.
53
52
  */
54
53
  async update(project, directory, options) {
55
54
  return await trace("dateilager-binary-client.update", {
@@ -68,7 +67,6 @@ export class DateiLagerBinaryClient {
68
67
  }
69
68
  /**
70
69
  * Rebuild the local filesystem.
71
- *
72
70
  * @param project The id of the project.
73
71
  * @param to The version of the project to rebuild the filesystem to.
74
72
  * @param directory The path of the directory to rebuild the filesystem at.
@@ -79,7 +77,7 @@ export class DateiLagerBinaryClient {
79
77
  * @param options.cacheDir Path where the cache directory is mounted.
80
78
  * @param options.matchInclude Set fileMatch to true if the written files are matched by this glob pattern
81
79
  * @param options.matchExclude Set fileMatch to false if the written files are matched by this glob pattern
82
- * @returns The latest project version or `null` if something went wrong.
80
+ * @returns The latest project version or `null` if something went wrong.
83
81
  */
84
82
  async rebuild(project, to, directory, options) {
85
83
  return await trace("dateilager-binary-client.rebuild", {
@@ -201,7 +199,7 @@ export class DateiLagerBinaryClient {
201
199
  }
202
200
  const subprocess = execa(this._options.command, baseArgs.concat(args), {
203
201
  cwd,
204
- cleanup: false,
202
+ cleanup: false, // don't terminate this subprocess process eagerly when the parent process is terminated, which is execa's default behaviour. we use graceful shutdown gadget-side to give running operations a chance to complete, and we don't want to terminate them prematurely
205
203
  env: { DL_TOKEN: await this._options.token() },
206
204
  });
207
205
  if (this._options.logger && subprocess.stderr) {
@@ -1 +1 @@
1
- {"version":3,"file":"binary-client.js","sourceRoot":"","sources":["../../src/binary-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAyH7C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAIjC;;OAEG;IACH,YAAmB,OAAsC;QANzD,gBAAgB;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,EAAE,CAAC,CAAC;iBAC1E;YACH,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { context, propagation } from \"@opentelemetry/api\";\nimport type { ExecaReturnValue } from \"execa\";\nimport execa from \"execa\";\nimport fs from \"fs/promises\";\nimport readline from \"readline\";\nimport { trace } from \"./internal/telemetry\";\n\n/**\n * Options for {@link DateiLagerBinaryClient}.\n */\nexport interface DateiLagerBinaryClientOptions {\n /**\n * The address of the dateilager server.\n */\n server: {\n /**\n * The host of the dateilager server.\n */\n host: string;\n\n /**\n * The port of the dateilager server.\n */\n port?: number;\n\n /**\n * The GRPC headless service hostname, used for load balancing across multiple servers.\n */\n headlessHost?: string;\n };\n\n /**\n * The token that will be sent as authorization metadata to the dateilager server.\n */\n token: string | (() => Promise<string>);\n\n /**\n * The path to the dateilager-client executable.\n *\n * @default \"dateilager-client\"\n */\n command?: string;\n\n /**\n * The default number of milliseconds to wait before terminating any command.\n *\n * @default 0 No timeout.\n */\n timeout?:\n | number\n | {\n /**\n * The default number of milliseconds to wait before terminating the update command.\n *\n * @default 0 No timeout.\n */\n update?: number;\n\n /**\n * The default number of milliseconds to wait before terminating the rebuild command.\n *\n * @default 0 No timeout.\n */\n rebuild?: number;\n\n /**\n * The default number of milliseconds to wait before terminating the gc command.\n *\n * @default 0 No timeout.\n */\n gc?: number;\n };\n\n /**\n * Whether the dateilager binary client should enable tracing.\n *\n * @default false\n */\n tracing?: boolean;\n\n /**\n * Logging configuration.\n */\n logger?: {\n /**\n * The log level to pass to the dateilager binary client.\n */\n level: \"debug\" | \"info\" | \"warn\" | \"error\";\n\n /**\n * The function that will be called when the dateilager binary client logs something.\n */\n log: (level: \"debug\" | \"info\" | \"warn\" | \"error\", msg: string, fields: Record<string, unknown>) => void;\n };\n}\n\n/**\n * The version of the filesystem after the call to rebuild.\n *\n * If a file pattern was included then patternDetected can be used to know if that filepattern was seen while rebuilding.\n */\nexport interface RebuildResult {\n /**\n * Filesystem version.\n */\n version: bigint;\n /**\n * Files updated by the rebuild operation.\n */\n count: number;\n /**\n * Whether or not the file match was detected.\n */\n fileMatch: boolean;\n}\n\n/**\n * The Result from calling the Dateilager Garbage Compiler\n */\nexport interface GCResult {\n /**\n * The number of records garbage collected\n */\n count: number;\n}\n\n/**\n * A version of the DateiLager client that uses the compiled binary client instead of the Javascript one.\n *\n * Useful for working directly with a real filesystem instead of in memory objects.\n */\nexport class DateiLagerBinaryClient {\n /** @internal */\n private readonly _options;\n\n /**\n * @param options An object with {@link DateiLagerBinaryClientOptions options}.\n */\n public constructor(options: DateiLagerBinaryClientOptions) {\n this._options = {\n host: options.server.host,\n port: options.server.port ?? 5051,\n headlessHost: options.server.headlessHost,\n token: typeof options.token === \"string\" ? () => Promise.resolve(options.token as string) : options.token,\n command: options.command ?? \"dateilager-client\",\n timeout:\n typeof options.timeout === \"number\"\n ? {\n update: options.timeout,\n rebuild: options.timeout,\n gc: options.timeout,\n }\n : {\n update: 0,\n rebuild: 0,\n gc: 0,\n ...options.timeout,\n },\n tracing: options.tracing ?? false,\n logger: options.logger,\n };\n }\n\n /**\n * Update objects in a project based on the differences in a local directory.\n *\n * @param project The id of the project.\n * @param directory The path of the directory to send updates from.\n * @param options Object of options.\n * @param options.timeout Number of milliseconds to wait before terminating the process.\n * @returns The latest project version or `null` if something went wrong.\n */\n public async update(project: bigint, directory: string, options?: { timeout?: number }): Promise<bigint | null> {\n return await trace(\n \"dateilager-binary-client.update\",\n {\n attributes: {\n \"dl.project\": String(project),\n \"dl.directory\": directory,\n },\n },\n async () => {\n const args = [\"--dir\", String(directory), \"--project\", String(project)];\n const result = await this._call(\"update\", args, directory, options);\n\n if (result.stdout == \"-1\") {\n return null;\n }\n\n return BigInt(result.stdout);\n }\n );\n }\n\n /**\n * Rebuild the local filesystem.\n *\n * @param project The id of the project.\n * @param to The version of the project to rebuild the filesystem to.\n * @param directory The path of the directory to rebuild the filesystem at.\n * @param options Object of options.\n * @param options.timeout Number of milliseconds to wait before terminating the process.\n * @param options.ignores The paths to ignore when rebuilding the FS.\n * @param options.summarize Should produce the summary file after rebuilding.\n * @param options.cacheDir Path where the cache directory is mounted.\n * @param options.matchInclude Set fileMatch to true if the written files are matched by this glob pattern\n * @param options.matchExclude Set fileMatch to false if the written files are matched by this glob pattern\n * @returns The latest project version or `null` if something went wrong.\n */\n public async rebuild(\n project: bigint,\n to: bigint | null,\n directory: string,\n options?: {\n timeout?: number;\n ignores?: string[];\n summarize?: boolean;\n cacheDir?: string;\n matchInclude?: string;\n matchExclude?: string;\n }\n ): Promise<RebuildResult> {\n return await trace(\n \"dateilager-binary-client.rebuild\",\n {\n attributes: {\n \"dl.project\": String(project),\n \"dl.to\": String(to),\n \"dl.directory\": directory,\n },\n },\n async () => {\n await fs.mkdir(directory, { recursive: true });\n\n const args = [\"--dir\", directory];\n if (to) {\n args.push(\"--to\", String(to));\n }\n\n if (options?.ignores) {\n args.push(\"--ignores\", options.ignores.join(\",\"));\n }\n\n if (options?.summarize === false) {\n args.push(\"--summarize=false\");\n }\n\n if (options?.cacheDir) {\n args.push(`--cachedir=${options.cacheDir}`);\n }\n\n if (options?.matchInclude) {\n args.push(`--matchinclude=${options.matchInclude}`);\n }\n\n if (options?.matchExclude) {\n args.push(`--matchexclude=${options.matchExclude}`);\n }\n\n args.push(\"--project\", String(project), \"--dir\", directory);\n const result = await this._call(\"rebuild\", args, directory, options);\n const parsed = JSON.parse(result.stdout) as { version: number; count: number; fileMatch: boolean };\n return { version: BigInt(parsed.version), count: parsed.count, fileMatch: parsed.fileMatch };\n }\n );\n }\n\n /**\n * @param sample sample size of cleanup\n * @param keep The amount of records to keep\n * @param from Where to start cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcRandomProjects(sample: number, keep: number, from?: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"random-projects\",\n \"dl.keep\": String(keep),\n \"dl.from\": String(from),\n \"dl.sample\": String(sample),\n },\n },\n async () => {\n const args = [\"--mode\", \"random-projects\", \"--keep\", String(keep), \"--sample\", String(sample)];\n\n if (from) args.push(\"--from\", String(from));\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /**\n *\n * @param project The selected project to cleanup\n * @param keep The amount of records to keep\n * @param from Where to start cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcProject(project: number, keep: number, from?: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"project\",\n \"dl.keep\": String(keep),\n \"dl.from\": String(from),\n },\n },\n async () => {\n const args = [\"--mode\", \"project\", \"--keep\", String(keep), \"--project\", String(project)];\n\n if (from) args.push(\"--from\", String(from));\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /**\n *\n * @param sample sample size of cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcContents(sample: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"contents\",\n \"dl.sample\": String(sample),\n },\n },\n async () => {\n const args = [\"--mode\", \"contents\", \"--sample\", String(sample)];\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /** @internal */\n private async _call(\n method: \"update\" | \"rebuild\" | \"gc\",\n args: string[],\n cwd?: string,\n options?: { timeout?: number }\n ): Promise<ExecaReturnValue> {\n const baseArgs = [method, \"--host\", this._options.host, \"--port\", String(this._options.port), \"--log-encoding\", \"json\"];\n\n if (this._options.logger) {\n baseArgs.push(\"--log-level\", this._options.logger.level);\n }\n\n if (this._options.headlessHost) {\n baseArgs.push(\"--headless-host\", this._options.headlessHost);\n }\n\n const timeout = options?.timeout ?? this._options.timeout[method];\n baseArgs.push(\"--timeout\", String(timeout));\n\n if (this._options.tracing) {\n const carrier = {};\n propagation.inject(context.active(), carrier);\n const otelContext = JSON.stringify(carrier);\n\n baseArgs.push(\"--tracing\", \"--otel-context\", otelContext);\n }\n const subprocess = execa(this._options.command, baseArgs.concat(args), {\n cwd,\n cleanup: false, // don't terminate this subprocess process eagerly when the parent process is terminated, which is execa's default behaviour. we use graceful shutdown gadget-side to give running operations a chance to complete, and we don't want to terminate them prematurely\n env: { DL_TOKEN: await this._options.token() },\n });\n\n if (this._options.logger && subprocess.stderr) {\n readline.createInterface(subprocess.stderr).on(\"line\", (line) => {\n try {\n // we purposefully extract and ignore the `ts` field\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { level, msg, ts, ...fields } = JSON.parse(line) as {\n [key: string]: unknown;\n level: \"debug\" | \"info\" | \"warn\" | \"error\";\n msg: string;\n ts: string | number;\n };\n\n this._options.logger?.log(level, msg, fields);\n } catch (error) {\n this._options.logger?.log(\"warn\", \"failed to log line\", { error, line });\n }\n });\n }\n\n return subprocess;\n }\n}\n"]}
1
+ {"version":3,"file":"binary-client.js","sourceRoot":"","sources":["../../src/binary-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAmH7C;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IAIjC;;OAEG;IACH,YAAmB,OAAsC;QANzD,gBAAgB;QACC;;;;;WAAS;QAMxB,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;YACzB,IA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CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { context, propagation } from \"@opentelemetry/api\";\nimport type { ExecaReturnValue } from \"execa\";\nimport execa from \"execa\";\nimport fs from \"fs/promises\";\nimport readline from \"readline\";\nimport { trace } from \"./internal/telemetry\";\n\n/**\n * Options for {@link DateiLagerBinaryClient}.\n */\nexport interface DateiLagerBinaryClientOptions {\n /**\n * The address of the dateilager server.\n */\n server: {\n /**\n * The host of the dateilager server.\n */\n host: string;\n\n /**\n * The port of the dateilager server.\n */\n port?: number;\n\n /**\n * The GRPC headless service hostname, used for load balancing across multiple servers.\n */\n headlessHost?: string;\n };\n\n /**\n * The token that will be sent as authorization metadata to the dateilager server.\n */\n token: string | (() => Promise<string>);\n\n /**\n * The path to the dateilager-client executable.\n * @default \"dateilager-client\"\n */\n command?: string;\n\n /**\n * The default number of milliseconds to wait before terminating any command.\n * @default 0 No timeout.\n */\n timeout?:\n | number\n | {\n /**\n * The default number of milliseconds to wait before terminating the update command.\n * @default 0 No timeout.\n */\n update?: number;\n\n /**\n * The default number of milliseconds to wait before terminating the rebuild command.\n * @default 0 No timeout.\n */\n rebuild?: number;\n\n /**\n * The default number of milliseconds to wait before terminating the gc command.\n * @default 0 No timeout.\n */\n gc?: number;\n };\n\n /**\n * Whether the dateilager binary client should enable tracing.\n * @default false\n */\n tracing?: boolean;\n\n /**\n * Logging configuration.\n */\n logger?: {\n /**\n * The log level to pass to the dateilager binary client.\n */\n level: \"debug\" | \"info\" | \"warn\" | \"error\";\n\n /**\n * The function that will be called when the dateilager binary client logs something.\n */\n log: (level: \"debug\" | \"info\" | \"warn\" | \"error\", msg: string, fields: Record<string, unknown>) => void;\n };\n}\n\n/**\n * The version of the filesystem after the call to rebuild.\n *\n * If a file pattern was included then patternDetected can be used to know if that filepattern was seen while rebuilding.\n */\nexport interface RebuildResult {\n /**\n * Filesystem version.\n */\n version: bigint;\n /**\n * Files updated by the rebuild operation.\n */\n count: number;\n /**\n * Whether or not the file match was detected.\n */\n fileMatch: boolean;\n}\n\n/**\n * The Result from calling the Dateilager Garbage Compiler\n */\nexport interface GCResult {\n /**\n * The number of records garbage collected\n */\n count: number;\n}\n\n/**\n * A version of the DateiLager client that uses the compiled binary client instead of the Javascript one.\n *\n * Useful for working directly with a real filesystem instead of in memory objects.\n */\nexport class DateiLagerBinaryClient {\n /** @internal */\n private readonly _options;\n\n /**\n * @param options An object with {@link DateiLagerBinaryClientOptions options}.\n */\n public constructor(options: DateiLagerBinaryClientOptions) {\n this._options = {\n host: options.server.host,\n port: options.server.port ?? 5051,\n headlessHost: options.server.headlessHost,\n token: typeof options.token === \"string\" ? () => Promise.resolve(options.token as string) : options.token,\n command: options.command ?? \"dateilager-client\",\n timeout:\n typeof options.timeout === \"number\"\n ? {\n update: options.timeout,\n rebuild: options.timeout,\n gc: options.timeout,\n }\n : {\n update: 0,\n rebuild: 0,\n gc: 0,\n ...options.timeout,\n },\n tracing: options.tracing ?? false,\n logger: options.logger,\n };\n }\n\n /**\n * Update objects in a project based on the differences in a local directory.\n * @param project The id of the project.\n * @param directory The path of the directory to send updates from.\n * @param options Object of options.\n * @param options.timeout Number of milliseconds to wait before terminating the process.\n * @returns The latest project version or `null` if something went wrong.\n */\n public async update(project: bigint, directory: string, options?: { timeout?: number }): Promise<bigint | null> {\n return await trace(\n \"dateilager-binary-client.update\",\n {\n attributes: {\n \"dl.project\": String(project),\n \"dl.directory\": directory,\n },\n },\n async () => {\n const args = [\"--dir\", String(directory), \"--project\", String(project)];\n const result = await this._call(\"update\", args, directory, options);\n\n if (result.stdout == \"-1\") {\n return null;\n }\n\n return BigInt(result.stdout);\n }\n );\n }\n\n /**\n * Rebuild the local filesystem.\n * @param project The id of the project.\n * @param to The version of the project to rebuild the filesystem to.\n * @param directory The path of the directory to rebuild the filesystem at.\n * @param options Object of options.\n * @param options.timeout Number of milliseconds to wait before terminating the process.\n * @param options.ignores The paths to ignore when rebuilding the FS.\n * @param options.summarize Should produce the summary file after rebuilding.\n * @param options.cacheDir Path where the cache directory is mounted.\n * @param options.matchInclude Set fileMatch to true if the written files are matched by this glob pattern\n * @param options.matchExclude Set fileMatch to false if the written files are matched by this glob pattern\n * @returns The latest project version or `null` if something went wrong.\n */\n public async rebuild(\n project: bigint,\n to: bigint | null,\n directory: string,\n options?: {\n timeout?: number;\n ignores?: string[];\n summarize?: boolean;\n cacheDir?: string;\n matchInclude?: string;\n matchExclude?: string;\n }\n ): Promise<RebuildResult> {\n return await trace(\n \"dateilager-binary-client.rebuild\",\n {\n attributes: {\n \"dl.project\": String(project),\n \"dl.to\": String(to),\n \"dl.directory\": directory,\n },\n },\n async () => {\n await fs.mkdir(directory, { recursive: true });\n\n const args = [\"--dir\", directory];\n if (to) {\n args.push(\"--to\", String(to));\n }\n\n if (options?.ignores) {\n args.push(\"--ignores\", options.ignores.join(\",\"));\n }\n\n if (options?.summarize === false) {\n args.push(\"--summarize=false\");\n }\n\n if (options?.cacheDir) {\n args.push(`--cachedir=${options.cacheDir}`);\n }\n\n if (options?.matchInclude) {\n args.push(`--matchinclude=${options.matchInclude}`);\n }\n\n if (options?.matchExclude) {\n args.push(`--matchexclude=${options.matchExclude}`);\n }\n\n args.push(\"--project\", String(project), \"--dir\", directory);\n const result = await this._call(\"rebuild\", args, directory, options);\n const parsed = JSON.parse(result.stdout) as { version: number; count: number; fileMatch: boolean };\n return { version: BigInt(parsed.version), count: parsed.count, fileMatch: parsed.fileMatch };\n }\n );\n }\n\n /**\n * @param sample sample size of cleanup\n * @param keep The amount of records to keep\n * @param from Where to start cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcRandomProjects(sample: number, keep: number, from?: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"random-projects\",\n \"dl.keep\": String(keep),\n \"dl.from\": String(from),\n \"dl.sample\": String(sample),\n },\n },\n async () => {\n const args = [\"--mode\", \"random-projects\", \"--keep\", String(keep), \"--sample\", String(sample)];\n\n if (from) args.push(\"--from\", String(from));\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /**\n *\n * @param project The selected project to cleanup\n * @param keep The amount of records to keep\n * @param from Where to start cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcProject(project: number, keep: number, from?: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"project\",\n \"dl.keep\": String(keep),\n \"dl.from\": String(from),\n },\n },\n async () => {\n const args = [\"--mode\", \"project\", \"--keep\", String(keep), \"--project\", String(project)];\n\n if (from) args.push(\"--from\", String(from));\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /**\n *\n * @param sample sample size of cleanup\n * @param options dict options passed\n * @param options.timeout timeout limit for the request\n */\n public async gcContents(sample: number, options?: { timeout?: number }): Promise<GCResult> {\n return await trace(\n \"dateilager-binary-client.gc\",\n {\n attributes: {\n \"db.mode\": \"contents\",\n \"dl.sample\": String(sample),\n },\n },\n async () => {\n const args = [\"--mode\", \"contents\", \"--sample\", String(sample)];\n\n const result = await this._call(\"gc\", args, undefined, options);\n const parsed = JSON.parse(result.stdout) as { count: number };\n return { count: parsed.count };\n }\n );\n }\n\n /** @internal */\n private async _call(\n method: \"update\" | \"rebuild\" | \"gc\",\n args: string[],\n cwd?: string,\n options?: { timeout?: number }\n ): Promise<ExecaReturnValue> {\n const baseArgs = [method, \"--host\", this._options.host, \"--port\", String(this._options.port), \"--log-encoding\", \"json\"];\n\n if (this._options.logger) {\n baseArgs.push(\"--log-level\", this._options.logger.level);\n }\n\n if (this._options.headlessHost) {\n baseArgs.push(\"--headless-host\", this._options.headlessHost);\n }\n\n const timeout = options?.timeout ?? this._options.timeout[method];\n baseArgs.push(\"--timeout\", String(timeout));\n\n if (this._options.tracing) {\n const carrier = {};\n propagation.inject(context.active(), carrier);\n const otelContext = JSON.stringify(carrier);\n\n baseArgs.push(\"--tracing\", \"--otel-context\", otelContext);\n }\n const subprocess = execa(this._options.command, baseArgs.concat(args), {\n cwd,\n cleanup: false, // don't terminate this subprocess process eagerly when the parent process is terminated, which is execa's default behaviour. we use graceful shutdown gadget-side to give running operations a chance to complete, and we don't want to terminate them prematurely\n env: { DL_TOKEN: await this._options.token() },\n });\n\n if (this._options.logger && subprocess.stderr) {\n readline.createInterface(subprocess.stderr).on(\"line\", (line) => {\n try {\n // we purposefully extract and ignore the `ts` field\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { level, msg, ts, ...fields } = JSON.parse(line) as {\n [key: string]: unknown;\n level: \"debug\" | \"info\" | \"warn\" | \"error\";\n msg: string;\n ts: string | number;\n };\n\n this._options.logger?.log(level, msg, fields);\n } catch (error) {\n this._options.logger?.log(\"warn\", \"failed to log line\", { error, line });\n }\n });\n }\n\n return subprocess;\n }\n}\n"]}
@@ -26,13 +26,11 @@ export interface DateiLagerGrpcClientOptions {
26
26
  token: string | (() => Promise<string>);
27
27
  /**
28
28
  * Options that will be passed to the underlying grpc client constructor.
29
- *
30
29
  * @see ClientOptions
31
30
  */
32
31
  grpcClientOptions?: ClientOptions;
33
32
  /**
34
33
  * Options that will be passed to every remote procedure call.
35
- *
36
34
  * @see RpcOptions
37
35
  */
38
36
  rpcOptions?: RpcOptions | (() => RpcOptions | undefined);
@@ -47,7 +45,6 @@ export declare class DateiLagerGrpcClient {
47
45
  /**
48
46
  * The library used to interact with GRPC creates connections lazily, this constructor will not
49
47
  * raise an error even if there is no service running at {@link DateiLagerGrpcClientOptions.server server}.
50
- *
51
48
  * @param options Grpc client options.
52
49
  */
53
50
  constructor(options: DateiLagerGrpcClientOptions);
@@ -57,7 +54,6 @@ export declare class DateiLagerGrpcClient {
57
54
  close(): void;
58
55
  /**
59
56
  * Create a new project.
60
- *
61
57
  * @param project The id of the project.
62
58
  * @param packPatterns The paths to pack.
63
59
  * @param template The id of the project to start from.
@@ -65,19 +61,17 @@ export declare class DateiLagerGrpcClient {
65
61
  newProject(project: bigint, packPatterns: string[], template?: bigint): Promise<void>;
66
62
  /**
67
63
  * Delete a project.
68
- *
69
64
  * @param project The id of the project.
70
65
  */
71
66
  deleteProject(project: bigint): Promise<void>;
72
67
  /**
73
68
  * List objects.
74
- *
75
- * @param project The id of the project.
76
- * @param path The path to list objects under.
77
- * @param ignores The paths under {@link path} to ignore.
78
- * @param from The project version to start from.
79
- * @param to The project version to end at.
80
- * @returns A stream of objects.
69
+ * @param project The id of the project.
70
+ * @param path The path to list objects under.
71
+ * @param ignores The paths under {@link path} to ignore.
72
+ * @param from The project version to start from.
73
+ * @param to The project version to end at.
74
+ * @returns A stream of objects.
81
75
  * @yields An object from the stream.
82
76
  * @example
83
77
  * for await (const object of client.listObjects(1n, "")) {
@@ -88,13 +82,12 @@ export declare class DateiLagerGrpcClient {
88
82
  listObjects(project: bigint, path: string, ignores?: string[], from?: bigint, to?: bigint): AsyncGenerator<Objekt, void>;
89
83
  /**
90
84
  * Get objects.
91
- *
92
85
  * @param project The id of the project.
93
86
  * @param path The path to get objects under.
94
87
  * @param ignores The paths under {@link path} to ignore.
95
88
  * @param from The project version to start from.
96
89
  * @param to The project version to end at.
97
- * @returns All the objects under {@link path}.
90
+ * @returns All the objects under {@link path}.
98
91
  * @example
99
92
  * const response = await client.getObjects(1n, "");
100
93
  * for (const object of response.objects) {
@@ -105,39 +98,34 @@ export declare class DateiLagerGrpcClient {
105
98
  getObjects(project: bigint, path: string, ignores?: string[], from?: bigint, to?: bigint): Promise<GetUnaryResponse>;
106
99
  /**
107
100
  * Get an object.
108
- *
109
101
  * @param project The id of the project.
110
102
  * @param path The path of the object.
111
103
  * @param from The project version to start from.
112
104
  * @param to The project version to end at.
113
- * @returns The object at the given path or undefined if it does not exist.
105
+ * @returns The object at the given path or undefined if it does not exist.
114
106
  */
115
107
  getObject(project: bigint, path: string, from?: bigint, to?: bigint): Promise<Objekt | undefined>;
116
108
  /**
117
109
  * Update objects.
118
- *
119
110
  * @param project The id of the project.
120
- * @returns An {@link UpdateInputStream} to send objects to update.
111
+ * @returns An {@link UpdateInputStream} to send objects to update.
121
112
  */
122
113
  updateObjects(project: bigint): UpdateInputStream;
123
114
  /**
124
115
  * Update an object.
125
- *
126
116
  * @param project The id of the project.
127
117
  * @param obj The object to update.
128
- * @returns The latest project version or `null` if something went wrong.
118
+ * @returns The latest project version or `null` if something went wrong.
129
119
  */
130
120
  updateObject(project: bigint, obj: Objekt): Promise<bigint | null>;
131
121
  /**
132
122
  * Rollback a project.
133
- *
134
123
  * @param project The id of the project.
135
124
  * @param version The version to rollback to.
136
125
  */
137
126
  rollbackProject(project: bigint, version: bigint): Promise<void>;
138
127
  /**
139
128
  * Snapshot the current state of the dateilager server.
140
- *
141
129
  * @returns All the projects on the dateilager server.
142
130
  * @throws If the dateilager server's DL_ENV environment variable is PROD.
143
131
  * @see DateiLagerGrpcClient.resetToSnapshotInDevOrTests
@@ -146,7 +134,6 @@ export declare class DateiLagerGrpcClient {
146
134
  /**
147
135
  * Reset the given projects to their respective versions and delete any remaining projects.
148
136
  * If no projects are provided, delete all projects.
149
- *
150
137
  * @param projects The projects to reset.
151
138
  * @throws If the dateilager server's DL_ENV environment variable is PROD.
152
139
  * @see DateiLagerGrpcClient.snapshotInDevOrTests
@@ -156,70 +143,61 @@ export declare class DateiLagerGrpcClient {
156
143
  * Clones the `source` projects changes (from `fromVersion` up to `toVersion`) to the `target` project.
157
144
  * This method assumes that it is always a one way clone from source to target, it does not take into account
158
145
  * the changes that have occurred in the `target` project.
159
- *
160
146
  * @param source The source project.
161
147
  * @param target The target project.
162
148
  * @param version The version of the source project to clone up to.
163
- * @returns The new version number of the target project.
149
+ * @returns The new version number of the target project.
164
150
  */
165
151
  cloneToProject(source: bigint, target: bigint, version: bigint): Promise<CloneToProjectResponse>;
166
152
  /**
167
153
  * GC project.
168
- *
169
154
  * @param project The project to GC.
170
155
  * @param keep The amount of versions since the latest that should be kept.
171
156
  * @param from The starting version to GC from.
172
- * @returns The amount of objects that were GC'd.
157
+ * @returns The amount of objects that were GC'd.
173
158
  */
174
159
  gcProject(project: bigint, keep: bigint, from?: bigint): Promise<bigint>;
175
160
  /**
176
161
  * GC random projects.
177
- *
178
162
  * @param sample The percentage of projects to sample from.
179
163
  * @param keep The amount of versions since the latest that should be kept.
180
164
  * @param from The starting version to GC from.
181
- * @returns The amount of objects that were GC'd.
165
+ * @returns The amount of objects that were GC'd.
182
166
  */
183
167
  gcRandomProjects(sample: number, keep: bigint, from?: bigint): Promise<bigint>;
184
168
  /**
185
169
  * GC contents.
186
- *
187
170
  * @param sample The percentage of projects to sample from.
188
- * @returns The amount of objects that were GC'd.
171
+ * @returns The amount of objects that were GC'd.
189
172
  */
190
173
  gcContents(sample: number): Promise<bigint>;
191
174
  }
192
175
  /**
193
176
  * Used to send a stream of objects to update.
194
- *
195
177
  * @see DateiLagerGrpcClient.updateObjects
196
178
  */
197
179
  declare class UpdateInputStream {
198
180
  constructor(project: bigint, call: ClientStreamingCall<UpdateRequest, UpdateResponse>, span: Span);
199
181
  /**
200
182
  * Send an object to update.
201
- *
202
183
  * @param obj The object to update.
203
184
  */
204
185
  send(obj: Objekt): Promise<void>;
205
186
  /**
206
187
  * Complete the update request.
207
- *
208
188
  * @returns The latest project version or `null` if something went wrong.
209
189
  */
210
190
  complete(): Promise<bigint | null>;
211
191
  }
212
192
  /**
213
193
  * Encode string object contents as an array of bytes.
214
- *
215
194
  * @param content The string to encode.
216
- * @returns The encoded content as an array of bytes.
195
+ * @returns The encoded content as an array of bytes.
217
196
  */
218
197
  export declare function encodeContent(content: string): Uint8Array;
219
198
  /**
220
199
  * Decode an array of bytes as an object's string contents.
221
- *
222
200
  * @param bytes The array of bytes to decode.
223
- * @returns The bytes decoded into a string.
201
+ * @returns The bytes decoded into a string.
224
202
  */
225
203
  export declare function decodeContent(bytes: Uint8Array | undefined): string;
@@ -16,7 +16,6 @@ export class DateiLagerGrpcClient {
16
16
  /**
17
17
  * The library used to interact with GRPC creates connections lazily, this constructor will not
18
18
  * raise an error even if there is no service running at {@link DateiLagerGrpcClientOptions.server server}.
19
- *
20
19
  * @param options Grpc client options.
21
20
  */
22
21
  constructor(options) {
@@ -71,7 +70,6 @@ export class DateiLagerGrpcClient {
71
70
  }
72
71
  /**
73
72
  * Create a new project.
74
- *
75
73
  * @param project The id of the project.
76
74
  * @param packPatterns The paths to pack.
77
75
  * @param template The id of the project to start from.
@@ -95,7 +93,6 @@ export class DateiLagerGrpcClient {
95
93
  }
96
94
  /**
97
95
  * Delete a project.
98
- *
99
96
  * @param project The id of the project.
100
97
  */
101
98
  async deleteProject(project) {
@@ -107,13 +104,12 @@ export class DateiLagerGrpcClient {
107
104
  }
108
105
  /**
109
106
  * List objects.
110
- *
111
- * @param project The id of the project.
112
- * @param path The path to list objects under.
113
- * @param ignores The paths under {@link path} to ignore.
114
- * @param from The project version to start from.
115
- * @param to The project version to end at.
116
- * @returns A stream of objects.
107
+ * @param project The id of the project.
108
+ * @param path The path to list objects under.
109
+ * @param ignores The paths under {@link path} to ignore.
110
+ * @param from The project version to start from.
111
+ * @param to The project version to end at.
112
+ * @returns A stream of objects.
117
113
  * @yields An object from the stream.
118
114
  * @example
119
115
  * for await (const object of client.listObjects(1n, "")) {
@@ -158,13 +154,12 @@ export class DateiLagerGrpcClient {
158
154
  }
159
155
  /**
160
156
  * Get objects.
161
- *
162
157
  * @param project The id of the project.
163
158
  * @param path The path to get objects under.
164
159
  * @param ignores The paths under {@link path} to ignore.
165
160
  * @param from The project version to start from.
166
161
  * @param to The project version to end at.
167
- * @returns All the objects under {@link path}.
162
+ * @returns All the objects under {@link path}.
168
163
  * @example
169
164
  * const response = await client.getObjects(1n, "");
170
165
  * for (const object of response.objects) {
@@ -188,12 +183,11 @@ export class DateiLagerGrpcClient {
188
183
  }
189
184
  /**
190
185
  * Get an object.
191
- *
192
186
  * @param project The id of the project.
193
187
  * @param path The path of the object.
194
188
  * @param from The project version to start from.
195
189
  * @param to The project version to end at.
196
- * @returns The object at the given path or undefined if it does not exist.
190
+ * @returns The object at the given path or undefined if it does not exist.
197
191
  */
198
192
  async getObject(project, path, from, to) {
199
193
  return await trace("dateilager-grpc-client.get-object", {
@@ -226,9 +220,8 @@ export class DateiLagerGrpcClient {
226
220
  }
227
221
  /**
228
222
  * Update objects.
229
- *
230
223
  * @param project The id of the project.
231
- * @returns An {@link UpdateInputStream} to send objects to update.
224
+ * @returns An {@link UpdateInputStream} to send objects to update.
232
225
  */
233
226
  updateObjects(project) {
234
227
  const parentContext = contextAPI.active();
@@ -242,10 +235,9 @@ export class DateiLagerGrpcClient {
242
235
  }
243
236
  /**
244
237
  * Update an object.
245
- *
246
238
  * @param project The id of the project.
247
239
  * @param obj The object to update.
248
- * @returns The latest project version or `null` if something went wrong.
240
+ * @returns The latest project version or `null` if something went wrong.
249
241
  */
250
242
  async updateObject(project, obj) {
251
243
  const stream = this.updateObjects(project);
@@ -254,7 +246,6 @@ export class DateiLagerGrpcClient {
254
246
  }
255
247
  /**
256
248
  * Rollback a project.
257
- *
258
249
  * @param project The id of the project.
259
250
  * @param version The version to rollback to.
260
251
  */
@@ -263,7 +254,6 @@ export class DateiLagerGrpcClient {
263
254
  }
264
255
  /**
265
256
  * Snapshot the current state of the dateilager server.
266
- *
267
257
  * @returns All the projects on the dateilager server.
268
258
  * @throws If the dateilager server's DL_ENV environment variable is PROD.
269
259
  * @see DateiLagerGrpcClient.resetToSnapshotInDevOrTests
@@ -275,7 +265,6 @@ export class DateiLagerGrpcClient {
275
265
  /**
276
266
  * Reset the given projects to their respective versions and delete any remaining projects.
277
267
  * If no projects are provided, delete all projects.
278
- *
279
268
  * @param projects The projects to reset.
280
269
  * @throws If the dateilager server's DL_ENV environment variable is PROD.
281
270
  * @see DateiLagerGrpcClient.snapshotInDevOrTests
@@ -287,11 +276,10 @@ export class DateiLagerGrpcClient {
287
276
  * Clones the `source` projects changes (from `fromVersion` up to `toVersion`) to the `target` project.
288
277
  * This method assumes that it is always a one way clone from source to target, it does not take into account
289
278
  * the changes that have occurred in the `target` project.
290
- *
291
279
  * @param source The source project.
292
280
  * @param target The target project.
293
281
  * @param version The version of the source project to clone up to.
294
- * @returns The new version number of the target project.
282
+ * @returns The new version number of the target project.
295
283
  */
296
284
  async cloneToProject(source, target, version) {
297
285
  return await trace("dateilager-grpc-client.clone-to-project", {
@@ -307,11 +295,10 @@ export class DateiLagerGrpcClient {
307
295
  }
308
296
  /**
309
297
  * GC project.
310
- *
311
298
  * @param project The project to GC.
312
299
  * @param keep The amount of versions since the latest that should be kept.
313
300
  * @param from The starting version to GC from.
314
- * @returns The amount of objects that were GC'd.
301
+ * @returns The amount of objects that were GC'd.
315
302
  */
316
303
  async gcProject(project, keep, from) {
317
304
  const call = await this._client.gcProject({
@@ -323,11 +310,10 @@ export class DateiLagerGrpcClient {
323
310
  }
324
311
  /**
325
312
  * GC random projects.
326
- *
327
313
  * @param sample The percentage of projects to sample from.
328
314
  * @param keep The amount of versions since the latest that should be kept.
329
315
  * @param from The starting version to GC from.
330
- * @returns The amount of objects that were GC'd.
316
+ * @returns The amount of objects that were GC'd.
331
317
  */
332
318
  async gcRandomProjects(sample, keep, from) {
333
319
  const call = await this._client.gcRandomProjects({
@@ -339,9 +325,8 @@ export class DateiLagerGrpcClient {
339
325
  }
340
326
  /**
341
327
  * GC contents.
342
- *
343
328
  * @param sample The percentage of projects to sample from.
344
- * @returns The amount of objects that were GC'd.
329
+ * @returns The amount of objects that were GC'd.
345
330
  */
346
331
  async gcContents(sample) {
347
332
  const call = await this._client.gcContents({
@@ -352,7 +337,6 @@ export class DateiLagerGrpcClient {
352
337
  }
353
338
  /**
354
339
  * Used to send a stream of objects to update.
355
- *
356
340
  * @see DateiLagerGrpcClient.updateObjects
357
341
  */
358
342
  class UpdateInputStream {
@@ -384,7 +368,6 @@ class UpdateInputStream {
384
368
  }
385
369
  /**
386
370
  * Send an object to update.
387
- *
388
371
  * @param obj The object to update.
389
372
  */
390
373
  async send(obj) {
@@ -401,7 +384,6 @@ class UpdateInputStream {
401
384
  }
402
385
  /**
403
386
  * Complete the update request.
404
- *
405
387
  * @returns The latest project version or `null` if something went wrong.
406
388
  */
407
389
  async complete() {
@@ -418,9 +400,8 @@ class UpdateInputStream {
418
400
  const encoder = new TextEncoder();
419
401
  /**
420
402
  * Encode string object contents as an array of bytes.
421
- *
422
403
  * @param content The string to encode.
423
- * @returns The encoded content as an array of bytes.
404
+ * @returns The encoded content as an array of bytes.
424
405
  */
425
406
  export function encodeContent(content) {
426
407
  return encoder.encode(content);
@@ -428,9 +409,8 @@ export function encodeContent(content) {
428
409
  const decoder = new TextDecoder();
429
410
  /**
430
411
  * Decode an array of bytes as an object's string contents.
431
- *
432
412
  * @param bytes The array of bytes to decode.
433
- * @returns The bytes decoded into a string.
413
+ * @returns The bytes decoded into a string.
434
414
  */
435
415
  export function decodeContent(bytes) {
436
416
  return decoder.decode(bytes);