@kiwano/core 0.1.2 → 1.0.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.
Files changed (102) hide show
  1. package/{Builder.d.ts → dist/Builder.d.ts} +2 -2
  2. package/{Builder.js → dist/Builder.js} +0 -0
  3. package/{argument.d.ts → dist/argument.d.ts} +1 -1
  4. package/{argument.js → dist/argument.js} +3 -3
  5. package/dist/common.d.ts +13 -0
  6. package/{common.js → dist/common.js} +0 -0
  7. package/{entity → dist/entity}/createInputObjectType.d.ts +0 -0
  8. package/{entity → dist/entity}/createInputObjectType.js +0 -0
  9. package/{entity → dist/entity}/entitySchema.d.ts +44 -34
  10. package/{entity → dist/entity}/entitySchema.js +24 -2
  11. package/{entity → dist/entity}/index.d.ts +0 -0
  12. package/{entity → dist/entity}/index.js +0 -0
  13. package/{entity → dist/entity}/updateInputObjectType.d.ts +0 -0
  14. package/{entity → dist/entity}/updateInputObjectType.js +0 -0
  15. package/{enumType.d.ts → dist/enumType.d.ts} +0 -0
  16. package/{enumType.js → dist/enumType.js} +0 -0
  17. package/{enumValue.d.ts → dist/enumValue.d.ts} +0 -0
  18. package/{enumValue.js → dist/enumValue.js} +0 -0
  19. package/{error → dist/error}/FrameworkError.d.ts +0 -0
  20. package/{error → dist/error}/FrameworkError.js +0 -0
  21. package/{error → dist/error}/index.d.ts +0 -0
  22. package/{error → dist/error}/index.js +0 -0
  23. package/{error → dist/error}/resolver/DataError.d.ts +0 -0
  24. package/{error → dist/error}/resolver/DataError.js +0 -0
  25. package/{error → dist/error}/resolver/ForbiddenError.d.ts +0 -0
  26. package/{error → dist/error}/resolver/ForbiddenError.js +0 -0
  27. package/{error → dist/error}/resolver/InvalidInputError.d.ts +0 -0
  28. package/{error → dist/error}/resolver/InvalidInputError.js +0 -0
  29. package/{error → dist/error}/resolver/NotFoundError.d.ts +0 -0
  30. package/{error → dist/error}/resolver/NotFoundError.js +0 -0
  31. package/{error → dist/error}/resolver/ResolverError.d.ts +0 -0
  32. package/{error → dist/error}/resolver/ResolverError.js +0 -0
  33. package/{error → dist/error}/resolver/index.d.ts +0 -0
  34. package/{error → dist/error}/resolver/index.js +0 -0
  35. package/{field.d.ts → dist/field.d.ts} +1 -1
  36. package/{field.js → dist/field.js} +3 -3
  37. package/{index.d.ts → dist/index.d.ts} +0 -0
  38. package/{index.js → dist/index.js} +0 -0
  39. package/{inputField.d.ts → dist/inputField.d.ts} +1 -1
  40. package/{inputField.js → dist/inputField.js} +3 -3
  41. package/{inputObjectType.d.ts → dist/inputObjectType.d.ts} +4 -4
  42. package/{inputObjectType.js → dist/inputObjectType.js} +0 -0
  43. package/{naming → dist/naming}/common.d.ts +2 -0
  44. package/{naming → dist/naming}/common.js +0 -0
  45. package/{naming → dist/naming}/compact.d.ts +2 -0
  46. package/{naming → dist/naming}/compact.js +6 -0
  47. package/{naming → dist/naming}/descriptive.d.ts +2 -0
  48. package/{naming → dist/naming}/descriptive.js +6 -0
  49. package/{naming → dist/naming}/index.d.ts +0 -0
  50. package/{naming → dist/naming}/index.js +0 -0
  51. package/{naming → dist/naming}/util.d.ts +0 -0
  52. package/{naming → dist/naming}/util.js +0 -0
  53. package/{objectType.d.ts → dist/objectType.d.ts} +0 -0
  54. package/{objectType.js → dist/objectType.js} +0 -0
  55. package/{plugin → dist/plugin}/MultiPlugin.d.ts +0 -0
  56. package/{plugin → dist/plugin}/MultiPlugin.js +0 -0
  57. package/{plugin → dist/plugin}/PluginError.d.ts +0 -0
  58. package/{plugin → dist/plugin}/PluginError.js +0 -0
  59. package/{plugin → dist/plugin}/acl/acl.d.ts +2 -2
  60. package/{plugin → dist/plugin}/acl/acl.js +0 -0
  61. package/{plugin → dist/plugin}/acl/index.d.ts +0 -0
  62. package/{plugin → dist/plugin}/acl/index.js +0 -0
  63. package/{plugin → dist/plugin}/acl/middleware.d.ts +0 -0
  64. package/{plugin → dist/plugin}/acl/middleware.js +0 -0
  65. package/{plugin → dist/plugin}/common.d.ts +0 -0
  66. package/{plugin → dist/plugin}/common.js +0 -0
  67. package/{plugin → dist/plugin}/filter/equals.d.ts +0 -0
  68. package/{plugin → dist/plugin}/filter/equals.js +0 -0
  69. package/{plugin → dist/plugin}/filter/index.d.ts +0 -0
  70. package/{plugin → dist/plugin}/filter/index.js +0 -0
  71. package/{plugin → dist/plugin}/filter/search.d.ts +0 -0
  72. package/{plugin → dist/plugin}/filter/search.js +0 -0
  73. package/{plugin → dist/plugin}/index.d.ts +0 -0
  74. package/{plugin → dist/plugin}/index.js +0 -0
  75. package/{plugin → dist/plugin}/pagination/connection.d.ts +0 -0
  76. package/{plugin → dist/plugin}/pagination/connection.js +0 -0
  77. package/{plugin → dist/plugin}/pagination/firstAfter.d.ts +0 -0
  78. package/{plugin → dist/plugin}/pagination/firstAfter.js +0 -0
  79. package/{plugin → dist/plugin}/pagination/index.d.ts +0 -0
  80. package/{plugin → dist/plugin}/pagination/index.js +0 -0
  81. package/{plugin → dist/plugin}/pagination/items.d.ts +0 -0
  82. package/{plugin → dist/plugin}/pagination/items.js +0 -0
  83. package/{plugin → dist/plugin}/pagination/offsetLimit.d.ts +0 -0
  84. package/{plugin → dist/plugin}/pagination/offsetLimit.js +0 -0
  85. package/{plugin → dist/plugin}/pagination/relay.d.ts +0 -0
  86. package/{plugin → dist/plugin}/pagination/relay.js +0 -0
  87. package/{plugin → dist/plugin}/pagination/simple.d.ts +0 -0
  88. package/{plugin → dist/plugin}/pagination/simple.js +0 -0
  89. package/{plugin → dist/plugin}/sort/index.d.ts +0 -0
  90. package/{plugin → dist/plugin}/sort/index.js +0 -0
  91. package/{plugin → dist/plugin}/sort/sort.d.ts +0 -0
  92. package/{plugin → dist/plugin}/sort/sort.js +0 -0
  93. package/{schema.d.ts → dist/schema.d.ts} +4 -1
  94. package/{schema.js → dist/schema.js} +5 -3
  95. package/{unionType.d.ts → dist/unionType.d.ts} +1 -1
  96. package/{unionType.js → dist/unionType.js} +0 -0
  97. package/{util.d.ts → dist/util.d.ts} +0 -0
  98. package/{util.js → dist/util.js} +0 -0
  99. package/package.json +15 -11
  100. package/LICENSE +0 -21
  101. package/README.md +0 -1
  102. package/common.d.ts +0 -13
@@ -6,8 +6,8 @@ import { Configurator, OptionalPromise } from "./common";
6
6
  import { AbstractSchemaBuilder } from "./schema";
7
7
  export declare class BuilderError extends FrameworkError {
8
8
  }
9
- export declare type BuilderOrConfiguratorOrName<T> = T | Configurator<T> | string;
10
- export declare type BuilderName = string | (() => string);
9
+ export type BuilderOrConfiguratorOrName<T> = T | Configurator<T> | string;
10
+ export type BuilderName = string | (() => string);
11
11
  export declare const builderInfoExtensionName = "$builder";
12
12
  export default abstract class Builder<RT> {
13
13
  protected _name?: BuilderName;
File without changes
@@ -1,7 +1,7 @@
1
1
  import { GraphQLArgumentConfig, GraphQLInputType } from "graphql/type/definition";
2
2
  import Builder, { BuildContext, FinalizeContext, BuilderName } from "./Builder";
3
3
  import { Plugin } from "./plugin";
4
- export declare type ArgumentType = string | GraphQLInputType;
4
+ export type ArgumentType = string | GraphQLInputType;
5
5
  export interface ArgumentBuilderInfo {
6
6
  name: string;
7
7
  type: ArgumentType;
@@ -84,12 +84,12 @@ class ArgumentBuilder extends Builder_1.default {
84
84
  let type = (0, lodash_1.isString)(this._type) ? context.getType(this._type) : this._type;
85
85
  if (this._list) {
86
86
  if (this._nonNullList) {
87
- type = (0, graphql_1.GraphQLNonNull)(type);
87
+ type = new graphql_1.GraphQLNonNull(type);
88
88
  }
89
- type = (0, graphql_1.GraphQLList)(type);
89
+ type = new graphql_1.GraphQLList(type);
90
90
  }
91
91
  if (this._nonNull) {
92
- type = (0, graphql_1.GraphQLNonNull)(type);
92
+ type = new graphql_1.GraphQLNonNull(type);
93
93
  }
94
94
  const argument = {
95
95
  type,
@@ -0,0 +1,13 @@
1
+ import { GraphQLResolveInfo } from "graphql";
2
+ export { IMiddleware as Middleware } from "graphql-middleware/dist/types";
3
+ export type ConstructorType<T> = new (...args: any[]) => T;
4
+ export type OptionalPromise<T = void> = Promise<T> | T;
5
+ export type Configurator<T> = (object: T) => T | void;
6
+ export type AnyObject = Record<string, any>;
7
+ export type Optional<T> = T | void;
8
+ export interface ResolverInfo<ST> {
9
+ source: ST;
10
+ args: AnyObject;
11
+ context: any;
12
+ info: GraphQLResolveInfo;
13
+ }
File without changes
File without changes
@@ -7,23 +7,25 @@ import { AbstractSchemaBuilder } from "../schema";
7
7
  import { CreateInputObjectTypeBuilder } from "./createInputObjectType";
8
8
  import { UpdateInputObjectTypeBuilder } from "./updateInputObjectType";
9
9
  import { Configurator } from "../common";
10
- export declare type EntityType = ObjectTypeBuilder | (() => ObjectTypeBuilder);
10
+ export type EntityType = ObjectTypeBuilder | (() => ObjectTypeBuilder);
11
11
  export declare enum EntityFieldType {
12
12
  ALL = "ALL",
13
13
  FIND = "FIND",
14
14
  CREATE = "CREATE",
15
15
  UPDATE = "UPDATE",
16
16
  DELETE = "DELETE",
17
+ RESTORE = "RESTORE",
17
18
  RELATION = "RELATION"
18
19
  }
19
20
  export declare const entityFieldTypeExtensionName = "$entityFieldType";
20
- export declare abstract class AbstractEntitySchemaBuilderBase<NS extends EntityNamingStrategyBase, OT extends ObjectTypeBuilder, FT extends FieldBuilder> extends AbstractSchemaBuilder<NS> {
21
+ export declare abstract class AbstractEntitySchemaBuilderBase<NS extends EntityNamingStrategyBase, OT extends ObjectTypeBuilder, AFT extends FieldBuilder, FFT extends FieldBuilder, CFT extends FieldBuilder, UFT extends FieldBuilder, DFT extends FieldBuilder, RFT extends FieldBuilder> extends AbstractSchemaBuilder<NS> {
21
22
  protected _entityObjectType?: OT;
22
- protected _allField?: FT;
23
- protected _findField?: FT;
24
- protected _createField?: FT;
25
- protected _updateField?: FT;
26
- protected _deleteField?: FT;
23
+ protected _allField?: AFT;
24
+ protected _findField?: FFT;
25
+ protected _createField?: CFT;
26
+ protected _updateField?: UFT;
27
+ protected _deleteField?: DFT;
28
+ protected _restoreField?: RFT;
27
29
  protected _allowedEntityRoles: Set<string>;
28
30
  protected _deniedEntityRoles: Set<string>;
29
31
  protected _entityResolvers?: object;
@@ -33,47 +35,54 @@ export declare abstract class AbstractEntitySchemaBuilderBase<NS extends EntityN
33
35
  entity(builder: OT): this;
34
36
  entity(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<OT>, configurator: Configurator<OT>): this;
35
37
  all(): this;
36
- all(configurator: Configurator<FT>): this;
37
- all(name: string, configurator: Configurator<FT>): this;
38
+ all(configurator: Configurator<AFT>): this;
39
+ all(name: string, configurator: Configurator<AFT>): this;
38
40
  all(name: string): this;
39
- all(builder: FT): this;
40
- all(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FT>, configurator: Configurator<FT>): this;
41
+ all(builder: AFT): this;
42
+ all(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<AFT>, configurator: Configurator<AFT>): this;
41
43
  find(): this;
42
- find(configurator: Configurator<FT>): this;
43
- find(name: string, configurator: Configurator<FT>): this;
44
+ find(configurator: Configurator<FFT>): this;
45
+ find(name: string, configurator: Configurator<FFT>): this;
44
46
  find(name: string): this;
45
- find(builder: FT): this;
46
- find(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FT>, configurator: Configurator<FT>): this;
47
+ find(builder: FFT): this;
48
+ find(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FFT>, configurator: Configurator<FFT>): this;
47
49
  create(): this;
48
- create(configurator: Configurator<FT>): this;
49
- create(name: string, configurator: Configurator<FT>): this;
50
+ create(configurator: Configurator<CFT>): this;
51
+ create(name: string, configurator: Configurator<CFT>): this;
50
52
  create(name: string): this;
51
- create(builder: FT): this;
52
- create(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FT>, configurator: Configurator<FT>): this;
53
+ create(builder: CFT): this;
54
+ create(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<CFT>, configurator: Configurator<CFT>): this;
53
55
  update(): this;
54
- update(configurator: Configurator<FT>): this;
55
- update(name: string, configurator: Configurator<FT>): this;
56
+ update(configurator: Configurator<UFT>): this;
57
+ update(name: string, configurator: Configurator<UFT>): this;
56
58
  update(name: string): this;
57
- update(builder: FT): this;
58
- update(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FT>, configurator: Configurator<FT>): this;
59
+ update(builder: UFT): this;
60
+ update(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<UFT>, configurator: Configurator<UFT>): this;
59
61
  delete(): this;
60
- delete(configurator: Configurator<FT>): this;
61
- delete(name: string, configurator: Configurator<FT>): this;
62
+ delete(configurator: Configurator<DFT>): this;
63
+ delete(name: string, configurator: Configurator<DFT>): this;
62
64
  delete(name: string): this;
63
- delete(builder: FT): this;
64
- delete(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<FT>, configurator: Configurator<FT>): this;
65
+ delete(builder: DFT): this;
66
+ delete(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<DFT>, configurator: Configurator<DFT>): this;
67
+ restore(): this;
68
+ restore(configurator: Configurator<RFT>): this;
69
+ restore(name: string, configurator: Configurator<RFT>): this;
70
+ restore(name: string): this;
71
+ restore(builder: RFT): this;
72
+ restore(builderOrConfiguratorOrName: BuilderOrConfiguratorOrName<RFT>, configurator: Configurator<RFT>): this;
65
73
  allowEntity(...roles: string[]): this;
66
74
  denyEntity(...roles: string[]): this;
67
75
  entityResolvers(resolvers?: object): this;
68
76
  finalizeSchema(): Promise<void>;
69
77
  protected abstract createEntityObjectType(name: BuilderName): OT;
70
- protected abstract createAllField(name: BuilderName): FT;
71
- protected abstract createFindField(name: BuilderName): FT;
72
- protected abstract createCreateField(name: BuilderName): FT;
73
- protected abstract createUpdateField(name: BuilderName): FT;
74
- protected abstract createDeleteField(name: BuilderName): FT;
78
+ protected abstract createAllField(name: BuilderName): AFT;
79
+ protected abstract createFindField(name: BuilderName): FFT;
80
+ protected abstract createCreateField(name: BuilderName): CFT;
81
+ protected abstract createUpdateField(name: BuilderName): UFT;
82
+ protected abstract createDeleteField(name: BuilderName): DFT;
83
+ protected abstract createRestoreField(name: BuilderName): RFT;
75
84
  }
76
- export declare abstract class AbstractEntitySchemaBuilder<NS extends EntityNamingStrategy, OT extends ObjectTypeBuilder, FT extends FieldBuilder, CIT extends InputObjectTypeBuilder, UIT extends InputObjectTypeBuilder> extends AbstractEntitySchemaBuilderBase<NS, OT, FT> {
85
+ export declare abstract class AbstractEntitySchemaBuilder<NS extends EntityNamingStrategy, OT extends ObjectTypeBuilder, AFT extends FieldBuilder, FFT extends FieldBuilder, CFT extends FieldBuilder, UFT extends FieldBuilder, DFT extends FieldBuilder, RFT extends FieldBuilder, CIT extends InputObjectTypeBuilder, UIT extends InputObjectTypeBuilder> extends AbstractEntitySchemaBuilderBase<NS, OT, AFT, FFT, CFT, UFT, DFT, RFT> {
77
86
  protected _createInputObject?: CIT;
78
87
  protected _updateInputObject?: UIT;
79
88
  createInput(): this;
@@ -92,7 +101,7 @@ export declare abstract class AbstractEntitySchemaBuilder<NS extends EntityNamin
92
101
  protected abstract createCreateInputObject(name: BuilderName): CIT;
93
102
  protected abstract createUpdateInputObject(name: BuilderName): UIT;
94
103
  }
95
- export declare class EntitySchemaBuilder extends AbstractEntitySchemaBuilder<EntityNamingStrategy, ObjectTypeBuilder, FieldBuilder, CreateInputObjectTypeBuilder, UpdateInputObjectTypeBuilder> {
104
+ export declare class EntitySchemaBuilder extends AbstractEntitySchemaBuilder<EntityNamingStrategy, ObjectTypeBuilder, FieldBuilder, FieldBuilder, FieldBuilder, FieldBuilder, FieldBuilder, FieldBuilder, CreateInputObjectTypeBuilder, UpdateInputObjectTypeBuilder> {
96
105
  static defaultNamingStrategy: EntityNamingStrategy;
97
106
  constructor(name?: string);
98
107
  protected createEntityObjectType(name: BuilderName): ObjectTypeBuilder;
@@ -101,6 +110,7 @@ export declare class EntitySchemaBuilder extends AbstractEntitySchemaBuilder<Ent
101
110
  protected createCreateField(name: BuilderName): FieldBuilder;
102
111
  protected createUpdateField(name: BuilderName): FieldBuilder;
103
112
  protected createDeleteField(name: BuilderName): FieldBuilder;
113
+ protected createRestoreField(name: BuilderName): FieldBuilder;
104
114
  protected createCreateInputObject(name: BuilderName): CreateInputObjectTypeBuilder;
105
115
  protected createUpdateInputObject(name: BuilderName): UpdateInputObjectTypeBuilder;
106
116
  }
@@ -15,6 +15,7 @@ var EntityFieldType;
15
15
  EntityFieldType["CREATE"] = "CREATE";
16
16
  EntityFieldType["UPDATE"] = "UPDATE";
17
17
  EntityFieldType["DELETE"] = "DELETE";
18
+ EntityFieldType["RESTORE"] = "RESTORE";
18
19
  EntityFieldType["RELATION"] = "RELATION";
19
20
  })(EntityFieldType = exports.EntityFieldType || (exports.EntityFieldType = {}));
20
21
  exports.entityFieldTypeExtensionName = "$entityFieldType";
@@ -60,6 +61,12 @@ class AbstractEntitySchemaBuilderBase extends schema_1.AbstractSchemaBuilder {
60
61
  this._deleteField = (0, util_1.resolveBuilder)(resolvedArgs, name => this.createDeleteField(name || defaultName));
61
62
  return this;
62
63
  }
64
+ restore(builderOrConfiguratorOrName = null, configurator = null) {
65
+ let resolvedArgs = (0, util_1.resolveAutoBuilderArgs)(builderOrConfiguratorOrName, configurator, field_1.FieldBuilder);
66
+ const defaultName = () => this.namingStrategy.restoreField(this.name);
67
+ this._restoreField = (0, util_1.resolveBuilder)(resolvedArgs, name => this.createRestoreField(name || defaultName));
68
+ return this;
69
+ }
63
70
  allowEntity(...roles) {
64
71
  roles.forEach(role => this._allowedEntityRoles.add(role));
65
72
  return this;
@@ -106,6 +113,11 @@ class AbstractEntitySchemaBuilderBase extends schema_1.AbstractSchemaBuilder {
106
113
  this._deleteField.extension(exports.entityFieldTypeExtensionName, EntityFieldType.DELETE);
107
114
  this.mutation(this._deleteField);
108
115
  }
116
+ if (this._restoreField) {
117
+ this._restoreField.type(this._entityObjectType.name);
118
+ this._restoreField.extension(exports.entityFieldTypeExtensionName, EntityFieldType.RESTORE);
119
+ this.mutation(this._restoreField);
120
+ }
109
121
  // Entity resolvers
110
122
  if (this._entityResolvers) {
111
123
  this._resolvers = Object.assign({ [this._entityObjectType.name]: (0, util_1.ensureInstantiated)(this._entityResolvers) }, this._resolvers);
@@ -134,20 +146,27 @@ class AbstractEntitySchemaBuilder extends AbstractEntitySchemaBuilderBase {
134
146
  if (this._deleteField) {
135
147
  this._deleteField.arg(this.namingStrategy.deleteFieldIdArgument(this.name), 'ID', _ => _.nonNull());
136
148
  }
149
+ if (this._restoreField) {
150
+ this._restoreField.arg(this.namingStrategy.restoreFieldIdArgument(this.name), 'ID', _ => _.nonNull());
151
+ }
137
152
  if (this._createField) {
138
153
  if (!this._createInputObject) {
139
154
  this._createInputObject = this.createCreateInputObject(this.namingStrategy.createInputObject(this.name));
140
155
  }
141
- this.inputObject(this._createInputObject);
142
156
  this._createField.arg(this.namingStrategy.createFieldInputArgument(this.name), this._createInputObject.name, _ => _.nonNull());
143
157
  }
158
+ if (this._createInputObject) {
159
+ this.inputObject(this._createInputObject);
160
+ }
144
161
  if (this._updateField) {
145
162
  if (!this._updateInputObject) {
146
163
  this._updateInputObject = this.createUpdateInputObject(this.namingStrategy.updateInputObject(this.name));
147
164
  }
148
- this.inputObject(this._updateInputObject);
149
165
  this._updateField.arg(this.namingStrategy.updateFieldInputArgument(this.name), this._updateInputObject.name, _ => _.nonNull());
150
166
  }
167
+ if (this._updateInputObject) {
168
+ this.inputObject(this._updateInputObject);
169
+ }
151
170
  }
152
171
  }
153
172
  exports.AbstractEntitySchemaBuilder = AbstractEntitySchemaBuilder;
@@ -174,6 +193,9 @@ class EntitySchemaBuilder extends AbstractEntitySchemaBuilder {
174
193
  createDeleteField(name) {
175
194
  return new field_1.FieldBuilder(name, 'Boolean');
176
195
  }
196
+ createRestoreField(name) {
197
+ return new field_1.FieldBuilder(name);
198
+ }
177
199
  createCreateInputObject(name) {
178
200
  return new createInputObjectType_1.CreateInputObjectTypeBuilder(name, () => this._entityObjectType);
179
201
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -19,7 +19,7 @@ export interface FieldBuilderInfo {
19
19
  plugins: Plugin[];
20
20
  resolver?: GraphQLFieldResolver<any, any>;
21
21
  }
22
- export declare type FieldType = string | GraphQLOutputType;
22
+ export type FieldType = string | GraphQLOutputType;
23
23
  export declare class FieldBuilder extends Builder<GraphQLFieldConfig<any, any>> {
24
24
  protected _type: FieldType;
25
25
  protected _description?: string;
@@ -134,12 +134,12 @@ class FieldBuilder extends Builder_1.default {
134
134
  }
135
135
  if (this._list) {
136
136
  if (this._nonNullList) {
137
- type = (0, graphql_1.GraphQLNonNull)(type);
137
+ type = new graphql_1.GraphQLNonNull(type);
138
138
  }
139
- type = (0, graphql_1.GraphQLList)(type);
139
+ type = new graphql_1.GraphQLList(type);
140
140
  }
141
141
  if (this._nonNull) {
142
- type = (0, graphql_1.GraphQLNonNull)(type);
142
+ type = new graphql_1.GraphQLNonNull(type);
143
143
  }
144
144
  const resolver = this._resolver || context.getResolver(parentBuilder.name, this.name);
145
145
  const field = {
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  import { GraphQLInputFieldConfig, GraphQLInputType } from "graphql/type/definition";
2
2
  import Builder, { BuildContext, FinalizeContext, BuilderName } from "./Builder";
3
3
  import { Plugin } from "./plugin";
4
- export declare type InputFieldType = string | GraphQLInputType;
4
+ export type InputFieldType = string | GraphQLInputType;
5
5
  export interface InputFieldBuilderInfo {
6
6
  name: string;
7
7
  type: InputFieldType;
@@ -84,12 +84,12 @@ class InputFieldBuilder extends Builder_1.default {
84
84
  let type = (0, lodash_1.isString)(this._type) ? context.getType(this._type) : this._type;
85
85
  if (this._list) {
86
86
  if (this._nonNullList) {
87
- type = (0, graphql_1.GraphQLNonNull)(type);
87
+ type = new graphql_1.GraphQLNonNull(type);
88
88
  }
89
- type = (0, graphql_1.GraphQLList)(type);
89
+ type = new graphql_1.GraphQLList(type);
90
90
  }
91
91
  if (this._nonNull) {
92
- type = (0, graphql_1.GraphQLNonNull)(type);
92
+ type = new graphql_1.GraphQLNonNull(type);
93
93
  }
94
94
  const inputField = {
95
95
  type,
@@ -17,10 +17,10 @@ export declare class InputObjectTypeBuilder extends Builder<GraphQLInputType> {
17
17
  protected _extensions: Map<string, any>;
18
18
  description(description?: string): this;
19
19
  extension(name: string, value: any): this;
20
- field(name: string, type: InputFieldType, configurator: Configurator<InputFieldBuilder>): any;
21
- field(name: string, type: InputFieldType): any;
22
- field(field: InputFieldBuilder): any;
23
- field(fieldOrName: InputFieldBuilder | string, type: InputFieldType, configurator: Configurator<InputFieldBuilder>): any;
20
+ field(name: string, type: InputFieldType, configurator: Configurator<InputFieldBuilder>): this;
21
+ field(name: string, type: InputFieldType): this;
22
+ field(field: InputFieldBuilder): this;
23
+ field(fieldOrName: InputFieldBuilder | string, type: InputFieldType, configurator: Configurator<InputFieldBuilder>): this;
24
24
  finalizeBuilder(context: FinalizeContext): Promise<void>;
25
25
  finalizeInputObjectType(context: FinalizeContext, info: InputObjectTypeBuilderInfo): Promise<void>;
26
26
  build(context: BuildContext): GraphQLInputObjectType;
File without changes
@@ -7,10 +7,12 @@ export interface EntityNamingStrategyBase extends NamingStrategy {
7
7
  createField(schemaName: string): string;
8
8
  updateField(schemaName: string): string;
9
9
  deleteField(schemaName: string): string;
10
+ restoreField(schemaName: string): string;
10
11
  }
11
12
  export interface EntityNamingStrategy extends EntityNamingStrategyBase {
12
13
  findFieldIdArgument(schemaName: string): string;
13
14
  deleteFieldIdArgument(schemaName: string): string;
15
+ restoreFieldIdArgument(schemaName: string): string;
14
16
  createInputObject(schemaName: string): string;
15
17
  createFieldInputArgument(schemaName: string): string;
16
18
  updateInputObject(schemaName: string): string;
File without changes
@@ -6,8 +6,10 @@ export declare class CompactNamingStrategy implements EntityNamingStrategy {
6
6
  createField(schemaName: string): string;
7
7
  updateField(schemaName: string): string;
8
8
  deleteField(schemaName: string): string;
9
+ restoreField(schemaName: string): string;
9
10
  findFieldIdArgument(schemaName: string): string;
10
11
  deleteFieldIdArgument(schemaName: string): string;
12
+ restoreFieldIdArgument(schemaName: string): string;
11
13
  createInputObject(schemaName: string): string;
12
14
  createFieldInputArgument(schemaName: string): string;
13
15
  updateInputObject(schemaName: string): string;
@@ -21,12 +21,18 @@ class CompactNamingStrategy {
21
21
  deleteField(schemaName) {
22
22
  return `delete${(0, util_1.ucFirst)(schemaName)}`;
23
23
  }
24
+ restoreField(schemaName) {
25
+ return `restore${(0, util_1.ucFirst)(schemaName)}`;
26
+ }
24
27
  findFieldIdArgument(schemaName) {
25
28
  return 'id';
26
29
  }
27
30
  deleteFieldIdArgument(schemaName) {
28
31
  return 'id';
29
32
  }
33
+ restoreFieldIdArgument(schemaName) {
34
+ return 'id';
35
+ }
30
36
  createInputObject(schemaName) {
31
37
  return `Create${(0, util_1.ucFirst)(schemaName)}Input`;
32
38
  }
@@ -6,8 +6,10 @@ export declare class DescriptiveNamingStrategy implements EntityNamingStrategy {
6
6
  createField(schemaName: string): string;
7
7
  updateField(schemaName: string): string;
8
8
  deleteField(schemaName: string): string;
9
+ restoreField(schemaName: string): string;
9
10
  findFieldIdArgument(schemaName: string): string;
10
11
  deleteFieldIdArgument(schemaName: string): string;
12
+ restoreFieldIdArgument(schemaName: string): string;
11
13
  createInputObject(schemaName: string): string;
12
14
  createFieldInputArgument(schemaName: string): string;
13
15
  updateInputObject(schemaName: string): string;
@@ -21,12 +21,18 @@ class DescriptiveNamingStrategy {
21
21
  deleteField(schemaName) {
22
22
  return `delete${(0, util_1.ucFirst)(schemaName)}`;
23
23
  }
24
+ restoreField(schemaName) {
25
+ return `restore${(0, util_1.ucFirst)(schemaName)}`;
26
+ }
24
27
  findFieldIdArgument(schemaName) {
25
28
  return 'id';
26
29
  }
27
30
  deleteFieldIdArgument(schemaName) {
28
31
  return 'id';
29
32
  }
33
+ restoreFieldIdArgument(schemaName) {
34
+ return 'id';
35
+ }
30
36
  createInputObject(schemaName) {
31
37
  return `Create${(0, util_1.ucFirst)(schemaName)}Input`;
32
38
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,7 +2,7 @@ import { AclMiddlewareOptions } from "./middleware";
2
2
  import { Plugin } from "../common";
3
3
  import { SchemaBuilder } from "../../schema";
4
4
  import { GraphQLSchema } from "graphql";
5
- export declare type AclRoleIdentifier = string | number;
5
+ export type AclRoleIdentifier = string | number;
6
6
  interface AclRoleConfig {
7
7
  identifier: AclRoleIdentifier;
8
8
  parent?: AclRoleIdentifier;
@@ -20,7 +20,7 @@ export interface AclValidateConfig {
20
20
  resource?: string;
21
21
  allowedRoles?: AclRoleIdentifier[];
22
22
  }
23
- export declare type AclValidateConfigType = AclValidateConfig | AclRoleIdentifier | AclRoleIdentifier[];
23
+ export type AclValidateConfigType = AclValidateConfig | AclRoleIdentifier | AclRoleIdentifier[];
24
24
  export interface AclOptions extends AclMiddlewareOptions {
25
25
  defaultAction?: AclAction;
26
26
  learn?: boolean;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,4 @@
1
+ import { GraphQLSchemaConfig } from "graphql/type/schema";
1
2
  import { GraphQLFieldResolver } from "graphql/type/definition";
2
3
  import { GraphQLScalarType, GraphQLSchema, GraphQLType } from "graphql";
3
4
  import { ObjectTypeBuilder } from "./objectType";
@@ -14,13 +15,14 @@ export declare abstract class AbstractSchemaBuilder<NS extends NamingStrategy> {
14
15
  protected _plugins: Plugin[];
15
16
  protected _middleware: Middleware[];
16
17
  protected _subSchemas: AbstractSchemaBuilder<any>[];
18
+ protected _customConfig?: Readonly<GraphQLSchemaConfig>;
17
19
  protected _defaultNamingStrategy?: NS;
18
20
  protected _namingStrategy?: NS;
19
21
  protected _objectTypes: Map<string, ObjectTypeBuilder>;
20
22
  protected _inputObjectTypes: Map<string, InputObjectTypeBuilder>;
21
23
  protected _enumTypes: Map<string, EnumTypeBuilder>;
22
24
  protected _unionTypes: Map<string, UnionTypeBuilder>;
23
- protected _scalarTypes: Map<string, GraphQLScalarType>;
25
+ protected _scalarTypes: Map<string, GraphQLScalarType<unknown, unknown>>;
24
26
  protected _allowedRoles: Set<string>;
25
27
  protected _deniedRoles: Set<string>;
26
28
  protected _allowedQueryRoles: Set<string>;
@@ -36,6 +38,7 @@ export declare abstract class AbstractSchemaBuilder<NS extends NamingStrategy> {
36
38
  naming(strategy: NS): this;
37
39
  setDefaultNamingStrategy(strategy: NS): void;
38
40
  get namingStrategy(): NS;
41
+ customConfig(config: Readonly<GraphQLSchemaConfig>): this;
39
42
  object(name: string, configurator: Configurator<ObjectTypeBuilder>): this;
40
43
  object(name: string): this;
41
44
  object(object: ObjectTypeBuilder): this;
@@ -42,6 +42,10 @@ class AbstractSchemaBuilder {
42
42
  get namingStrategy() {
43
43
  return this._namingStrategy || this._defaultNamingStrategy;
44
44
  }
45
+ customConfig(config) {
46
+ this._customConfig = config;
47
+ return this;
48
+ }
45
49
  object(objectOrName, configurator = null) {
46
50
  const resolvedArgs = (0, util_1.resolveBuilderArgs)(objectOrName, configurator, objectType_1.ObjectTypeBuilder);
47
51
  const resolvedBuilder = (0, util_1.resolveBuilder)(resolvedArgs, name => new objectType_1.ObjectTypeBuilder(name));
@@ -305,9 +309,7 @@ class AbstractSchemaBuilder {
305
309
  const resolvedRootSchema = rootSchema || this;
306
310
  const context = new Builder_1.BuildContext(this, resolvedRootSchema, resolvedTypes);
307
311
  // Schema
308
- const schemaConfig = {
309
- query: this._queryObject.build(context)
310
- };
312
+ const schemaConfig = Object.assign(Object.assign({}, (this._customConfig || {})), { query: this._queryObject.build(context) });
311
313
  if (this._mutationObject) {
312
314
  schemaConfig['mutation'] = this._mutationObject.build(context);
313
315
  }
@@ -9,7 +9,7 @@ export interface UnionTypeBuilderInfo {
9
9
  extensions: Map<string, any>;
10
10
  plugins: Plugin[];
11
11
  }
12
- export declare type UnionTypeMemberName = string | GraphQLOutputType;
12
+ export type UnionTypeMemberName = string | GraphQLOutputType;
13
13
  export declare class UnionTypeBuilder extends Builder<GraphQLUnionType> {
14
14
  protected _types: Set<UnionTypeMemberName>;
15
15
  protected _description?: string;
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,19 +1,24 @@
1
1
  {
2
2
  "name": "@kiwano/core",
3
- "version": "0.1.2",
3
+ "version": "1.0.0",
4
4
  "description": "",
5
- "main": "index.js",
6
- "typings": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
7
  "scripts": {
8
- "build": "npm run clean && npm run compile && npm run copy",
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "npm run clean && npm run compile",
9
10
  "clean": "rimraf ./dist",
10
- "compile": "tsc -p tsconfig.build.json",
11
- "copy": "ts-node -T ../../scripts/copy.ts"
11
+ "compile": "tsc -p tsconfig.json",
12
+ "watch": "tsc --watch --preserveWatchOutput -p tsconfig.json",
13
+ "publish": "npm publish"
12
14
  },
13
15
  "repository": {
14
16
  "type": "git",
15
17
  "url": "git+https://github.com/kiwano-js/kiwano.git"
16
18
  },
19
+ "files": [
20
+ "dist/**"
21
+ ],
17
22
  "author": "Bart Blok <bart@wittig.nl>",
18
23
  "license": "MIT",
19
24
  "bugs": {
@@ -27,11 +32,10 @@
27
32
  "access": "public"
28
33
  },
29
34
  "devDependencies": {
30
- "@types/lodash": "^4.14.182",
31
- "graphql": "^15.8.0",
35
+ "@types/lodash": "^4.14.191",
36
+ "graphql": "^16.6.0",
32
37
  "rimraf": "^3.0.2",
33
- "ts-node": "^10.7.0",
34
- "typescript": "^4.6.3"
38
+ "typescript": "^4.9.3"
35
39
  },
36
40
  "dependencies": {
37
41
  "@graphql-tools/schema": "^8.3.9",
@@ -40,7 +44,7 @@
40
44
  "pluralize": "^8.0.0"
41
45
  },
42
46
  "peerDependencies": {
43
- "graphql": "^14.0.0 || ^15.0.0"
47
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
44
48
  },
45
49
  "gitHead": "8c06d628d7cfaddff14bbd8fc08fefb1d9be0118"
46
50
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 kiwano-js
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1 +0,0 @@
1
- # Kiwano
package/common.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { GraphQLResolveInfo } from "graphql";
2
- export { IMiddleware as Middleware } from "graphql-middleware/dist/types";
3
- export declare type ConstructorType<T> = new (...args: any[]) => T;
4
- export declare type OptionalPromise<T = void> = Promise<T> | T;
5
- export declare type Configurator<T> = (object: T) => T | void;
6
- export declare type AnyObject = Record<string, any>;
7
- export declare type Optional<T> = T | void;
8
- export interface ResolverInfo<ST> {
9
- source: ST;
10
- args: AnyObject;
11
- context: any;
12
- info: GraphQLResolveInfo;
13
- }