From 6b0b2abe592bf372220082b0092ec2c65e4ba30c Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Tue, 5 Mar 2024 12:20:09 -0700 Subject: [PATCH 1/3] update graphql --- packages/data-types/package.json | 2 +- packages/data-types/src/data-type.ts | 8 ++-- packages/data-types/src/graphql-helper.ts | 22 +++++----- packages/data-types/src/types/base-type.ts | 4 +- .../data-types/test/data-type-graphql-spec.ts | 40 ++++++++++--------- yarn.lock | 15 ++----- 6 files changed, 44 insertions(+), 47 deletions(-) diff --git a/packages/data-types/package.json b/packages/data-types/package.json index d7757a7566c..fc08b7a3f79 100644 --- a/packages/data-types/package.json +++ b/packages/data-types/package.json @@ -28,7 +28,7 @@ "dependencies": { "@terascope/types": "^0.14.0", "@terascope/utils": "^0.55.0", - "graphql": "^14.7.0", + "graphql": "^16.8.1", "lodash": "^4.17.21", "yargs": "^17.7.2" }, diff --git a/packages/data-types/src/data-type.ts b/packages/data-types/src/data-type.ts index 09a15281d07..82b6909f305 100644 --- a/packages/data-types/src/data-type.ts +++ b/packages/data-types/src/data-type.ts @@ -8,7 +8,7 @@ import { xLuceneTypeConfig } from '@terascope/types'; import defaultsDeep from 'lodash/defaultsDeep'; -import { formatSchema, formatGQLComment } from './graphql-helper'; +import { formatSchema, formatGQLDescription } from './graphql-helper'; import * as i from './interfaces'; import BaseType from './types/base-type'; import * as utils from './utils'; @@ -233,13 +233,13 @@ export class DataType { if (references.length) { baseProperties.push(utils.joinStrings( - formatGQLComment('references and virtual fields'), + formatGQLDescription('references and virtual fields'), references )); } const baseType = utils.joinStrings( - formatGQLComment(description), + formatGQLDescription(description), `type ${typeName} { ${utils.joinStrings(baseProperties)} }` @@ -249,7 +249,7 @@ export class DataType { if (createInputType) { inputType = utils.joinStrings( - formatGQLComment(description, `Input for ${typeName}`), + formatGQLDescription(description, `Input for ${typeName}`), `input ${inputName} { ${utils.joinStrings(inputProperties)} }` diff --git a/packages/data-types/src/graphql-helper.ts b/packages/data-types/src/graphql-helper.ts index eed53caa626..ce2b6e92638 100644 --- a/packages/data-types/src/graphql-helper.ts +++ b/packages/data-types/src/graphql-helper.ts @@ -2,12 +2,8 @@ import * as ts from '@terascope/utils'; import { buildSchema, printSchema } from 'graphql/utilities'; export function formatSchema(schemaStr: string, removeScalars = false): string { - const schema = buildSchema(schemaStr, { - commentDescriptions: true, - }); - const result = printSchema(schema, { - commentDescriptions: true - }); + const schema = buildSchema(schemaStr); + const result = printSchema(schema!); if (removeScalars) { return result.replace(/\s*scalar \w+/g, ''); @@ -15,17 +11,21 @@ export function formatSchema(schemaStr: string, removeScalars = false): string { return result; } -export function formatGQLComment(desc?: string, prefix?: string): string { +export function formatGQLDescription(desc?: string, prefix?: string): string { let description = ts.trim(desc); if (prefix) { description = description ? `${prefix} - ${description}` : prefix; } if (!description) return ''; - return description + const trimmedLines = description .split('\n') - .map((str) => ts.trim(str).replace(/^#/, '').trim()) + .map((str) => str.trim()) .filter(Boolean) - .map((str) => `# ${str}`) - .join('\n'); + .map((str) => `${str}`); + + if (trimmedLines.length > 1) { + return `"""${trimmedLines.join('\n')}"""`; + } + return `""" ${trimmedLines[0]} """`; } diff --git a/packages/data-types/src/types/base-type.ts b/packages/data-types/src/types/base-type.ts index 6985d566d1a..250a89f5405 100644 --- a/packages/data-types/src/types/base-type.ts +++ b/packages/data-types/src/types/base-type.ts @@ -3,7 +3,7 @@ import { } from '@terascope/types'; import { castArray } from '@terascope/utils'; import { GraphQLType, TypeESMapping } from '../interfaces'; -import { formatGQLComment } from '../graphql-helper'; +import { formatGQLDescription } from '../graphql-helper'; export interface IBaseType { new(field: string, config: DataTypeFieldConfig): BaseType; @@ -72,5 +72,5 @@ function makeCustomTypes(customType?: string|(string[])): string[] { export function formatGQLType(type: string, desc?: string):string { if (!desc) return type; - return `${formatGQLComment(desc)}\n${type}`; + return `${formatGQLDescription(desc)}\n${type}`; } diff --git a/packages/data-types/test/data-type-graphql-spec.ts b/packages/data-types/test/data-type-graphql-spec.ts index 3fc634a7b79..06d2e0dbaa0 100644 --- a/packages/data-types/test/data-type-graphql-spec.ts +++ b/packages/data-types/test/data-type-graphql-spec.ts @@ -32,20 +32,24 @@ describe('DataType (graphql)', () => { lon: String! } - # My test data type - # some extra desc + """ + My test data type + some extra desc + """ type myType { date: String - # example obj test + " example obj test " example_obj: JSONObject - # # hello + """ + ## hello # test + """ hello: String - # ip test + " ip test " ip: String - # location test + " location test " location: DTGeoPointV1 - # some number test + " some number test " someNum: Float } `); @@ -79,12 +83,12 @@ describe('DataType (graphql)', () => { foo: String } - # nested field test description + """ nested field test description """ type ObjType { example: DTObjTypeExampleV1 } - # Input for ObjType - nested field test description + """ Input for ObjType - nested field test description """ input ObjTypeInput { example: DTObjTypeExampleInputV1 } @@ -137,7 +141,7 @@ describe('DataType (graphql)', () => { expect(() => { new DataType(typeConfig).toGraphQL(); - }).toThrowError('No typeName was specified to create the graphql type representing this data structure'); + }).toThrow('No typeName was specified to create the graphql type representing this data structure'); }); }); @@ -274,7 +278,7 @@ describe('DataType (graphql)', () => { someNum: Float } - # Input for first_type + """ Input for first_type """ input first_type_input { date: String hello: String @@ -291,7 +295,7 @@ describe('DataType (graphql)', () => { otherLocation: [[DTGeoBoundaryV1]] } - # Input for second_type + """ Input for second_type """ input second_type_input { bool: Boolean foo: DT_second_type_foo_input_V1 @@ -332,7 +336,7 @@ describe('DataType (graphql)', () => { name: String } - # Input for TestRecord + """ Input for TestRecord """ input TestRecordInput { description: String name: String @@ -399,7 +403,7 @@ describe('DataType (graphql)', () => { expect(() => { DataType.mergeGraphQLDataTypes(types, { removeScalars: true }); - }).toThrowError(/Unable to process duplicate DataType "Hello"/); + }).toThrow(/Unable to process duplicate DataType "Hello"/); }); it('should throw when given a type without a type name', () => { @@ -416,7 +420,7 @@ describe('DataType (graphql)', () => { expect(() => { DataType.mergeGraphQLDataTypes(types); - }).toThrowError(/Unable to process DataType with missing type name/); + }).toThrow(/Unable to process DataType with missing type name/); }); it('should be able to combine mulitple types together with references', () => { @@ -471,7 +475,7 @@ describe('DataType (graphql)', () => { type Info { id: String - # references and virtual fields + """ references and virtual fields """ info(query: String): Info } @@ -481,7 +485,7 @@ describe('DataType (graphql)', () => { ip: String location: DTGeoPointV1 long_number: Float - # references and virtual fields + """ references and virtual fields """ info(query: String): Info num_parents: Int } @@ -491,7 +495,7 @@ describe('DataType (graphql)', () => { obj: JSONObject other_location: DTGeoPointV1 some_date: String - # references and virtual fields + """ references and virtual fields """ info(query: String): Info children: ChildType } diff --git a/yarn.lock b/yarn.lock index 221093ade73..ace7a88512a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7443,12 +7443,10 @@ graphlib@^2.1.8: dependencies: lodash "^4.17.15" -graphql@^14.7.0: - version "14.7.0" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.7.0.tgz#7fa79a80a69be4a31c27dda824dc04dac2035a72" - integrity sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA== - dependencies: - iterall "^1.2.2" +graphql@^16.8.1: + version "16.8.1" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" + integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== grouped-queue@^2.0.0: version "2.0.0" @@ -8468,11 +8466,6 @@ isurl@^1.0.0-alpha5: has-to-string-tag-x "^1.2.0" is-object "^1.0.1" -iterall@^1.2.2: - version "1.3.0" - resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea" - integrity sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg== - iterate-object@^1.3.2: version "1.3.4" resolved "https://registry.yarnpkg.com/iterate-object/-/iterate-object-1.3.4.tgz#fa50b1d9e58e340a7dd6b4c98c8a5e182e790096" From 8830371a45d72d599832dc86a60fd20f1e2b8eea Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Fri, 6 Sep 2024 15:16:53 -0700 Subject: [PATCH 2/3] update graphql --- packages/data-types/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/data-types/package.json b/packages/data-types/package.json index b2dc11af081..1fdd72409a2 100644 --- a/packages/data-types/package.json +++ b/packages/data-types/package.json @@ -29,7 +29,7 @@ "dependencies": { "@terascope/types": "^1.1.0", "@terascope/utils": "^1.1.0", - "graphql": "^16.8.1", + "graphql": "^16.9.0", "lodash": "^4.17.21", "yargs": "^17.7.2" }, diff --git a/yarn.lock b/yarn.lock index f9817b6490d..f9ae38eacef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7313,10 +7313,10 @@ graphlib@^2.1.8: dependencies: lodash "^4.17.15" -graphql@^16.8.1: - version "16.8.1" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.1.tgz#1930a965bef1170603702acdb68aedd3f3cf6f07" - integrity sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw== +graphql@^16.9.0: + version "16.9.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.9.0.tgz#1c310e63f16a49ce1fbb230bd0a000e99f6f115f" + integrity sha512-GGTKBX4SD7Wdb8mqeDLni2oaRGYQWjWHGKPQ24ZMnUtKfcsVoiv4uX8+LJr1K6U5VW2Lu1BwJnj7uiori0YtRw== grouped-queue@^2.0.0: version "2.0.0" From 3d6f8b6c8683917d55b6745db15651915837c9b9 Mon Sep 17 00:00:00 2001 From: Lesley Dreyer Date: Thu, 12 Sep 2024 17:49:08 -0700 Subject: [PATCH 3/3] bump: (patch) @terascope/data-types@1.1.1, @terascope/data-mate@1.1.1 bump: (patch) elasticsearch-store@1.1.1, terafoundation@1.3.1 bump: (patch) ts-transforms@1.1.1 --- e2e/package.json | 2 +- packages/data-mate/package.json | 4 ++-- packages/data-types/package.json | 2 +- packages/elasticsearch-api/package.json | 2 +- packages/elasticsearch-store/package.json | 6 +++--- packages/terafoundation/package.json | 4 ++-- packages/teraslice/package.json | 2 +- packages/ts-transforms/package.json | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/e2e/package.json b/e2e/package.json index e147a49cb00..872c8cc5b1b 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -45,7 +45,7 @@ "devDependencies": { "@terascope/types": "^1.1.0", "bunyan": "^1.8.15", - "elasticsearch-store": "^1.1.0", + "elasticsearch-store": "^1.1.1", "fs-extra": "^11.2.0", "ms": "^2.1.3", "nanoid": "^3.3.4", diff --git a/packages/data-mate/package.json b/packages/data-mate/package.json index 201d71f64e8..54cd3e7c1b3 100644 --- a/packages/data-mate/package.json +++ b/packages/data-mate/package.json @@ -1,7 +1,7 @@ { "name": "@terascope/data-mate", "displayName": "Data-Mate", - "version": "1.1.0", + "version": "1.1.1", "description": "Library of data validations/transformations", "homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-mate#readme", "repository": { @@ -30,7 +30,7 @@ "test:watch": "ts-scripts test --watch . --" }, "dependencies": { - "@terascope/data-types": "^1.1.0", + "@terascope/data-types": "^1.1.1", "@terascope/types": "^1.1.0", "@terascope/utils": "^1.1.0", "@types/validator": "^13.11.10", diff --git a/packages/data-types/package.json b/packages/data-types/package.json index 1fdd72409a2..46ba87630d3 100644 --- a/packages/data-types/package.json +++ b/packages/data-types/package.json @@ -1,7 +1,7 @@ { "name": "@terascope/data-types", "displayName": "Data Types", - "version": "1.1.0", + "version": "1.1.1", "description": "A library for defining the data structures and mapping", "homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-types#readme", "bugs": { diff --git a/packages/elasticsearch-api/package.json b/packages/elasticsearch-api/package.json index 621b9f00982..6ecc1f3bc70 100644 --- a/packages/elasticsearch-api/package.json +++ b/packages/elasticsearch-api/package.json @@ -33,7 +33,7 @@ "@opensearch-project/opensearch": "^1.2.0", "@types/elasticsearch": "^5.0.43", "elasticsearch": "^15.4.1", - "elasticsearch-store": "^1.1.0", + "elasticsearch-store": "^1.1.1", "elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0", "elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0", "elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0" diff --git a/packages/elasticsearch-store/package.json b/packages/elasticsearch-store/package.json index 38891740293..263ab5dc6fe 100644 --- a/packages/elasticsearch-store/package.json +++ b/packages/elasticsearch-store/package.json @@ -1,7 +1,7 @@ { "name": "elasticsearch-store", "displayName": "Elasticsearch Store", - "version": "1.1.0", + "version": "1.1.1", "description": "An API for managing an elasticsearch index, with versioning and migration support.", "homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-store#readme", "bugs": { @@ -30,8 +30,8 @@ "test:watch": "ts-scripts test --watch . --" }, "dependencies": { - "@terascope/data-mate": "^1.1.0", - "@terascope/data-types": "^1.1.0", + "@terascope/data-mate": "^1.1.1", + "@terascope/data-types": "^1.1.1", "@terascope/types": "^1.1.0", "@terascope/utils": "^1.1.0", "ajv": "^6.12.6", diff --git a/packages/terafoundation/package.json b/packages/terafoundation/package.json index ceb8f731529..22da2332959 100644 --- a/packages/terafoundation/package.json +++ b/packages/terafoundation/package.json @@ -1,7 +1,7 @@ { "name": "terafoundation", "displayName": "Terafoundation", - "version": "1.3.0", + "version": "1.3.1", "description": "A Clustering and Foundation tool for Terascope Tools", "homepage": "https://github.com/terascope/teraslice/tree/master/packages/terafoundation#readme", "bugs": { @@ -37,7 +37,7 @@ "convict-format-with-moment": "^6.2.0", "convict-format-with-validator": "^6.2.0", "elasticsearch": "^15.4.1", - "elasticsearch-store": "^1.1.0", + "elasticsearch-store": "^1.1.1", "express": "^4.20.0", "js-yaml": "^4.1.0", "nanoid": "^3.3.4", diff --git a/packages/teraslice/package.json b/packages/teraslice/package.json index 0dabc90eb5a..166a7f1bcef 100644 --- a/packages/teraslice/package.json +++ b/packages/teraslice/package.json @@ -64,7 +64,7 @@ "semver": "^7.6.3", "socket.io": "^1.7.4", "socket.io-client": "^1.7.4", - "terafoundation": "^1.3.0", + "terafoundation": "^1.3.1", "uuid": "^9.0.1" }, "devDependencies": { diff --git a/packages/ts-transforms/package.json b/packages/ts-transforms/package.json index c8943d03f3b..75763ce0584 100644 --- a/packages/ts-transforms/package.json +++ b/packages/ts-transforms/package.json @@ -1,7 +1,7 @@ { "name": "ts-transforms", "displayName": "TS Transforms", - "version": "1.1.0", + "version": "1.1.1", "description": "An ETL framework built upon xlucene-evaluator", "homepage": "https://github.com/terascope/teraslice/tree/master/packages/ts-transforms#readme", "bugs": { @@ -36,7 +36,7 @@ "test:watch": "ts-scripts test --watch . --" }, "dependencies": { - "@terascope/data-mate": "^1.1.0", + "@terascope/data-mate": "^1.1.1", "@terascope/types": "^1.1.0", "@terascope/utils": "^1.1.0", "awesome-phonenumber": "^2.70.0",