@stackone/connect-sdk 1.35.1 → 1.36.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/index.d.mts CHANGED
@@ -31,6 +31,17 @@ declare const getOperationFromUrl: (connector: Connector, url: string, method: H
31
31
  declare function parseYamlConnector(yamlFileContents: string): Connector;
32
32
  declare const parseOperationInputs: (operation: Operation, inputs: unknown) => Record<string, unknown>;
33
33
  //#endregion
34
+ //#region src/connectors/validators.d.ts
35
+ type ValidationError = {
36
+ line: number;
37
+ message: string;
38
+ field?: string;
39
+ };
40
+ declare const validateYamlConnector: (yamlFileContents: string) => {
41
+ success: boolean;
42
+ errors?: ValidationError[];
43
+ };
44
+ //#endregion
34
45
  //#region src/errors/types.d.ts
35
46
  type ErrorType = 'CONNECTOR_PARSE_ERROR' | 'MISSING_OPERATION_ERROR' | 'INVALID_OPERATION_INPUTS_ERROR' | 'INVALID_CURSOR_ERROR';
36
47
  //#endregion
@@ -140,4 +151,4 @@ declare const runConnectorOperation: ({
140
151
  runStepOperationFn?: typeof runStepOperation;
141
152
  }) => Promise<Block>;
142
153
  //#endregion
143
- export { ConnectSDKError, ErrorType, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation };
154
+ export { ConnectSDKError, ErrorType, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation, validateYamlConnector };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,17 @@ declare const getOperationFromUrl: (connector: Connector, url: string, method: H
31
31
  declare function parseYamlConnector(yamlFileContents: string): Connector;
32
32
  declare const parseOperationInputs: (operation: Operation, inputs: unknown) => Record<string, unknown>;
33
33
  //#endregion
34
+ //#region src/connectors/validators.d.ts
35
+ type ValidationError = {
36
+ line: number;
37
+ message: string;
38
+ field?: string;
39
+ };
40
+ declare const validateYamlConnector: (yamlFileContents: string) => {
41
+ success: boolean;
42
+ errors?: ValidationError[];
43
+ };
44
+ //#endregion
34
45
  //#region src/errors/types.d.ts
35
46
  type ErrorType = 'CONNECTOR_PARSE_ERROR' | 'MISSING_OPERATION_ERROR' | 'INVALID_OPERATION_INPUTS_ERROR' | 'INVALID_CURSOR_ERROR';
36
47
  //#endregion
@@ -140,4 +151,4 @@ declare const runConnectorOperation: ({
140
151
  runStepOperationFn?: typeof runStepOperation;
141
152
  }) => Promise<Block>;
142
153
  //#endregion
143
- export { ConnectSDKError, ErrorType, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation };
154
+ export { ConnectSDKError, ErrorType, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation, validateYamlConnector };
package/dist/index.js CHANGED
@@ -476,7 +476,7 @@ const _parse = (_Err) => (schema, value, _ctx, _params) => {
476
476
  }
477
477
  return result.value;
478
478
  };
479
- const parse$2 = /* @__PURE__ */ _parse($ZodRealError);
479
+ const parse$3 = /* @__PURE__ */ _parse($ZodRealError);
480
480
  const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
481
481
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
482
482
  let result = schema._zod.run({
@@ -2588,7 +2588,7 @@ const ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
2588
2588
 
2589
2589
  //#endregion
2590
2590
  //#region ../../node_modules/zod/v4/classic/parse.js
2591
- const parse$1 = /* @__PURE__ */ _parse(ZodRealError);
2591
+ const parse$2 = /* @__PURE__ */ _parse(ZodRealError);
2592
2592
  const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2593
2593
  const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
2594
2594
  const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -2615,7 +2615,7 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2615
2615
  reg.add(inst, meta);
2616
2616
  return inst;
2617
2617
  };
2618
- inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
2618
+ inst.parse = (data, params) => parse$2(inst, data, params, { callee: inst.parse });
2619
2619
  inst.safeParse = (data, params) => safeParse(inst, data, params);
2620
2620
  inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2621
2621
  inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
@@ -3651,6 +3651,76 @@ const getDefaultRequestStepFunctionsParams = (stepFunctionName, baseRequestParam
3651
3651
  } else return {};
3652
3652
  };
3653
3653
 
3654
+ //#endregion
3655
+ //#region src/connectors/validators.ts
3656
+ const validateYamlConnector = (yamlFileContents) => {
3657
+ try {
3658
+ const errors = [];
3659
+ const yamlConnector = (0, yaml.parse)(yamlFileContents);
3660
+ const parsedYamlConnector = CONNECTOR_YAML_SCHEMA.safeParse(yamlConnector);
3661
+ if (!parsedYamlConnector.success) parsedYamlConnector.error.issues.forEach((issue$1) => {
3662
+ const lineNumber = getErrorLineNumber(issue$1.path, yamlFileContents);
3663
+ errors.push({
3664
+ line: lineNumber,
3665
+ message: issue$1.message,
3666
+ field: issue$1.path.join(".")
3667
+ });
3668
+ });
3669
+ return errors.length > 0 ? {
3670
+ success: false,
3671
+ errors
3672
+ } : { success: true };
3673
+ } catch (error) {
3674
+ const errorMsg = error.message;
3675
+ const lineMatch = errorMsg.match(/at line (\d+)/);
3676
+ const lineNumber = lineMatch ? parseInt(lineMatch[1], 10) : 1;
3677
+ return {
3678
+ success: false,
3679
+ errors: [{
3680
+ line: lineNumber,
3681
+ message: "The YAML connector file is not valid. Please check the syntax and structure.",
3682
+ field: void 0
3683
+ }]
3684
+ };
3685
+ }
3686
+ };
3687
+ const getErrorLineNumber = (path, yamlFileContents) => {
3688
+ const yamlLines = yamlFileContents.split("\n");
3689
+ let pathIdx = 0;
3690
+ let lastIndentationLevel = -1;
3691
+ let lastLine = 0;
3692
+ for (let lineNumber = 0; lineNumber < yamlLines.length; lineNumber++) {
3693
+ const line = yamlLines[lineNumber];
3694
+ const indentationLevel = line.match(/^(\s*)/)?.[1]?.length || 0;
3695
+ const trimmedLine = line.replace("- ", "").trim();
3696
+ if (trimmedLine.startsWith("#") || trimmedLine === "") continue;
3697
+ if (indentationLevel <= lastIndentationLevel) continue;
3698
+ const currentPathText = (0, __stackone_utils.notMissing)(path[pathIdx]) ? `${String(path[pathIdx])}` : "";
3699
+ if ((0, __stackone_utils.isMissing)(currentPathText)) return lastLine + 1;
3700
+ if (!isNaN(Number(currentPathText))) {
3701
+ const posToFind = parseInt(currentPathText, 10);
3702
+ let currentPos = -1;
3703
+ for (let lineNumber2 = lineNumber; lineNumber2 < yamlLines.length; lineNumber2++) {
3704
+ const line$1 = yamlLines[lineNumber2];
3705
+ const trimmedLine$1 = line$1.trim();
3706
+ if (trimmedLine$1.startsWith("-")) currentPos++;
3707
+ if (currentPos === posToFind) {
3708
+ pathIdx++;
3709
+ lastLine = lineNumber;
3710
+ lineNumber--;
3711
+ break;
3712
+ } else lineNumber++;
3713
+ }
3714
+ } else if (trimmedLine.startsWith(`${currentPathText}:`)) if (pathIdx === path.length - 1) return lineNumber + 1;
3715
+ else {
3716
+ lastIndentationLevel = indentationLevel;
3717
+ lastLine = lineNumber;
3718
+ pathIdx++;
3719
+ }
3720
+ }
3721
+ return lastLine + 1;
3722
+ };
3723
+
3654
3724
  //#endregion
3655
3725
  //#region src/errors/connectSDKErrors.ts
3656
3726
  var ConnectSDKError = class ConnectSDKError extends Error {
@@ -4167,4 +4237,5 @@ exports.getOperationFromUrl = getOperationFromUrl;
4167
4237
  exports.parseOperationInputs = parseOperationInputs;
4168
4238
  exports.parseYamlConnector = parseYamlConnector;
4169
4239
  exports.runConnectorOperation = runConnectorOperation;
4170
- exports.runStepOperation = runStepOperation;
4240
+ exports.runStepOperation = runStepOperation;
4241
+ exports.validateYamlConnector = validateYamlConnector;
package/dist/index.mjs CHANGED
@@ -3628,6 +3628,76 @@ const getDefaultRequestStepFunctionsParams = (stepFunctionName, baseRequestParam
3628
3628
  } else return {};
3629
3629
  };
3630
3630
 
3631
+ //#endregion
3632
+ //#region src/connectors/validators.ts
3633
+ const validateYamlConnector = (yamlFileContents) => {
3634
+ try {
3635
+ const errors = [];
3636
+ const yamlConnector = parse(yamlFileContents);
3637
+ const parsedYamlConnector = CONNECTOR_YAML_SCHEMA.safeParse(yamlConnector);
3638
+ if (!parsedYamlConnector.success) parsedYamlConnector.error.issues.forEach((issue$1) => {
3639
+ const lineNumber = getErrorLineNumber(issue$1.path, yamlFileContents);
3640
+ errors.push({
3641
+ line: lineNumber,
3642
+ message: issue$1.message,
3643
+ field: issue$1.path.join(".")
3644
+ });
3645
+ });
3646
+ return errors.length > 0 ? {
3647
+ success: false,
3648
+ errors
3649
+ } : { success: true };
3650
+ } catch (error) {
3651
+ const errorMsg = error.message;
3652
+ const lineMatch = errorMsg.match(/at line (\d+)/);
3653
+ const lineNumber = lineMatch ? parseInt(lineMatch[1], 10) : 1;
3654
+ return {
3655
+ success: false,
3656
+ errors: [{
3657
+ line: lineNumber,
3658
+ message: "The YAML connector file is not valid. Please check the syntax and structure.",
3659
+ field: void 0
3660
+ }]
3661
+ };
3662
+ }
3663
+ };
3664
+ const getErrorLineNumber = (path, yamlFileContents) => {
3665
+ const yamlLines = yamlFileContents.split("\n");
3666
+ let pathIdx = 0;
3667
+ let lastIndentationLevel = -1;
3668
+ let lastLine = 0;
3669
+ for (let lineNumber = 0; lineNumber < yamlLines.length; lineNumber++) {
3670
+ const line = yamlLines[lineNumber];
3671
+ const indentationLevel = line.match(/^(\s*)/)?.[1]?.length || 0;
3672
+ const trimmedLine = line.replace("- ", "").trim();
3673
+ if (trimmedLine.startsWith("#") || trimmedLine === "") continue;
3674
+ if (indentationLevel <= lastIndentationLevel) continue;
3675
+ const currentPathText = notMissing(path[pathIdx]) ? `${String(path[pathIdx])}` : "";
3676
+ if (isMissing(currentPathText)) return lastLine + 1;
3677
+ if (!isNaN(Number(currentPathText))) {
3678
+ const posToFind = parseInt(currentPathText, 10);
3679
+ let currentPos = -1;
3680
+ for (let lineNumber2 = lineNumber; lineNumber2 < yamlLines.length; lineNumber2++) {
3681
+ const line$1 = yamlLines[lineNumber2];
3682
+ const trimmedLine$1 = line$1.trim();
3683
+ if (trimmedLine$1.startsWith("-")) currentPos++;
3684
+ if (currentPos === posToFind) {
3685
+ pathIdx++;
3686
+ lastLine = lineNumber;
3687
+ lineNumber--;
3688
+ break;
3689
+ } else lineNumber++;
3690
+ }
3691
+ } else if (trimmedLine.startsWith(`${currentPathText}:`)) if (pathIdx === path.length - 1) return lineNumber + 1;
3692
+ else {
3693
+ lastIndentationLevel = indentationLevel;
3694
+ lastLine = lineNumber;
3695
+ pathIdx++;
3696
+ }
3697
+ }
3698
+ return lastLine + 1;
3699
+ };
3700
+
3631
3701
  //#endregion
3632
3702
  //#region src/errors/connectSDKErrors.ts
3633
3703
  var ConnectSDKError = class ConnectSDKError extends Error {
@@ -4137,4 +4207,4 @@ const processCursor = (queryParams, blockContext) => {
4137
4207
  };
4138
4208
 
4139
4209
  //#endregion
4140
- export { ConnectSDKError, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation };
4210
+ export { ConnectSDKError, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation, validateYamlConnector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/connect-sdk",
3
- "version": "1.35.1",
3
+ "version": "1.36.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",