@geins/crm 0.3.4 → 0.3.5-canary

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @geins/crm
2
2
 
3
+ ## 0.3.5-canary
4
+
5
+ ### Patch Changes
6
+
7
+ - d666708: added settingvars to GraphQLService
8
+ - 2158dcd: Possiblity to use string as query for the merchantAPI
9
+ - 5f86eeb: ci fixes
10
+ - Updated dependencies [d666708]
11
+ - Updated dependencies [2158dcd]
12
+ - Updated dependencies [5f86eeb]
13
+ - @geins/core@0.3.5-canary
14
+
3
15
  ## 0.3.4
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -16312,15 +16312,18 @@ var MerchantApiClient = /** @class */ (function () {
16312
16312
  }
16313
16313
  return FetchPolicyOptions.NETWORK_ONLY;
16314
16314
  };
16315
- MerchantApiClient.prototype.getOperationObject = function (operationType, document, variables, options) {
16315
+ MerchantApiClient.prototype.getOperationObject = function (operationType, operationOptions) {
16316
16316
  var _a;
16317
16317
  var _b;
16318
- if (variables === void 0) { variables = {}; }
16319
- if (options === void 0) { options = {}; }
16318
+ var query = operationOptions.query, queryAsString = operationOptions.queryAsString, variables = operationOptions.variables, requestOptions = operationOptions.requestOptions;
16319
+ var queryDocument = query || gql(queryAsString || '');
16320
+ var options = requestOptions || {};
16320
16321
  var token = this._userToken || ((_b = this._cookieService) === null || _b === void 0 ? void 0 : _b.get(AUTH_COOKIES.USER_AUTH));
16321
- // remove typename from variables
16322
+ if (!queryDocument) {
16323
+ throw new Error('Query is required');
16324
+ }
16322
16325
  var operationObj = (_a = {},
16323
- _a[operationType] = document,
16326
+ _a[operationType] = queryDocument,
16324
16327
  _a.variables = variables,
16325
16328
  _a.fetchPolicy = this.getFetchPolicy(operationType, options.fetchPolicy),
16326
16329
  _a.pollInterval = options.pollInterval || this.pollInterval,
@@ -16336,20 +16339,18 @@ var MerchantApiClient = /** @class */ (function () {
16336
16339
  };
16337
16340
  MerchantApiClient.prototype.runQuery = function (options) {
16338
16341
  return __awaiter(this, void 0, void 0, function () {
16339
- var query, variables, requestOptions, q;
16342
+ var q;
16340
16343
  return __generator(this, function (_a) {
16341
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16342
- q = this.getOperationObject(OperationType.QUERY, query, variables, requestOptions);
16344
+ q = this.getOperationObject(OperationType.QUERY, options);
16343
16345
  return [2 /*return*/, this._apolloClient.query(q)];
16344
16346
  });
16345
16347
  });
16346
16348
  };
16347
16349
  MerchantApiClient.prototype.runMutation = function (options) {
16348
16350
  return __awaiter(this, void 0, void 0, function () {
16349
- var query, variables, requestOptions, q;
16351
+ var q;
16350
16352
  return __generator(this, function (_a) {
16351
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16352
- q = this.getOperationObject(OperationType.MUTATION, query, variables, requestOptions);
16353
+ q = this.getOperationObject(OperationType.MUTATION, options);
16353
16354
  return [2 /*return*/, this._apolloClient.mutate(q)];
16354
16355
  });
16355
16356
  });
@@ -20740,37 +20741,45 @@ var ChannelService = /** @class */ (function (_super) {
20740
20741
  return ChannelService;
20741
20742
  }(BaseApiService));
20742
20743
 
20744
+ /**
20745
+ * GraphQLService class provides methods to interact with a GraphQL API.
20746
+ * It extends the BaseApiService and includes methods for querying and mutating data.
20747
+ */
20743
20748
  var GraphQLService = /** @class */ (function (_super) {
20744
20749
  __extends(GraphQLService, _super);
20745
20750
  function GraphQLService(client, geinsSettings) {
20746
20751
  return _super.call(this, client, geinsSettings) || this;
20747
20752
  }
20748
20753
  GraphQLService.prototype.verifyQueryOptions = function (options) {
20749
- var _a, _b, _c, _d;
20750
- if (!options.query) {
20751
- throw new Error('Query is required');
20752
- }
20753
- if (!(((_d = (_c = (_b = (_a = options.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.variableDefinitions) === null || _d === void 0 ? void 0 : _d.length) > 0)) {
20754
- console.log('NO VARS');
20755
- return options;
20756
- }
20757
- var queryOptions = __assign({}, options);
20754
+ var _a, _b, _c, _d, _e;
20755
+ var returnOptions = __assign({}, options);
20756
+ if (!options.query && !options.queryAsString) {
20757
+ throw new Error('Query or queryAsString is required');
20758
+ }
20759
+ // check if query is a string and convert it to a gql object
20760
+ typeof returnOptions.query === 'string' && (returnOptions.query = gql(options.queryAsString || ''));
20761
+ var definition = (_b = (_a = returnOptions.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0];
20762
+ if (!definition ||
20763
+ definition.kind !== 'OperationDefinition' ||
20764
+ !(((_d = (_c = definition.variableDefinitions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0)) {
20765
+ return returnOptions;
20766
+ }
20767
+ var queryOptions = __assign({}, returnOptions);
20768
+ var queryDocument = queryOptions.query;
20758
20769
  queryOptions.variables = this.createVariables(queryOptions.variables);
20759
- var queryVars = queryOptions.query.definitions[0].variableDefinitions.map(function (v) { return v.variable.name.value; });
20770
+ var queryVars = ((_e = queryDocument.definitions[0].variableDefinitions) === null || _e === void 0 ? void 0 : _e.map(function (v) { return v.variable.name.value; })) || [];
20760
20771
  var providedVars = Object.keys(queryOptions.variables);
20761
20772
  providedVars.forEach(function (v) {
20762
- if (!queryVars.includes(v)) {
20773
+ if (queryVars && !queryVars.includes(v)) {
20763
20774
  delete queryOptions.variables[v];
20764
20775
  }
20765
20776
  });
20766
20777
  return queryOptions;
20767
20778
  };
20768
20779
  /**
20769
- * Generic method to run any GraphQL query
20770
- * @param query - The GraphQL query DocumentNode or gql query object
20771
- * @param variables - Variables to pass to the query
20772
- * @param options - Optional options like fetchPolicy, pollInterval, etc.
20773
- * @returns The result data of the query or null
20780
+ * Executes a GraphQL query with the provided options.
20781
+ * @param options - The options for the GraphQL query.
20782
+ * @returns A promise that resolves to the query result or null if an error occurs.
20774
20783
  */
20775
20784
  GraphQLService.prototype.query = function (options) {
20776
20785
  return __awaiter(this, void 0, void 0, function () {
@@ -20792,17 +20801,15 @@ var GraphQLService = /** @class */ (function (_super) {
20792
20801
  error_1 = _b.sent();
20793
20802
  console.error('Query error:', error_1);
20794
20803
  return [2 /*return*/, null];
20795
- case 4: return [2 /*return*/, null];
20804
+ case 4: return [2 /*return*/];
20796
20805
  }
20797
20806
  });
20798
20807
  });
20799
20808
  };
20800
20809
  /**
20801
- * Generic method to run any GraphQL mutation
20802
- * @param mutation - The GraphQL mutation DocumentNode or gql mutation object
20803
- * @param variables - Variables to pass to the mutation
20804
- * @param options - Optional options like fetchPolicy, etc.
20805
- * @returns The result data of the mutation or null
20810
+ * Executes a GraphQL mutation with the provided options.
20811
+ * @param options - The options for the GraphQL mutation.
20812
+ * @returns A promise that resolves to the mutation result or null if an error occurs.
20806
20813
  */
20807
20814
  GraphQLService.prototype.mutation = function (options) {
20808
20815
  return __awaiter(this, void 0, void 0, function () {
package/dist/index.esm.js CHANGED
@@ -16310,15 +16310,18 @@ var MerchantApiClient = /** @class */ (function () {
16310
16310
  }
16311
16311
  return FetchPolicyOptions.NETWORK_ONLY;
16312
16312
  };
16313
- MerchantApiClient.prototype.getOperationObject = function (operationType, document, variables, options) {
16313
+ MerchantApiClient.prototype.getOperationObject = function (operationType, operationOptions) {
16314
16314
  var _a;
16315
16315
  var _b;
16316
- if (variables === void 0) { variables = {}; }
16317
- if (options === void 0) { options = {}; }
16316
+ var query = operationOptions.query, queryAsString = operationOptions.queryAsString, variables = operationOptions.variables, requestOptions = operationOptions.requestOptions;
16317
+ var queryDocument = query || gql(queryAsString || '');
16318
+ var options = requestOptions || {};
16318
16319
  var token = this._userToken || ((_b = this._cookieService) === null || _b === void 0 ? void 0 : _b.get(AUTH_COOKIES.USER_AUTH));
16319
- // remove typename from variables
16320
+ if (!queryDocument) {
16321
+ throw new Error('Query is required');
16322
+ }
16320
16323
  var operationObj = (_a = {},
16321
- _a[operationType] = document,
16324
+ _a[operationType] = queryDocument,
16322
16325
  _a.variables = variables,
16323
16326
  _a.fetchPolicy = this.getFetchPolicy(operationType, options.fetchPolicy),
16324
16327
  _a.pollInterval = options.pollInterval || this.pollInterval,
@@ -16334,20 +16337,18 @@ var MerchantApiClient = /** @class */ (function () {
16334
16337
  };
16335
16338
  MerchantApiClient.prototype.runQuery = function (options) {
16336
16339
  return __awaiter(this, void 0, void 0, function () {
16337
- var query, variables, requestOptions, q;
16340
+ var q;
16338
16341
  return __generator(this, function (_a) {
16339
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16340
- q = this.getOperationObject(OperationType.QUERY, query, variables, requestOptions);
16342
+ q = this.getOperationObject(OperationType.QUERY, options);
16341
16343
  return [2 /*return*/, this._apolloClient.query(q)];
16342
16344
  });
16343
16345
  });
16344
16346
  };
16345
16347
  MerchantApiClient.prototype.runMutation = function (options) {
16346
16348
  return __awaiter(this, void 0, void 0, function () {
16347
- var query, variables, requestOptions, q;
16349
+ var q;
16348
16350
  return __generator(this, function (_a) {
16349
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16350
- q = this.getOperationObject(OperationType.MUTATION, query, variables, requestOptions);
16351
+ q = this.getOperationObject(OperationType.MUTATION, options);
16351
16352
  return [2 /*return*/, this._apolloClient.mutate(q)];
16352
16353
  });
16353
16354
  });
@@ -20738,37 +20739,45 @@ var ChannelService = /** @class */ (function (_super) {
20738
20739
  return ChannelService;
20739
20740
  }(BaseApiService));
20740
20741
 
20742
+ /**
20743
+ * GraphQLService class provides methods to interact with a GraphQL API.
20744
+ * It extends the BaseApiService and includes methods for querying and mutating data.
20745
+ */
20741
20746
  var GraphQLService = /** @class */ (function (_super) {
20742
20747
  __extends(GraphQLService, _super);
20743
20748
  function GraphQLService(client, geinsSettings) {
20744
20749
  return _super.call(this, client, geinsSettings) || this;
20745
20750
  }
20746
20751
  GraphQLService.prototype.verifyQueryOptions = function (options) {
20747
- var _a, _b, _c, _d;
20748
- if (!options.query) {
20749
- throw new Error('Query is required');
20750
- }
20751
- if (!(((_d = (_c = (_b = (_a = options.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.variableDefinitions) === null || _d === void 0 ? void 0 : _d.length) > 0)) {
20752
- console.log('NO VARS');
20753
- return options;
20754
- }
20755
- var queryOptions = __assign({}, options);
20752
+ var _a, _b, _c, _d, _e;
20753
+ var returnOptions = __assign({}, options);
20754
+ if (!options.query && !options.queryAsString) {
20755
+ throw new Error('Query or queryAsString is required');
20756
+ }
20757
+ // check if query is a string and convert it to a gql object
20758
+ typeof returnOptions.query === 'string' && (returnOptions.query = gql(options.queryAsString || ''));
20759
+ var definition = (_b = (_a = returnOptions.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0];
20760
+ if (!definition ||
20761
+ definition.kind !== 'OperationDefinition' ||
20762
+ !(((_d = (_c = definition.variableDefinitions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0)) {
20763
+ return returnOptions;
20764
+ }
20765
+ var queryOptions = __assign({}, returnOptions);
20766
+ var queryDocument = queryOptions.query;
20756
20767
  queryOptions.variables = this.createVariables(queryOptions.variables);
20757
- var queryVars = queryOptions.query.definitions[0].variableDefinitions.map(function (v) { return v.variable.name.value; });
20768
+ var queryVars = ((_e = queryDocument.definitions[0].variableDefinitions) === null || _e === void 0 ? void 0 : _e.map(function (v) { return v.variable.name.value; })) || [];
20758
20769
  var providedVars = Object.keys(queryOptions.variables);
20759
20770
  providedVars.forEach(function (v) {
20760
- if (!queryVars.includes(v)) {
20771
+ if (queryVars && !queryVars.includes(v)) {
20761
20772
  delete queryOptions.variables[v];
20762
20773
  }
20763
20774
  });
20764
20775
  return queryOptions;
20765
20776
  };
20766
20777
  /**
20767
- * Generic method to run any GraphQL query
20768
- * @param query - The GraphQL query DocumentNode or gql query object
20769
- * @param variables - Variables to pass to the query
20770
- * @param options - Optional options like fetchPolicy, pollInterval, etc.
20771
- * @returns The result data of the query or null
20778
+ * Executes a GraphQL query with the provided options.
20779
+ * @param options - The options for the GraphQL query.
20780
+ * @returns A promise that resolves to the query result or null if an error occurs.
20772
20781
  */
20773
20782
  GraphQLService.prototype.query = function (options) {
20774
20783
  return __awaiter(this, void 0, void 0, function () {
@@ -20790,17 +20799,15 @@ var GraphQLService = /** @class */ (function (_super) {
20790
20799
  error_1 = _b.sent();
20791
20800
  console.error('Query error:', error_1);
20792
20801
  return [2 /*return*/, null];
20793
- case 4: return [2 /*return*/, null];
20802
+ case 4: return [2 /*return*/];
20794
20803
  }
20795
20804
  });
20796
20805
  });
20797
20806
  };
20798
20807
  /**
20799
- * Generic method to run any GraphQL mutation
20800
- * @param mutation - The GraphQL mutation DocumentNode or gql mutation object
20801
- * @param variables - Variables to pass to the mutation
20802
- * @param options - Optional options like fetchPolicy, etc.
20803
- * @returns The result data of the mutation or null
20808
+ * Executes a GraphQL mutation with the provided options.
20809
+ * @param options - The options for the GraphQL mutation.
20810
+ * @returns A promise that resolves to the mutation result or null if an error occurs.
20804
20811
  */
20805
20812
  GraphQLService.prototype.mutation = function (options) {
20806
20813
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geins/crm",
3
- "version": "0.3.4",
3
+ "version": "0.3.5-canary",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,13 +14,13 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@apollo/client": "^3.11.8",
17
- "@geins/core": "0.3.4",
17
+ "@geins/core": "0.3.5-canary",
18
18
  "crypto-js": "^4.2.0",
19
19
  "graphql": "^16.9.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@geins/eslint-config": "*",
23
- "@geins/types": "0.3.4",
22
+ "@geins/eslint-config": "0.1.6-canary",
23
+ "@geins/types": "0.3.5-canary",
24
24
  "@rollup/plugin-commonjs": "^28.0.0",
25
25
  "@rollup/plugin-node-resolve": "^15.3.0",
26
26
  "@rollup/plugin-typescript": "^12.1.0",