@geins/cms 0.3.4-canary → 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.
@@ -2,5 +2,5 @@ yarn run v1.22.22
2
2
  $ rollup -c
3
3
  
4
4
  src/index.ts → dist/index.cjs, dist/index.esm.js...
5
- created dist/index.cjs, dist/index.esm.js in 8.2s
6
- Done in 9.02s.
5
+ created dist/index.cjs, dist/index.esm.js in 8.9s
6
+ Done in 9.83s.
package/CHANGELOG.md CHANGED
@@ -1,14 +1,26 @@
1
1
  # @geins/cms
2
2
 
3
- ## 0.3.4-canary
3
+ ## 0.3.5-canary
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - d666708: added settingvars to GraphQLService
8
+ - 2158dcd: Possiblity to use string as query for the merchantAPI
8
9
  - 5f86eeb: ci fixes
9
10
  - Updated dependencies [d666708]
11
+ - Updated dependencies [2158dcd]
10
12
  - Updated dependencies [5f86eeb]
11
- - @geins/core@0.3.4-canary
13
+ - @geins/core@0.3.5-canary
14
+
15
+ ## 0.3.4
16
+
17
+ ### Patch Changes
18
+
19
+ - 3cf633e: added settingvars to GraphQLService
20
+ - 3cf633e: ci fixes
21
+ - Updated dependencies [3cf633e]
22
+ - Updated dependencies [3cf633e]
23
+ - @geins/core@0.3.4
12
24
 
13
25
  ## 0.3.3
14
26
 
package/dist/index.cjs CHANGED
@@ -16236,15 +16236,18 @@ var MerchantApiClient = /** @class */ (function () {
16236
16236
  }
16237
16237
  return FetchPolicyOptions.NETWORK_ONLY;
16238
16238
  };
16239
- MerchantApiClient.prototype.getOperationObject = function (operationType, document, variables, options) {
16239
+ MerchantApiClient.prototype.getOperationObject = function (operationType, operationOptions) {
16240
16240
  var _a;
16241
16241
  var _b;
16242
- if (variables === void 0) { variables = {}; }
16243
- if (options === void 0) { options = {}; }
16242
+ var query = operationOptions.query, queryAsString = operationOptions.queryAsString, variables = operationOptions.variables, requestOptions = operationOptions.requestOptions;
16243
+ var queryDocument = query || gql(queryAsString || '');
16244
+ var options = requestOptions || {};
16244
16245
  var token = this._userToken || ((_b = this._cookieService) === null || _b === void 0 ? void 0 : _b.get(AUTH_COOKIES.USER_AUTH));
16245
- // remove typename from variables
16246
+ if (!queryDocument) {
16247
+ throw new Error('Query is required');
16248
+ }
16246
16249
  var operationObj = (_a = {},
16247
- _a[operationType] = document,
16250
+ _a[operationType] = queryDocument,
16248
16251
  _a.variables = variables,
16249
16252
  _a.fetchPolicy = this.getFetchPolicy(operationType, options.fetchPolicy),
16250
16253
  _a.pollInterval = options.pollInterval || this.pollInterval,
@@ -16260,20 +16263,18 @@ var MerchantApiClient = /** @class */ (function () {
16260
16263
  };
16261
16264
  MerchantApiClient.prototype.runQuery = function (options) {
16262
16265
  return __awaiter(this, void 0, void 0, function () {
16263
- var query, variables, requestOptions, q;
16266
+ var q;
16264
16267
  return __generator(this, function (_a) {
16265
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16266
- q = this.getOperationObject(OperationType.QUERY, query, variables, requestOptions);
16268
+ q = this.getOperationObject(OperationType.QUERY, options);
16267
16269
  return [2 /*return*/, this._apolloClient.query(q)];
16268
16270
  });
16269
16271
  });
16270
16272
  };
16271
16273
  MerchantApiClient.prototype.runMutation = function (options) {
16272
16274
  return __awaiter(this, void 0, void 0, function () {
16273
- var query, variables, requestOptions, q;
16275
+ var q;
16274
16276
  return __generator(this, function (_a) {
16275
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16276
- q = this.getOperationObject(OperationType.MUTATION, query, variables, requestOptions);
16277
+ q = this.getOperationObject(OperationType.MUTATION, options);
16277
16278
  return [2 /*return*/, this._apolloClient.mutate(q)];
16278
16279
  });
16279
16280
  });
@@ -20664,37 +20665,45 @@ var ChannelService = /** @class */ (function (_super) {
20664
20665
  return ChannelService;
20665
20666
  }(BaseApiService));
20666
20667
 
20668
+ /**
20669
+ * GraphQLService class provides methods to interact with a GraphQL API.
20670
+ * It extends the BaseApiService and includes methods for querying and mutating data.
20671
+ */
20667
20672
  var GraphQLService = /** @class */ (function (_super) {
20668
20673
  __extends(GraphQLService, _super);
20669
20674
  function GraphQLService(client, geinsSettings) {
20670
20675
  return _super.call(this, client, geinsSettings) || this;
20671
20676
  }
20672
20677
  GraphQLService.prototype.verifyQueryOptions = function (options) {
20673
- var _a, _b, _c, _d;
20674
- if (!options.query) {
20675
- throw new Error('Query is required');
20676
- }
20677
- 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)) {
20678
- console.log('NO VARS');
20679
- return options;
20680
- }
20681
- var queryOptions = __assign({}, options);
20678
+ var _a, _b, _c, _d, _e;
20679
+ var returnOptions = __assign({}, options);
20680
+ if (!options.query && !options.queryAsString) {
20681
+ throw new Error('Query or queryAsString is required');
20682
+ }
20683
+ // check if query is a string and convert it to a gql object
20684
+ typeof returnOptions.query === 'string' && (returnOptions.query = gql(options.queryAsString || ''));
20685
+ var definition = (_b = (_a = returnOptions.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0];
20686
+ if (!definition ||
20687
+ definition.kind !== 'OperationDefinition' ||
20688
+ !(((_d = (_c = definition.variableDefinitions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0)) {
20689
+ return returnOptions;
20690
+ }
20691
+ var queryOptions = __assign({}, returnOptions);
20692
+ var queryDocument = queryOptions.query;
20682
20693
  queryOptions.variables = this.createVariables(queryOptions.variables);
20683
- var queryVars = queryOptions.query.definitions[0].variableDefinitions.map(function (v) { return v.variable.name.value; });
20694
+ var queryVars = ((_e = queryDocument.definitions[0].variableDefinitions) === null || _e === void 0 ? void 0 : _e.map(function (v) { return v.variable.name.value; })) || [];
20684
20695
  var providedVars = Object.keys(queryOptions.variables);
20685
20696
  providedVars.forEach(function (v) {
20686
- if (!queryVars.includes(v)) {
20697
+ if (queryVars && !queryVars.includes(v)) {
20687
20698
  delete queryOptions.variables[v];
20688
20699
  }
20689
20700
  });
20690
20701
  return queryOptions;
20691
20702
  };
20692
20703
  /**
20693
- * Generic method to run any GraphQL query
20694
- * @param query - The GraphQL query DocumentNode or gql query object
20695
- * @param variables - Variables to pass to the query
20696
- * @param options - Optional options like fetchPolicy, pollInterval, etc.
20697
- * @returns The result data of the query or null
20704
+ * Executes a GraphQL query with the provided options.
20705
+ * @param options - The options for the GraphQL query.
20706
+ * @returns A promise that resolves to the query result or null if an error occurs.
20698
20707
  */
20699
20708
  GraphQLService.prototype.query = function (options) {
20700
20709
  return __awaiter(this, void 0, void 0, function () {
@@ -20716,17 +20725,15 @@ var GraphQLService = /** @class */ (function (_super) {
20716
20725
  error_1 = _b.sent();
20717
20726
  console.error('Query error:', error_1);
20718
20727
  return [2 /*return*/, null];
20719
- case 4: return [2 /*return*/, null];
20728
+ case 4: return [2 /*return*/];
20720
20729
  }
20721
20730
  });
20722
20731
  });
20723
20732
  };
20724
20733
  /**
20725
- * Generic method to run any GraphQL mutation
20726
- * @param mutation - The GraphQL mutation DocumentNode or gql mutation object
20727
- * @param variables - Variables to pass to the mutation
20728
- * @param options - Optional options like fetchPolicy, etc.
20729
- * @returns The result data of the mutation or null
20734
+ * Executes a GraphQL mutation with the provided options.
20735
+ * @param options - The options for the GraphQL mutation.
20736
+ * @returns A promise that resolves to the mutation result or null if an error occurs.
20730
20737
  */
20731
20738
  GraphQLService.prototype.mutation = function (options) {
20732
20739
  return __awaiter(this, void 0, void 0, function () {
package/dist/index.esm.js CHANGED
@@ -16234,15 +16234,18 @@ var MerchantApiClient = /** @class */ (function () {
16234
16234
  }
16235
16235
  return FetchPolicyOptions.NETWORK_ONLY;
16236
16236
  };
16237
- MerchantApiClient.prototype.getOperationObject = function (operationType, document, variables, options) {
16237
+ MerchantApiClient.prototype.getOperationObject = function (operationType, operationOptions) {
16238
16238
  var _a;
16239
16239
  var _b;
16240
- if (variables === void 0) { variables = {}; }
16241
- if (options === void 0) { options = {}; }
16240
+ var query = operationOptions.query, queryAsString = operationOptions.queryAsString, variables = operationOptions.variables, requestOptions = operationOptions.requestOptions;
16241
+ var queryDocument = query || gql(queryAsString || '');
16242
+ var options = requestOptions || {};
16242
16243
  var token = this._userToken || ((_b = this._cookieService) === null || _b === void 0 ? void 0 : _b.get(AUTH_COOKIES.USER_AUTH));
16243
- // remove typename from variables
16244
+ if (!queryDocument) {
16245
+ throw new Error('Query is required');
16246
+ }
16244
16247
  var operationObj = (_a = {},
16245
- _a[operationType] = document,
16248
+ _a[operationType] = queryDocument,
16246
16249
  _a.variables = variables,
16247
16250
  _a.fetchPolicy = this.getFetchPolicy(operationType, options.fetchPolicy),
16248
16251
  _a.pollInterval = options.pollInterval || this.pollInterval,
@@ -16258,20 +16261,18 @@ var MerchantApiClient = /** @class */ (function () {
16258
16261
  };
16259
16262
  MerchantApiClient.prototype.runQuery = function (options) {
16260
16263
  return __awaiter(this, void 0, void 0, function () {
16261
- var query, variables, requestOptions, q;
16264
+ var q;
16262
16265
  return __generator(this, function (_a) {
16263
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16264
- q = this.getOperationObject(OperationType.QUERY, query, variables, requestOptions);
16266
+ q = this.getOperationObject(OperationType.QUERY, options);
16265
16267
  return [2 /*return*/, this._apolloClient.query(q)];
16266
16268
  });
16267
16269
  });
16268
16270
  };
16269
16271
  MerchantApiClient.prototype.runMutation = function (options) {
16270
16272
  return __awaiter(this, void 0, void 0, function () {
16271
- var query, variables, requestOptions, q;
16273
+ var q;
16272
16274
  return __generator(this, function (_a) {
16273
- query = options.query, variables = options.variables, requestOptions = options.requestOptions;
16274
- q = this.getOperationObject(OperationType.MUTATION, query, variables, requestOptions);
16275
+ q = this.getOperationObject(OperationType.MUTATION, options);
16275
16276
  return [2 /*return*/, this._apolloClient.mutate(q)];
16276
16277
  });
16277
16278
  });
@@ -20662,37 +20663,45 @@ var ChannelService = /** @class */ (function (_super) {
20662
20663
  return ChannelService;
20663
20664
  }(BaseApiService));
20664
20665
 
20666
+ /**
20667
+ * GraphQLService class provides methods to interact with a GraphQL API.
20668
+ * It extends the BaseApiService and includes methods for querying and mutating data.
20669
+ */
20665
20670
  var GraphQLService = /** @class */ (function (_super) {
20666
20671
  __extends(GraphQLService, _super);
20667
20672
  function GraphQLService(client, geinsSettings) {
20668
20673
  return _super.call(this, client, geinsSettings) || this;
20669
20674
  }
20670
20675
  GraphQLService.prototype.verifyQueryOptions = function (options) {
20671
- var _a, _b, _c, _d;
20672
- if (!options.query) {
20673
- throw new Error('Query is required');
20674
- }
20675
- 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)) {
20676
- console.log('NO VARS');
20677
- return options;
20678
- }
20679
- var queryOptions = __assign({}, options);
20676
+ var _a, _b, _c, _d, _e;
20677
+ var returnOptions = __assign({}, options);
20678
+ if (!options.query && !options.queryAsString) {
20679
+ throw new Error('Query or queryAsString is required');
20680
+ }
20681
+ // check if query is a string and convert it to a gql object
20682
+ typeof returnOptions.query === 'string' && (returnOptions.query = gql(options.queryAsString || ''));
20683
+ var definition = (_b = (_a = returnOptions.query) === null || _a === void 0 ? void 0 : _a.definitions) === null || _b === void 0 ? void 0 : _b[0];
20684
+ if (!definition ||
20685
+ definition.kind !== 'OperationDefinition' ||
20686
+ !(((_d = (_c = definition.variableDefinitions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0)) {
20687
+ return returnOptions;
20688
+ }
20689
+ var queryOptions = __assign({}, returnOptions);
20690
+ var queryDocument = queryOptions.query;
20680
20691
  queryOptions.variables = this.createVariables(queryOptions.variables);
20681
- var queryVars = queryOptions.query.definitions[0].variableDefinitions.map(function (v) { return v.variable.name.value; });
20692
+ var queryVars = ((_e = queryDocument.definitions[0].variableDefinitions) === null || _e === void 0 ? void 0 : _e.map(function (v) { return v.variable.name.value; })) || [];
20682
20693
  var providedVars = Object.keys(queryOptions.variables);
20683
20694
  providedVars.forEach(function (v) {
20684
- if (!queryVars.includes(v)) {
20695
+ if (queryVars && !queryVars.includes(v)) {
20685
20696
  delete queryOptions.variables[v];
20686
20697
  }
20687
20698
  });
20688
20699
  return queryOptions;
20689
20700
  };
20690
20701
  /**
20691
- * Generic method to run any GraphQL query
20692
- * @param query - The GraphQL query DocumentNode or gql query object
20693
- * @param variables - Variables to pass to the query
20694
- * @param options - Optional options like fetchPolicy, pollInterval, etc.
20695
- * @returns The result data of the query or null
20702
+ * Executes a GraphQL query with the provided options.
20703
+ * @param options - The options for the GraphQL query.
20704
+ * @returns A promise that resolves to the query result or null if an error occurs.
20696
20705
  */
20697
20706
  GraphQLService.prototype.query = function (options) {
20698
20707
  return __awaiter(this, void 0, void 0, function () {
@@ -20714,17 +20723,15 @@ var GraphQLService = /** @class */ (function (_super) {
20714
20723
  error_1 = _b.sent();
20715
20724
  console.error('Query error:', error_1);
20716
20725
  return [2 /*return*/, null];
20717
- case 4: return [2 /*return*/, null];
20726
+ case 4: return [2 /*return*/];
20718
20727
  }
20719
20728
  });
20720
20729
  });
20721
20730
  };
20722
20731
  /**
20723
- * Generic method to run any GraphQL mutation
20724
- * @param mutation - The GraphQL mutation DocumentNode or gql mutation object
20725
- * @param variables - Variables to pass to the mutation
20726
- * @param options - Optional options like fetchPolicy, etc.
20727
- * @returns The result data of the mutation or null
20732
+ * Executes a GraphQL mutation with the provided options.
20733
+ * @param options - The options for the GraphQL mutation.
20734
+ * @returns A promise that resolves to the mutation result or null if an error occurs.
20728
20735
  */
20729
20736
  GraphQLService.prototype.mutation = function (options) {
20730
20737
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geins/cms",
3
- "version": "0.3.4-canary",
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",
@@ -15,13 +15,13 @@
15
15
  "dependencies": {
16
16
  "@apollo/client": "^3.11.8",
17
17
  "graphql": "^16.9.0",
18
- "@geins/core": "0.3.4-canary"
18
+ "@geins/core": "0.3.5-canary"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@rollup/plugin-commonjs": "^28.0.0",
22
22
  "@rollup/plugin-node-resolve": "^15.3.0",
23
23
  "@rollup/plugin-typescript": "^12.1.0",
24
- "@geins/eslint-config": "0.1.5-canary",
24
+ "@geins/eslint-config": "0.1.6-canary",
25
25
  "typescript": "^5.6.2",
26
26
  "eslint": "^9.11.1"
27
27
  }