@usecontextlayer/ctxe 0.6.0 → 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]="0af3a69a-2f58-5008-ac97-72897804bc5d")}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.6.0";
4365
+ var version$1 = "0.7.0";
4366
4366
 
4367
4367
  //#endregion
4368
4368
  //#region sentry.ts
@@ -69119,6 +69119,19 @@ var BaseAPITimeoutError = class extends Error {
69119
69119
  if (opts?.cause != null) this.cause = opts.cause;
69120
69120
  }
69121
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
+ };
69122
69135
  var BadRequestError$1 = class extends BaseAPIError {
69123
69136
  constructor(body, rawResponse) {
69124
69137
  super({
@@ -69158,6 +69171,19 @@ var NotFoundError$1 = class extends BaseAPIError {
69158
69171
  this.name = "NotFoundError";
69159
69172
  }
69160
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
+ };
69161
69187
  function mergeHeaders$1(...headersArray) {
69162
69188
  const result = {};
69163
69189
  for (const [key, value] of headersArray.filter((headers) => headers != null).flatMap((headers) => Object.entries(headers))) {
@@ -71286,6 +71312,14 @@ const DagsterBindingPlanAll = object$1({
71286
71312
  });
71287
71313
  const DsnResponse = object$1({ dsn: string$1() });
71288
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 });
71289
71323
  var BasesClient = class {
71290
71324
  _options;
71291
71325
  constructor(options) {
@@ -71839,6 +71873,170 @@ var DsnClient = class {
71839
71873
  return handleNonStatusCodeError$1(_response.error, _response.rawResponse, "GET", "/base/bases/{base_id}/dsn");
71840
71874
  }
71841
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
+ };
71842
72040
  var SyncStateClient = class {
71843
72041
  _options;
71844
72042
  constructor(options) {
@@ -71970,6 +72168,7 @@ var BaseAPIClient = class {
71970
72168
  _bases;
71971
72169
  _bindingPlan;
71972
72170
  _bindings;
72171
+ _syncRuns;
71973
72172
  _dsn;
71974
72173
  _syncState;
71975
72174
  constructor(options) {
@@ -71984,6 +72183,9 @@ var BaseAPIClient = class {
71984
72183
  get bindings() {
71985
72184
  return this._bindings ??= new BindingsClient(this._options);
71986
72185
  }
72186
+ get syncRuns() {
72187
+ return this._syncRuns ??= new SyncRunsClient(this._options);
72188
+ }
71987
72189
  get dsn() {
71988
72190
  return this._dsn ??= new DsnClient(this._options);
71989
72191
  }
@@ -72024,6 +72226,28 @@ function ctxAuthHeaders(tokenProvider) {
72024
72226
  return { headers: { Authorization: async () => `Bearer ${await tokenProvider()}` } };
72025
72227
  }
72026
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
+
72027
72251
  //#endregion
72028
72252
  //#region commands/base-seam.ts
72029
72253
  const BINDING_STATE_VERSION = 1;
@@ -75693,4 +75917,4 @@ runCli().catch((error) => {
75693
75917
  //#endregion
75694
75918
  export { createProgram, resolveRepoContext, resolveRuntimePaths, runCli };
75695
75919
  //# sourceMappingURL=cli.mjs.map
75696
- //# debugId=0af3a69a-2f58-5008-ac97-72897804bc5d
75920
+ //# debugId=5506b6a8-6650-5a43-9cf5-9db6fb5eb4bf