@superdurable/connector-gitlab 0.1.0 → 0.1.1

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,16 +1,18 @@
1
1
  {
2
2
  "connectorId": "gitlab",
3
- "releaseTag": "connectors/gitlab/go/v0.2.0",
3
+ "releaseTag": "connectors/gitlab/go/v0.2.1",
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-gitlab",
7
- "version": "0.1.0"
7
+ "version": "0.1.1"
8
8
  },
9
9
  "factories": [
10
10
  {
11
11
  "name": "newGetProjectStep",
12
12
  "kind": "query",
13
13
  "operationId": "getProject",
14
+ "inputType": "GetProjectInput",
15
+ "description": "Read one GitLab project by numeric ID or namespace path.",
14
16
  "fields": {
15
17
  "stepType": "stepType",
16
18
  "annotations": "annotations",
@@ -43,12 +45,28 @@
43
45
  "field": "defect",
44
46
  "optional": true
45
47
  }
46
- ]
48
+ ],
49
+ "inputSchema": {
50
+ "additionalProperties": false,
51
+ "description": "GetProjectInput identifies a project by numeric ID or namespace path.",
52
+ "properties": {
53
+ "projectId": {
54
+ "description": "ProjectID is a numeric ID or namespace path, such as meridian/web.",
55
+ "type": "string"
56
+ }
57
+ },
58
+ "required": [
59
+ "projectId"
60
+ ],
61
+ "type": "object"
62
+ }
47
63
  },
48
64
  {
49
65
  "name": "newListIssuesStep",
50
66
  "kind": "query",
51
67
  "operationId": "listIssues",
68
+ "inputType": "ListIssuesInput",
69
+ "description": "List the first page of issues for a GitLab project.",
52
70
  "fields": {
53
71
  "stepType": "stepType",
54
72
  "annotations": "annotations",
@@ -81,12 +99,28 @@
81
99
  "field": "defect",
82
100
  "optional": true
83
101
  }
84
- ]
102
+ ],
103
+ "inputSchema": {
104
+ "additionalProperties": false,
105
+ "description": "ListIssuesInput identifies the project whose issues are listed.",
106
+ "properties": {
107
+ "projectId": {
108
+ "description": "ProjectID is a numeric ID or namespace path.",
109
+ "type": "string"
110
+ }
111
+ },
112
+ "required": [
113
+ "projectId"
114
+ ],
115
+ "type": "object"
116
+ }
85
117
  },
86
118
  {
87
119
  "name": "newUpdateIssueLabelsStep",
88
120
  "kind": "mutation",
89
121
  "operationId": "updateIssueLabels",
122
+ "inputType": "UpdateIssueLabelsInput",
123
+ "description": "Replace one GitLab issue's complete label set; repeating the request is safe.",
90
124
  "fields": {
91
125
  "stepType": "stepType",
92
126
  "annotations": "annotations",
@@ -119,7 +153,37 @@
119
153
  "field": "defect",
120
154
  "optional": true
121
155
  }
122
- ]
156
+ ],
157
+ "inputSchema": {
158
+ "additionalProperties": false,
159
+ "description": "UpdateIssueLabelsInput replaces every label on one issue; an empty list clears them.",
160
+ "properties": {
161
+ "issueIid": {
162
+ "description": "IssueIID is the positive project-local issue number.",
163
+ "type": "integer"
164
+ },
165
+ "labels": {
166
+ "description": "Labels is the desired complete label set; empty clears all labels.",
167
+ "items": {
168
+ "type": "string"
169
+ },
170
+ "type": [
171
+ "array",
172
+ "null"
173
+ ]
174
+ },
175
+ "projectId": {
176
+ "description": "ProjectID is a numeric ID or namespace path.",
177
+ "type": "string"
178
+ }
179
+ },
180
+ "required": [
181
+ "issueIid",
182
+ "labels",
183
+ "projectId"
184
+ ],
185
+ "type": "object"
186
+ }
123
187
  }
124
188
  ]
125
189
  }
@@ -1,10 +1,36 @@
1
1
  // src/generated/models.ts
2
2
  import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
3
4
  var ConfigSchema = z.object({
4
5
  "baseUrl": z.string().optional(),
5
6
  "timeoutMs": z.number().int().optional(),
6
7
  "maxResponseBytes": z.number().int().optional()
7
8
  });
9
+ var CredentialMaterialError = class extends TypeError {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "CredentialMaterialError";
13
+ }
14
+ };
15
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
16
+ "project credential decoding failed",
17
+ "shared project credential decoding failed",
18
+ "project credential decoding failed: this connector version does not support shared credentials"
19
+ ]);
20
+ function isCredentialMaterialError(error) {
21
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
22
+ }
23
+ function decodeCredentials(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
25
+ const fields = value;
26
+ const allowed = /* @__PURE__ */ new Set(["access_token"]);
27
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
28
+ if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new CredentialMaterialError("credential access_token has an invalid type");
29
+ const credentials = {};
30
+ if (!fields["access_token"]) throw new CredentialMaterialError("credential access_token is required");
31
+ credentials.accessToken = new SecretString(fields["access_token"] ?? "");
32
+ return credentials;
33
+ }
8
34
  var GetProjectInputSchema = z.strictObject({
9
35
  "projectId": z.string()
10
36
  });
@@ -102,7 +128,7 @@ var UpdateIssueLabelsDefinition = {
102
128
  { id: "updated", description: "Replace one GitLab issue's complete label set; repeating the request is safe." },
103
129
  { id: "notFound", description: "The requested resource does not exist or is inaccessible.", optional: true },
104
130
  { id: "providerRejected", description: "The provider rejected the request.", optional: true },
105
- { id: "invalidResponse", description: "The provider returned malformed or oversized JSON.", optional: true },
131
+ { id: "invalidResponse", description: "Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because replacing the complete label set again is safe.", optional: true },
106
132
  { id: "defect", description: "Local input or connection credentials are invalid.", optional: true }
107
133
  ],
108
134
  stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
@@ -141,6 +167,9 @@ function newProjectConnection(project, connectionName, createClient) {
141
167
 
142
168
  export {
143
169
  ConfigSchema,
170
+ CredentialMaterialError,
171
+ isCredentialMaterialError,
172
+ decodeCredentials,
144
173
  GetProjectInputSchema,
145
174
  ProjectSchema,
146
175
  ListIssuesInputSchema,
@@ -21,6 +21,14 @@ interface Credentials {
21
21
  /** Secret GitLab personal access token from User Settings > Access Tokens at https://gitlab.com/-/user_settings/personal_access_tokens. Create a token with read_api for reads or api for label updates, and copy it. Blank prevents requests. */
22
22
  accessToken: SecretString;
23
23
  }
24
+ /** Stored credential material that fails the connector credential checks, so no retry can succeed. */
25
+ declare class CredentialMaterialError extends TypeError {
26
+ constructor(message: string);
27
+ }
28
+ /** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
29
+ declare function isCredentialMaterialError(error: unknown): boolean;
30
+ /** Decode private credential fields for the connector. */
31
+ declare function decodeCredentials(value: unknown): Credentials;
24
32
  /** Host-owned source of private connector credentials. */
25
33
  type CredentialSource = CredentialProvider<Credentials>;
26
34
  /** GetProjectInput identifies a project by numeric ID or namespace path. */
@@ -134,4 +142,4 @@ declare function newConnection(client: Operations, reference: ConnectionRef): Co
134
142
  /** Bind scripted operations to a named connection. */
135
143
  declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
136
144
 
137
- export { Connection as C, type GetProjectInput as G, type IssuesPage as I, type ListIssuesInput as L, type Operations as O, type Project as P, type UpdateIssueLabelsInput as U, type Issue as a, type Config as b, type Credentials as c, ConfigSchema as d, type CredentialSource as e, GetProjectInputSchema as f, IssueSchema as g, IssuesPageSchema as h, ListIssuesInputSchema as i, ProjectSchema as j, UpdateIssueLabelsInputSchema as k, newConnectionWithOperations as l, newConnection as n };
145
+ export { Connection as C, type GetProjectInput as G, type IssuesPage as I, type ListIssuesInput as L, type Operations as O, type Project as P, type UpdateIssueLabelsInput as U, type Issue as a, type Config as b, type Credentials as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, GetProjectInputSchema as g, IssueSchema as h, IssuesPageSchema as i, ListIssuesInputSchema as j, ProjectSchema as k, UpdateIssueLabelsInputSchema as l, decodeCredentials as m, isCredentialMaterialError as n, newConnection as o, newConnectionWithOperations as p };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GetProjectInput, P as Project, C as Connection, L as ListIssuesInput, I as IssuesPage, U as UpdateIssueLabelsInput, a as Issue, O as Operations, b as Config, c as Credentials } from './connection-CmsyOQVf.js';
2
- export { d as ConfigSchema, e as CredentialSource, f as GetProjectInputSchema, g as IssueSchema, h as IssuesPageSchema, i as ListIssuesInputSchema, j as ProjectSchema, k as UpdateIssueLabelsInputSchema, n as newConnection, l as newConnectionWithOperations } from './connection-CmsyOQVf.js';
1
+ import { G as GetProjectInput, P as Project, C as Connection, L as ListIssuesInput, I as IssuesPage, U as UpdateIssueLabelsInput, a as Issue, O as Operations, b as Config, c as Credentials } from './connection-MkRfQmSd.js';
2
+ export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetProjectInputSchema, h as IssueSchema, i as IssuesPageSchema, j as ListIssuesInputSchema, k as ProjectSchema, l as UpdateIssueLabelsInputSchema, m as decodeCredentials, n as isCredentialMaterialError, o as newConnection, p as newConnectionWithOperations } from './connection-MkRfQmSd.js';
3
3
  import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
4
4
  import { QueryDefinition, MutationDefinition, QueryStepConfig, Query, QueryResult, MutationStepConfig, Mutation, MutationResult, QueryStep, MutationStep, Call, QueryAttempt, MutationAttempt, CredentialProvider, Failure } from '@superdurable/connectors-sdk';
5
5
  import { StepTarget } from '@superdurable/dex';
@@ -77,7 +77,7 @@ declare const UpdateIssueLabelsBranchUpdated: "updated";
77
77
  declare const UpdateIssueLabelsBranchNotFound: "notFound";
78
78
  /** The provider rejected the request. */
79
79
  declare const UpdateIssueLabelsBranchProviderRejected: "providerRejected";
80
- /** The provider returned malformed or oversized JSON. */
80
+ /** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because replacing the complete label set again is safe. */
81
81
  declare const UpdateIssueLabelsBranchInvalidResponse: "invalidResponse";
82
82
  /** Local input or connection credentials are invalid. */
83
83
  declare const UpdateIssueLabelsBranchDefect: "defect";
@@ -146,7 +146,7 @@ interface UpdateIssueLabelsStepConfig<StepInput, OperationInput = UpdateIssueLab
146
146
  notFound?: StepTarget<MutationResult<OperationOutput>>;
147
147
  /** The provider rejected the request. */
148
148
  providerRejected?: StepTarget<MutationResult<OperationOutput>>;
149
- /** The provider returned malformed or oversized JSON. */
149
+ /** Kept for compatibility and no longer selected: a malformed or oversized answer now retries, because replacing the complete label set again is safe. */
150
150
  invalidResponse?: StepTarget<MutationResult<OperationOutput>>;
151
151
  /** Local input or connection credentials are invalid. */
152
152
  defect?: StepTarget<MutationResult<OperationOutput>>;
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  ConfigSchema,
3
3
  Connection,
4
4
  ConnectorID,
5
+ CredentialMaterialError,
5
6
  GetProjectBranch,
6
7
  GetProjectBranchDefect,
7
8
  GetProjectBranchFound,
@@ -33,10 +34,12 @@ import {
33
34
  UpdateIssueLabelsDefinition,
34
35
  UpdateIssueLabelsInputSchema,
35
36
  UpdateIssueLabelsMetadata,
37
+ decodeCredentials,
38
+ isCredentialMaterialError,
36
39
  newConnection,
37
40
  newConnectionWithOperations,
38
41
  newProjectConnection
39
- } from "./chunk-LGQA5VXE.js";
42
+ } from "./chunk-6HA6UUCP.js";
40
43
 
41
44
  // src/generated/steps.ts
42
45
  import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
@@ -80,7 +83,8 @@ import { z } from "zod";
80
83
 
81
84
  // src/client.ts
82
85
  import { BodyTooLargeError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
83
- import { SecretString } from "@superdurable/connectors-sdk";
86
+ import { ReauthorizationRequiredError, SecretString } from "@superdurable/connectors-sdk";
87
+ import { ConnectionNotSelectedError, CredentialBrokerRejectedError, ObjectNotFoundError } from "@superdurable/connectors-sdk/projectconfig";
84
88
 
85
89
  // src/operations.ts
86
90
  import { newMutationBranch, newMutationRetry, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
@@ -162,7 +166,7 @@ var UpdateIssueLabelsOperation = class {
162
166
  if (value.id <= 0 || value.iid <= 0) throw new Error("missing issue identity");
163
167
  return newMutationBranch("updated", value, {});
164
168
  } catch {
165
- return mutationFailure("updateIssueLabels", "invalidResponse", "PROTOCOL", "response was malformed");
169
+ return newMutationRetry(failure("updateIssueLabels", "PROTOCOL", "response was malformed"));
166
170
  }
167
171
  }
168
172
  };
@@ -194,9 +198,6 @@ function mutationDefect(operation, message) {
194
198
  function queryFailure(operation, branch, empty) {
195
199
  return newQueryBranch(branch, empty, {}, failure(operation, "PROTOCOL", "response was malformed"));
196
200
  }
197
- function mutationFailure(operation, branch, kind, message) {
198
- return newMutationBranch(branch, emptyIssue, {}, failure(operation, kind, message));
199
- }
200
201
  function queryOutcome(result, empty) {
201
202
  if (result.branch === "retry") return newQueryRetry(result.failure, result.retryAfterMs);
202
203
  return newQueryBranch(result.branch, empty, {}, result.failure);
@@ -243,15 +244,16 @@ var GitLabClient = class {
243
244
  }
244
245
  /** Resolve credentials, send one request, and classify the provider response. */
245
246
  async exchange(call, operation, method, path, body) {
246
- let token;
247
+ let credentials;
247
248
  try {
248
- const credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
249
- if (!(credentials.accessToken instanceof SecretString)) throw new TypeError("invalid credential");
250
- token = credentials.accessToken.reveal();
251
- if (!token || !isHeaderSafeCredential(token)) throw new TypeError("invalid credential");
252
- } catch {
253
- return this.failure("defect", operation, "AUTHENTICATION", "connection credentials are unavailable");
249
+ credentials = await this.credentials.resolve(call, call.context.cancellationSignal);
250
+ } catch (error) {
251
+ if (isTerminalCredentialError(error)) return this.failure("defect", operation, "AUTHENTICATION", "connection credentials are unavailable");
252
+ return this.failure("retry", operation, "AVAILABILITY", "connection credentials could not be read, so nothing was sent");
254
253
  }
254
+ if (!(credentials?.accessToken instanceof SecretString)) return this.failure("defect", operation, "AUTHENTICATION", "connection credentials are invalid");
255
+ const token = credentials.accessToken.reveal();
256
+ if (!token || !isHeaderSafeCredential(token)) return this.failure("defect", operation, "AUTHENTICATION", "connection credentials are invalid");
255
257
  try {
256
258
  const response = await this.send({
257
259
  url: this.baseUrl + path,
@@ -263,23 +265,25 @@ var GitLabClient = class {
263
265
  addressPolicy: this.baseUrl === defaultBaseUrl ? "publicHTTPS" : "privateNetworkHTTP",
264
266
  signal: call.context.cancellationSignal
265
267
  });
266
- const statusOutcome = this.classifyStatus(operation, response.status, response.headers);
268
+ const statusOutcome = this.classifyStatus(operation, method, response.status, response.headers);
267
269
  if (statusOutcome) return statusOutcome;
268
270
  return { response };
269
271
  } catch (error) {
270
272
  if (error instanceof BodyTooLargeError) {
271
- const statusOutcome = this.classifyStatus(operation, error.status, error.headers);
273
+ const statusOutcome = this.classifyStatus(operation, method, error.status, error.headers);
272
274
  if (statusOutcome) return statusOutcome;
275
+ if (method === "PUT") return this.failure("retry", operation, "RESPONSE_TOO_LARGE", "response exceeded the configured limit");
273
276
  return this.failure("invalidResponse", operation, "RESPONSE_TOO_LARGE", "response exceeded the configured limit");
274
277
  }
275
278
  return this.failure("retry", operation, "AVAILABILITY", "GitLab request failed");
276
279
  }
277
280
  }
278
- classifyStatus(operation, status, headers) {
281
+ classifyStatus(operation, method, status, headers) {
279
282
  if (status === void 0 || status === 200) return void 0;
280
283
  if (status === 429 || status === 408 || status === 409 || status >= 500) {
281
284
  return this.failure("retry", operation, status === 429 ? "RATE_LIMIT" : "AVAILABILITY", `GitLab returned HTTP ${status}`, parseRetryAfter(header(headers, "retry-after"), this.now()));
282
285
  }
286
+ if (method === "PUT" && !definiteRefusalStatuses.has(status)) return this.failure("retry", operation, "AVAILABILITY", `GitLab answered HTTP ${status}, so the outcome is unknown`);
283
287
  if (status === 404) return this.failure("notFound", operation, "NOT_FOUND", `GitLab returned HTTP ${status}`);
284
288
  const kind = status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : status === 400 || status === 422 ? "VALIDATION" : "PROVIDER_REJECTION";
285
289
  return this.failure("providerRejected", operation, kind, `GitLab returned HTTP ${status}`);
@@ -288,6 +292,10 @@ var GitLabClient = class {
288
292
  return { branch, failure: { kind, provider: "gitlab", operation, message }, retryAfterMs };
289
293
  }
290
294
  };
295
+ function isTerminalCredentialError(error) {
296
+ return error instanceof ReauthorizationRequiredError || error instanceof ConnectionNotSelectedError || error instanceof CredentialBrokerRejectedError || error instanceof ObjectNotFoundError || isCredentialMaterialError(error);
297
+ }
298
+ var definiteRefusalStatuses = /* @__PURE__ */ new Set([400, 401, 403, 404, 411, 413, 414, 415, 422]);
291
299
  function header(headers, name) {
292
300
  const value = headers?.[name];
293
301
  return Array.isArray(value) ? value[0] ?? "" : value ?? "";
@@ -317,6 +325,7 @@ export {
317
325
  ConfigSchema,
318
326
  Connection,
319
327
  ConnectorID,
328
+ CredentialMaterialError,
320
329
  GetProjectBranch,
321
330
  GetProjectBranchDefect,
322
331
  GetProjectBranchFound,
@@ -352,6 +361,8 @@ export {
352
361
  UpdateIssueLabelsInputSchema,
353
362
  UpdateIssueLabelsMetadata,
354
363
  UpdateIssueLabelsOperation,
364
+ decodeCredentials,
365
+ isCredentialMaterialError,
355
366
  newConnection,
356
367
  newConnectionWithOperations,
357
368
  newGetProjectStep,
package/dist/mock.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MockQuery, MockMutation, Case } from '@superdurable/connectors-sdk/connectormock';
2
2
  import { Failure } from '@superdurable/connectors-sdk';
3
- import { O as Operations, C as Connection, G as GetProjectInput, P as Project, L as ListIssuesInput, I as IssuesPage, U as UpdateIssueLabelsInput, a as Issue } from './connection-CmsyOQVf.js';
3
+ import { O as Operations, C as Connection, G as GetProjectInput, P as Project, L as ListIssuesInput, I as IssuesPage, U as UpdateIssueLabelsInput, a as Issue } from './connection-MkRfQmSd.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Go zero value for GetProjectInput in scripted cases. */
package/dist/mock.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  UpdateIssueLabelsDefinition,
11
11
  UpdateIssueLabelsInputSchema,
12
12
  newConnectionWithOperations
13
- } from "./chunk-LGQA5VXE.js";
13
+ } from "./chunk-6HA6UUCP.js";
14
14
 
15
15
  // src/generated/mock.ts
16
16
  import { branchCase, retryCase, newMutation, newQuery } from "@superdurable/connectors-sdk/connectormock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-gitlab",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "GitLab project, issue, and label operations for Dex Flows",
6
6
  "repository": {
@@ -26,7 +26,8 @@
26
26
  "./mock": {
27
27
  "types": "./dist/mock.d.ts",
28
28
  "import": "./dist/mock.js"
29
- }
29
+ },
30
+ "./dex-connector.json": "./dex-connector.json"
30
31
  },
31
32
  "files": [
32
33
  "dist",