amplience-graphql-codegen-common
Advanced tools
Comparing version 0.2.0 to 1.0.0
import * as graphql from 'graphql'; | ||
import { FieldDefinitionNode, TypeDefinitionNode, ValueNode, DirectiveNode, ObjectValueNode, DefinitionNode, ObjectTypeDefinitionNode, TypeNode } from 'graphql'; | ||
import { FieldDefinitionNode, TypeDefinitionNode, ValueNode, DirectiveNode, ObjectValueNode, DefinitionNode, ObjectTypeDefinitionNode, TypeNode, NamedTypeNode } from 'graphql'; | ||
@@ -10,2 +10,3 @@ declare const hasDirective: (symbol: FieldDefinitionNode | TypeDefinitionNode, name: string) => boolean | undefined; | ||
declare const typeName: (type: TypeNode) => string; | ||
declare const namedType: (type: TypeNode) => NamedTypeNode; | ||
declare const switchArray: <T>(type: TypeNode, { ifArray, other, }: { | ||
@@ -24,4 +25,5 @@ ifArray: (subType: TypeNode) => T; | ||
declare const schemaPrepend: graphql.DocumentNode; | ||
declare const typeUri: (type: TypeDefinitionNode, schemaHost: string) => string; | ||
export { Ensure, combinations, hasDirective, hasProperty, ifNotEmpty, ifValue, isObjectTypeDefinitionNode, isValue, maybeDirective, maybeDirectiveValue, maybeFieldValue, schemaPrepend, switchArray, typeName, typeUri }; | ||
export { Ensure, combinations, hasDirective, hasProperty, ifNotEmpty, ifValue, isObjectTypeDefinitionNode, isValue, maybeDirective, maybeDirectiveValue, maybeFieldValue, namedType, schemaPrepend, switchArray, typeName, typeUri }; |
@@ -33,2 +33,3 @@ "use strict"; | ||
maybeFieldValue: () => maybeFieldValue, | ||
namedType: () => namedType, | ||
schemaPrepend: () => schemaPrepend, | ||
@@ -41,3 +42,2 @@ switchArray: () => switchArray, | ||
var import_change_case = require("change-case"); | ||
var import_graphql_tag = require("graphql-tag"); | ||
@@ -62,10 +62,11 @@ // src/graphql.ts | ||
var isObjectTypeDefinitionNode = (definitionNode) => definitionNode.kind === "ObjectTypeDefinition"; | ||
var typeName = (type) => { | ||
var typeName = (type) => namedType(type).name.value; | ||
var namedType = (type) => { | ||
switch (type.kind) { | ||
case "ListType": | ||
return typeName(type.type); | ||
return namedType(type.type); | ||
case "NamedType": | ||
return type.name.value; | ||
return type; | ||
case "NonNullType": | ||
return typeName(type.type); | ||
return namedType(type.type); | ||
default: | ||
@@ -96,3 +97,4 @@ throw new Error(type.kind); | ||
// src/index.ts | ||
// src/directives.ts | ||
var import_graphql_tag = require("graphql-tag"); | ||
var schemaPrepend = import_graphql_tag.gql` | ||
@@ -103,3 +105,3 @@ scalar AmplienceImage | ||
# Field directives | ||
directive @text( | ||
directive @amplienceText( | ||
minLength: Int | ||
@@ -109,12 +111,16 @@ maxLength: Int | ||
pattern: String | ||
examples: [String!] | ||
) on FIELD_DEFINITION | ||
directive @number(minimum: Int, maximum: Int) on FIELD_DEFINITION | ||
directive @list(minItems: Int, maxItems: Int) on FIELD_DEFINITION | ||
directive @const(item: String, items: [String!]) on FIELD_DEFINITION | ||
directive @link on FIELD_DEFINITION | ||
directive @reference on FIELD_DEFINITION | ||
directive @localized on FIELD_DEFINITION | ||
directive @example(items: [String!]) on FIELD_DEFINITION | ||
directive @amplienceNumber(minimum: Int, maximum: Int) on FIELD_DEFINITION | ||
directive @amplienceList(minItems: Int, maxItems: Int) on FIELD_DEFINITION | ||
directive @amplienceConst(item: String, items: [String!]) on FIELD_DEFINITION | ||
directive @amplienceLink on FIELD_DEFINITION | ||
directive @amplienceReference on FIELD_DEFINITION | ||
directive @amplienceLocalized on FIELD_DEFINITION | ||
directive @amplienceIgnore on FIELD_DEFINITION | ||
directive @amplienceSortable on FIELD_DEFINITION | ||
directive @amplienceFilterable on FIELD_DEFINITION | ||
enum ValidationLevel { | ||
SLOT | ||
CONTENT_TYPE | ||
@@ -124,17 +130,12 @@ HIERARCHY | ||
type Visualization { | ||
label: String! | ||
templated_uri: String! | ||
default: Boolean | ||
} | ||
# Object directives | ||
directive @amplience( | ||
directive @amplienceContentType( | ||
repository: String | ||
validationLevel: ValidationLevel | ||
visualizations: [Visualization!] | ||
kind: ValidationLevel | ||
visualizations: Boolean | ||
icon: String | ||
) on OBJECT | ||
`; | ||
directive @icon(url: String!) on OBJECT | ||
`; | ||
// src/index.ts | ||
var typeUri = (type, schemaHost) => `${schemaHost}/${(0, import_change_case.paramCase)(type.name.value)}`; | ||
@@ -153,2 +154,3 @@ // Annotate the CommonJS export names for ESM import in node: | ||
maybeFieldValue, | ||
namedType, | ||
schemaPrepend, | ||
@@ -155,0 +157,0 @@ switchArray, |
{ | ||
"name": "amplience-graphql-codegen-common", | ||
"author": "Lab Digital", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"private": false, | ||
@@ -27,3 +27,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "b074ad9bbd2473ec1943b12ee46d8b7ce2e62928" | ||
"gitHead": "8ec548b31ea77c5bdde92f010d48d30f98be4a91" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2980
1
299711
8