@usecontextlayer/ctxe 0.5.30 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bee62857-a9a3-500d-b035-dc7b7a5eb6f9")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5506b6a8-6650-5a43-9cf5-9db6fb5eb4bf")}catch(e){}}();
4
4
  import { createRequire } from "node:module";
5
5
  import * as Sentry from "@sentry/node";
6
6
  import { lstat, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
@@ -4362,7 +4362,7 @@ function normalizedKey(event) {
4362
4362
 
4363
4363
  //#endregion
4364
4364
  //#region package.json
4365
- var version$1 = "0.5.30";
4365
+ var version$1 = "0.7.0";
4366
4366
 
4367
4367
  //#endregion
4368
4368
  //#region sentry.ts
@@ -64889,7 +64889,7 @@ var require_proper_lockfile = /* @__PURE__ */ __commonJSMin(((exports, module) =
64889
64889
  }));
64890
64890
 
64891
64891
  //#endregion
64892
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/query.js
64892
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/query.js
64893
64893
  var import__2020 = require__2020();
64894
64894
  var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
64895
64895
  var import_proper_lockfile = /* @__PURE__ */ __toESM(require_proper_lockfile(), 1);
@@ -65028,7 +65028,7 @@ function cachedError(xs) {
65028
65028
  }
65029
65029
 
65030
65030
  //#endregion
65031
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/errors.js
65031
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/errors.js
65032
65032
  var PostgresError = class extends Error {
65033
65033
  constructor(x) {
65034
65034
  super(x.message);
@@ -65073,7 +65073,7 @@ function notSupported(x) {
65073
65073
  }
65074
65074
 
65075
65075
  //#endregion
65076
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/types.js
65076
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/types.js
65077
65077
  const types = {
65078
65078
  string: {
65079
65079
  to: 25,
@@ -65353,7 +65353,7 @@ const kebab = { ...toKebab };
65353
65353
  kebab.column.to = fromKebab;
65354
65354
 
65355
65355
  //#endregion
65356
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/result.js
65356
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/result.js
65357
65357
  var Result = class extends Array {
65358
65358
  constructor() {
65359
65359
  super();
@@ -65386,7 +65386,7 @@ var Result = class extends Array {
65386
65386
  };
65387
65387
 
65388
65388
  //#endregion
65389
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/queue.js
65389
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/queue.js
65390
65390
  var queue_default = Queue;
65391
65391
  function Queue(initial = []) {
65392
65392
  let xs = initial.slice();
@@ -65412,7 +65412,7 @@ function Queue(initial = []) {
65412
65412
  }
65413
65413
 
65414
65414
  //#endregion
65415
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/bytes.js
65415
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/bytes.js
65416
65416
  const size = 256;
65417
65417
  let buffer = Buffer.allocUnsafe(size);
65418
65418
  const messages = "BCcDdEFfHPpQSX".split("").reduce((acc, x) => {
@@ -65485,7 +65485,7 @@ function reset() {
65485
65485
  }
65486
65486
 
65487
65487
  //#endregion
65488
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/connection.js
65488
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/connection.js
65489
65489
  var connection_default = Connection;
65490
65490
  let uid = 1;
65491
65491
  const Sync = b().S().end();
@@ -65622,6 +65622,12 @@ function Connection(options, queues = {}, { onopen = noop$1, onend = noop$1, onc
65622
65622
  return true;
65623
65623
  }
65624
65624
  function nextWrite(fn) {
65625
+ if (socket === null) {
65626
+ nextWriteTimer !== null && clearImmediate(nextWriteTimer);
65627
+ chunk = nextWriteTimer = null;
65628
+ fn && fn(Errors.connection("CONNECTION_CLOSED", options, socket));
65629
+ return false;
65630
+ }
65625
65631
  const x = socket.write(chunk, fn);
65626
65632
  nextWriteTimer !== null && clearImmediate(nextWriteTimer);
65627
65633
  chunk = nextWriteTimer = null;
@@ -65718,6 +65724,7 @@ function Connection(options, queues = {}, { onopen = noop$1, onend = noop$1, onc
65718
65724
  }
65719
65725
  function errored(err) {
65720
65726
  stream && (stream.destroy(err), stream = null);
65727
+ final && (final(err), final = null);
65721
65728
  query && queryError(query, err);
65722
65729
  initial && (queryError(initial, err), initial = null);
65723
65730
  }
@@ -65977,6 +65984,8 @@ function Connection(options, queues = {}, { onopen = noop$1, onend = noop$1, onc
65977
65984
  if (query) {
65978
65985
  (query.cursorFn || query.describeFirst) && write(Sync);
65979
65986
  errorResponse = Errors.postgres(parseError(x));
65987
+ stream && (stream.destroy(errorResponse), stream = null);
65988
+ final && (final(errorResponse), final = null);
65980
65989
  } else errored(Errors.postgres(parseError(x)));
65981
65990
  }
65982
65991
  function retry(q, error) {
@@ -66162,7 +66171,7 @@ function timer(fn, seconds) {
66162
66171
  }
66163
66172
 
66164
66173
  //#endregion
66165
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/subscribe.js
66174
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/subscribe.js
66166
66175
  const noop = () => {};
66167
66176
  function Subscribe(postgres, options) {
66168
66177
  const subscribers = /* @__PURE__ */ new Map(), slot = "postgresjs_" + Math.random().toString(36).slice(2), state = {};
@@ -66369,7 +66378,7 @@ function parseEvent(x) {
66369
66378
  }
66370
66379
 
66371
66380
  //#endregion
66372
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/large.js
66381
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/large.js
66373
66382
  function largeObject(sql, oid, mode = 393216) {
66374
66383
  return new Promise(async (resolve, reject) => {
66375
66384
  await sql.begin(async (sql) => {
@@ -66427,7 +66436,7 @@ function largeObject(sql, oid, mode = 393216) {
66427
66436
  }
66428
66437
 
66429
66438
  //#endregion
66430
- //#region ../../node_modules/.pnpm/postgres@3.4.9/node_modules/postgres/src/index.js
66439
+ //#region ../../node_modules/.pnpm/postgres@3.4.9_patch_hash=3c6ad14249311b1009d0b5dc63a6223155b601ddf5a35abede25e8e10d200935/node_modules/postgres/src/index.js
66431
66440
  Object.assign(Postgres, {
66432
66441
  PostgresError,
66433
66442
  toPascal,
@@ -69110,6 +69119,19 @@ var BaseAPITimeoutError = class extends Error {
69110
69119
  if (opts?.cause != null) this.cause = opts.cause;
69111
69120
  }
69112
69121
  };
69122
+ var BadGatewayError = class extends BaseAPIError {
69123
+ constructor(body, rawResponse) {
69124
+ super({
69125
+ message: "BadGatewayError",
69126
+ statusCode: 502,
69127
+ body,
69128
+ rawResponse
69129
+ });
69130
+ Object.setPrototypeOf(this, new.target.prototype);
69131
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
69132
+ this.name = "BadGatewayError";
69133
+ }
69134
+ };
69113
69135
  var BadRequestError$1 = class extends BaseAPIError {
69114
69136
  constructor(body, rawResponse) {
69115
69137
  super({
@@ -69149,6 +69171,19 @@ var NotFoundError$1 = class extends BaseAPIError {
69149
69171
  this.name = "NotFoundError";
69150
69172
  }
69151
69173
  };
69174
+ var ServiceUnavailableError = class extends BaseAPIError {
69175
+ constructor(body, rawResponse) {
69176
+ super({
69177
+ message: "ServiceUnavailableError",
69178
+ statusCode: 503,
69179
+ body,
69180
+ rawResponse
69181
+ });
69182
+ Object.setPrototypeOf(this, new.target.prototype);
69183
+ if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
69184
+ this.name = "ServiceUnavailableError";
69185
+ }
69186
+ };
69152
69187
  function mergeHeaders$1(...headersArray) {
69153
69188
  const result = {};
69154
69189
  for (const [key, value] of headersArray.filter((headers) => headers != null).flatMap((headers) => Object.entries(headers))) {
@@ -71277,6 +71312,14 @@ const DagsterBindingPlanAll = object$1({
71277
71312
  });
71278
71313
  const DsnResponse = object$1({ dsn: string$1() });
71279
71314
  const Error_$1 = object$1({ error: string$1() });
71315
+ const SyncRun = object$1({
71316
+ endTime: property$1("end_time", date$1().nullable()),
71317
+ runId: property$1("run_id", string$1()),
71318
+ startTime: property$1("start_time", date$1().nullable()),
71319
+ status: RunStatus
71320
+ });
71321
+ const GetSyncRunResponse = object$1({ run: SyncRun.nullable() });
71322
+ const LaunchSyncRunResponse = object$1({ run: SyncRun });
71280
71323
  var BasesClient = class {
71281
71324
  _options;
71282
71325
  constructor(options) {
@@ -71830,6 +71873,170 @@ var DsnClient = class {
71830
71873
  return handleNonStatusCodeError$1(_response.error, _response.rawResponse, "GET", "/base/bases/{base_id}/dsn");
71831
71874
  }
71832
71875
  };
71876
+ var SyncRunsClient = class {
71877
+ _options;
71878
+ constructor(options) {
71879
+ this._options = normalizeClientOptions$1(options);
71880
+ }
71881
+ /**
71882
+ * @param {BaseAPI.LaunchSyncRunRequest} request
71883
+ * @param {SyncRunsClient.RequestOptions} requestOptions - Request-specific configuration.
71884
+ *
71885
+ * @throws {@link BaseAPI.BadRequestError}
71886
+ * @throws {@link BaseAPI.ForbiddenError}
71887
+ * @throws {@link BaseAPI.BadGatewayError}
71888
+ * @throws {@link BaseAPI.ServiceUnavailableError}
71889
+ *
71890
+ * @example
71891
+ * await client.syncRuns.launchSyncRun({
71892
+ * baseId: "base_id",
71893
+ * bindingId: "binding_id"
71894
+ * })
71895
+ */
71896
+ launchSyncRun(request, requestOptions) {
71897
+ return HttpResponsePromise$1.fromPromise(this.__launchSyncRun(request, requestOptions));
71898
+ }
71899
+ async __launchSyncRun(request, requestOptions) {
71900
+ const { baseId, bindingId } = request;
71901
+ const _headers = mergeHeaders$1(this._options?.headers, requestOptions?.headers);
71902
+ const _response = await fetcher$1({
71903
+ url: join$1(await Supplier$1.get(this._options.baseUrl) ?? await Supplier$1.get(this._options.environment), `base/bases/${encodePathParam$1(baseId)}/bindings/${encodePathParam$1(bindingId)}/sync-runs`),
71904
+ method: "POST",
71905
+ headers: _headers,
71906
+ queryString: queryBuilder$1().mergeAdditional(requestOptions?.queryParams).build(),
71907
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
71908
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
71909
+ abortSignal: requestOptions?.abortSignal,
71910
+ fetchFn: this._options?.fetch,
71911
+ logging: this._options.logging
71912
+ });
71913
+ if (_response.ok) return {
71914
+ data: LaunchSyncRunResponse.parseOrThrow(_response.body, {
71915
+ unrecognizedObjectKeys: "passthrough",
71916
+ allowUnrecognizedUnionMembers: true,
71917
+ allowUnrecognizedEnumValues: true,
71918
+ skipValidation: true,
71919
+ breadcrumbsPrefix: ["response"]
71920
+ }),
71921
+ rawResponse: _response.rawResponse
71922
+ };
71923
+ if (_response.error.reason === "status-code") switch (_response.error.statusCode) {
71924
+ case 400: throw new BadRequestError$1(Error_$1.parseOrThrow(_response.error.body, {
71925
+ unrecognizedObjectKeys: "passthrough",
71926
+ allowUnrecognizedUnionMembers: true,
71927
+ allowUnrecognizedEnumValues: true,
71928
+ skipValidation: true,
71929
+ breadcrumbsPrefix: ["response"]
71930
+ }), _response.rawResponse);
71931
+ case 403: throw new ForbiddenError$1(Error_$1.parseOrThrow(_response.error.body, {
71932
+ unrecognizedObjectKeys: "passthrough",
71933
+ allowUnrecognizedUnionMembers: true,
71934
+ allowUnrecognizedEnumValues: true,
71935
+ skipValidation: true,
71936
+ breadcrumbsPrefix: ["response"]
71937
+ }), _response.rawResponse);
71938
+ case 502: throw new BadGatewayError(Error_$1.parseOrThrow(_response.error.body, {
71939
+ unrecognizedObjectKeys: "passthrough",
71940
+ allowUnrecognizedUnionMembers: true,
71941
+ allowUnrecognizedEnumValues: true,
71942
+ skipValidation: true,
71943
+ breadcrumbsPrefix: ["response"]
71944
+ }), _response.rawResponse);
71945
+ case 503: throw new ServiceUnavailableError(Error_$1.parseOrThrow(_response.error.body, {
71946
+ unrecognizedObjectKeys: "passthrough",
71947
+ allowUnrecognizedUnionMembers: true,
71948
+ allowUnrecognizedEnumValues: true,
71949
+ skipValidation: true,
71950
+ breadcrumbsPrefix: ["response"]
71951
+ }), _response.rawResponse);
71952
+ default: throw new BaseAPIError({
71953
+ statusCode: _response.error.statusCode,
71954
+ body: _response.error.body,
71955
+ rawResponse: _response.rawResponse
71956
+ });
71957
+ }
71958
+ return handleNonStatusCodeError$1(_response.error, _response.rawResponse, "POST", "/base/bases/{base_id}/bindings/{binding_id}/sync-runs");
71959
+ }
71960
+ /**
71961
+ * @param {BaseAPI.GetSyncRunRequest} request
71962
+ * @param {SyncRunsClient.RequestOptions} requestOptions - Request-specific configuration.
71963
+ *
71964
+ * @throws {@link BaseAPI.BadRequestError}
71965
+ * @throws {@link BaseAPI.ForbiddenError}
71966
+ * @throws {@link BaseAPI.BadGatewayError}
71967
+ * @throws {@link BaseAPI.ServiceUnavailableError}
71968
+ *
71969
+ * @example
71970
+ * await client.syncRuns.getSyncRun({
71971
+ * baseId: "base_id",
71972
+ * runId: "run_id"
71973
+ * })
71974
+ */
71975
+ getSyncRun(request, requestOptions) {
71976
+ return HttpResponsePromise$1.fromPromise(this.__getSyncRun(request, requestOptions));
71977
+ }
71978
+ async __getSyncRun(request, requestOptions) {
71979
+ const { baseId, runId } = request;
71980
+ const _headers = mergeHeaders$1(this._options?.headers, requestOptions?.headers);
71981
+ const _response = await fetcher$1({
71982
+ url: join$1(await Supplier$1.get(this._options.baseUrl) ?? await Supplier$1.get(this._options.environment), `base/bases/${encodePathParam$1(baseId)}/sync-runs/${encodePathParam$1(runId)}`),
71983
+ method: "GET",
71984
+ headers: _headers,
71985
+ queryString: queryBuilder$1().mergeAdditional(requestOptions?.queryParams).build(),
71986
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1e3,
71987
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
71988
+ abortSignal: requestOptions?.abortSignal,
71989
+ fetchFn: this._options?.fetch,
71990
+ logging: this._options.logging
71991
+ });
71992
+ if (_response.ok) return {
71993
+ data: GetSyncRunResponse.parseOrThrow(_response.body, {
71994
+ unrecognizedObjectKeys: "passthrough",
71995
+ allowUnrecognizedUnionMembers: true,
71996
+ allowUnrecognizedEnumValues: true,
71997
+ skipValidation: true,
71998
+ breadcrumbsPrefix: ["response"]
71999
+ }),
72000
+ rawResponse: _response.rawResponse
72001
+ };
72002
+ if (_response.error.reason === "status-code") switch (_response.error.statusCode) {
72003
+ case 400: throw new BadRequestError$1(Error_$1.parseOrThrow(_response.error.body, {
72004
+ unrecognizedObjectKeys: "passthrough",
72005
+ allowUnrecognizedUnionMembers: true,
72006
+ allowUnrecognizedEnumValues: true,
72007
+ skipValidation: true,
72008
+ breadcrumbsPrefix: ["response"]
72009
+ }), _response.rawResponse);
72010
+ case 403: throw new ForbiddenError$1(Error_$1.parseOrThrow(_response.error.body, {
72011
+ unrecognizedObjectKeys: "passthrough",
72012
+ allowUnrecognizedUnionMembers: true,
72013
+ allowUnrecognizedEnumValues: true,
72014
+ skipValidation: true,
72015
+ breadcrumbsPrefix: ["response"]
72016
+ }), _response.rawResponse);
72017
+ case 502: throw new BadGatewayError(Error_$1.parseOrThrow(_response.error.body, {
72018
+ unrecognizedObjectKeys: "passthrough",
72019
+ allowUnrecognizedUnionMembers: true,
72020
+ allowUnrecognizedEnumValues: true,
72021
+ skipValidation: true,
72022
+ breadcrumbsPrefix: ["response"]
72023
+ }), _response.rawResponse);
72024
+ case 503: throw new ServiceUnavailableError(Error_$1.parseOrThrow(_response.error.body, {
72025
+ unrecognizedObjectKeys: "passthrough",
72026
+ allowUnrecognizedUnionMembers: true,
72027
+ allowUnrecognizedEnumValues: true,
72028
+ skipValidation: true,
72029
+ breadcrumbsPrefix: ["response"]
72030
+ }), _response.rawResponse);
72031
+ default: throw new BaseAPIError({
72032
+ statusCode: _response.error.statusCode,
72033
+ body: _response.error.body,
72034
+ rawResponse: _response.rawResponse
72035
+ });
72036
+ }
72037
+ return handleNonStatusCodeError$1(_response.error, _response.rawResponse, "GET", "/base/bases/{base_id}/sync-runs/{run_id}");
72038
+ }
72039
+ };
71833
72040
  var SyncStateClient = class {
71834
72041
  _options;
71835
72042
  constructor(options) {
@@ -71961,6 +72168,7 @@ var BaseAPIClient = class {
71961
72168
  _bases;
71962
72169
  _bindingPlan;
71963
72170
  _bindings;
72171
+ _syncRuns;
71964
72172
  _dsn;
71965
72173
  _syncState;
71966
72174
  constructor(options) {
@@ -71975,6 +72183,9 @@ var BaseAPIClient = class {
71975
72183
  get bindings() {
71976
72184
  return this._bindings ??= new BindingsClient(this._options);
71977
72185
  }
72186
+ get syncRuns() {
72187
+ return this._syncRuns ??= new SyncRunsClient(this._options);
72188
+ }
71978
72189
  get dsn() {
71979
72190
  return this._dsn ??= new DsnClient(this._options);
71980
72191
  }
@@ -72015,6 +72226,28 @@ function ctxAuthHeaders(tokenProvider) {
72015
72226
  return { headers: { Authorization: async () => `Bearer ${await tokenProvider()}` } };
72016
72227
  }
72017
72228
 
72229
+ //#endregion
72230
+ //#region ../shared/dist/index.mjs
72231
+ const dagsterUrlSchema = url().superRefine((value, context) => {
72232
+ const url = new URL(value);
72233
+ if (url.protocol !== "http:") context.addIssue({
72234
+ code: "custom",
72235
+ message: "Expected an http:// URL."
72236
+ });
72237
+ if (!url.port) context.addIssue({
72238
+ code: "custom",
72239
+ message: "Expected an explicit port."
72240
+ });
72241
+ if (url.username || url.password) context.addIssue({
72242
+ code: "custom",
72243
+ message: "Credentials are not allowed."
72244
+ });
72245
+ if (url.pathname !== "/" || url.search || url.hash) context.addIssue({
72246
+ code: "custom",
72247
+ message: "Expected an origin with no path, query, or fragment."
72248
+ });
72249
+ }).transform((value) => value.replace(/\/+$/, ""));
72250
+
72018
72251
  //#endregion
72019
72252
  //#region commands/base-seam.ts
72020
72253
  const BINDING_STATE_VERSION = 1;
@@ -75684,4 +75917,4 @@ runCli().catch((error) => {
75684
75917
  //#endregion
75685
75918
  export { createProgram, resolveRepoContext, resolveRuntimePaths, runCli };
75686
75919
  //# sourceMappingURL=cli.mjs.map
75687
- //# debugId=bee62857-a9a3-500d-b035-dc7b7a5eb6f9
75920
+ //# debugId=5506b6a8-6650-5a43-9cf5-9db6fb5eb4bf