Skip to content

Commit

Permalink
v3.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniopresto committed Mar 12, 2024
1 parent e7aaef2 commit ff1465c
Show file tree
Hide file tree
Showing 22 changed files with 352 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powership",
"version": "3.3.7",
"version": "3.3.10",
"private": true,
"scripts": {
"pack": "run-s pack:*",
Expand Down
10 changes: 5 additions & 5 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/accounts",
"version": "3.3.7",
"version": "3.3.10",
"description": "Powership accounts",
"type": "module",
"main": "./out/index.cjs",
Expand Down Expand Up @@ -91,8 +91,8 @@
"peerDependencies": {
"scrypt-kdf": "*",
"jsonwebtoken": "*",
"@powership/schema": "3.3.7",
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.10",
"@powership/utils": "3.3.10",
"dataloader": "*",
"plugin-hooks": "*",
"sift": "*",
Expand Down Expand Up @@ -135,7 +135,7 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/transporter": "3.3.7",
"@powership/entity": "3.3.7"
"@powership/transporter": "3.3.10",
"@powership/entity": "3.3.10"
}
}
2 changes: 1 addition & 1 deletion packages/babel-plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/babel-plugins",
"version": "3.3.7",
"version": "3.3.10",
"main": "./out/index.js",
"sideEffects": false,
"typings": "./out/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/boilerplate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/boilerplate",
"version": "3.3.7",
"version": "3.3.10",
"author": "antoniopresto <[email protected]>",
"sideEffects": false,
"type": "module",
Expand Down Expand Up @@ -61,7 +61,7 @@
"ts-jest": "*",
"typedoc": "*",
"typescript": "*",
"@powership/babel-plugins": "3.3.7",
"@powership/babel-plugins": "3.3.10",
"@babel/preset-typescript": "*",
"@babel/preset-env": "*",
"@babel/plugin-transform-typescript": "*",
Expand Down
6 changes: 3 additions & 3 deletions packages/deepstate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/deepstate",
"version": "3.3.7",
"version": "3.3.10",
"main": "out/index.cjs",
"module": "out/index.mjs",
"sideEffects": false,
Expand Down Expand Up @@ -120,7 +120,7 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.7"
"@powership/utils": "3.3.10",
"@powership/schema": "3.3.10"
}
}
8 changes: 4 additions & 4 deletions packages/entity/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/entity",
"version": "3.3.7",
"version": "3.3.10",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand Down Expand Up @@ -138,8 +138,8 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.7",
"@powership/transporter": "3.3.7"
"@powership/utils": "3.3.10",
"@powership/schema": "3.3.10",
"@powership/transporter": "3.3.10"
}
}
4 changes: 2 additions & 2 deletions packages/logstorm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logstorm",
"version": "3.3.7",
"version": "3.3.10",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"type": "module",
Expand Down Expand Up @@ -124,6 +124,6 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7"
"@powership/utils": "3.3.10"
}
}
8 changes: 4 additions & 4 deletions packages/mongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/mongo",
"version": "3.3.7",
"version": "3.3.10",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand Down Expand Up @@ -130,9 +130,9 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.7",
"@powership/transporter": "3.3.7",
"@powership/utils": "3.3.10",
"@powership/schema": "3.3.10",
"@powership/transporter": "3.3.10",
"mongodb": "*"
},
"files": [
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-engine",
"version": "3.3.7",
"version": "3.3.10",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand Down Expand Up @@ -96,9 +96,9 @@
},
"peerDependencies": {
"highlight.js": "*",
"@powership/schema": "3.3.7",
"@powership/transporter": "3.3.7",
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.10",
"@powership/transporter": "3.3.10",
"@powership/utils": "3.3.10",
"dataloader": "*",
"plugin-hooks": "*",
"sift": "*",
Expand Down Expand Up @@ -141,6 +141,6 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/entity": "3.3.7"
"@powership/entity": "3.3.10"
}
}
16 changes: 8 additions & 8 deletions packages/powership/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powership",
"version": "3.3.7",
"version": "3.3.10",
"author": "antoniopresto <[email protected]>",
"type": "module",
"main": "./out/index.cjs",
Expand Down Expand Up @@ -105,11 +105,11 @@
"tsconfig": "./tsconfig.module.json"
},
"peerDependencies": {
"@powership/utils": "3.3.7",
"@powership/schema": "3.3.7",
"@powership/entity": "3.3.7",
"@powership/utils": "3.3.10",
"@powership/schema": "3.3.10",
"@powership/entity": "3.3.10",
"highlight.js": "*",
"@powership/transporter": "3.3.7",
"@powership/transporter": "3.3.10",
"dataloader": "*",
"plugin-hooks": "*",
"sift": "*",
Expand Down Expand Up @@ -152,12 +152,12 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"plugin-engine": "3.3.7",
"plugin-engine": "3.3.10",
"body-parser": "*",
"graphql-playground-html": "*",
"http-errors": "*",
"http-status-codes": "*",
"logstorm": "3.3.7",
"@powership/server": "3.3.7"
"logstorm": "3.3.10",
"@powership/server": "3.3.10"
}
}
6 changes: 3 additions & 3 deletions packages/runmate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runmate",
"version": "3.3.7",
"version": "3.3.10",
"typings": "out",
"author": "antoniopresto <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -141,8 +141,8 @@
"ts-toolbelt": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7",
"logstorm": "3.3.7",
"@powership/utils": "3.3.10",
"logstorm": "3.3.10",
"@types/vorpal": "*",
"@types/glob": "*"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powership/schema",
"version": "3.3.7",
"version": "3.3.10",
"type": "module",
"main": "./out/index.cjs",
"module": "./out/index.mjs",
Expand Down Expand Up @@ -144,6 +144,6 @@
"tsx": "*",
"ulid": "*",
"url-pattern": "*",
"@powership/utils": "3.3.7"
"@powership/utils": "3.3.10"
}
}
4 changes: 2 additions & 2 deletions packages/schema/src/GraphType/GraphType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class GraphType<Definition extends ObjectFieldInput> {
if (self._optionalId) return self._optionalId;
throw new RuntimeError(
[
'The method you are trying to execute expects the GraphType used to be previously identified.\n' +
'The method you are trying to execute requires the GraphType to be identified.\n' +
'Examples:\n' +
' - `myNiceType.identify("Foo")`\n' +
' - `Type.identify("Foo")`\n' +
" - `createType('Bar', FieldDefinition)`",
].join('\n'),
this.__lazyGetter.definitionInput
Expand Down
96 changes: 96 additions & 0 deletions packages/schema/src/__alias__.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { keys } from '@powership/utils';

import { createType, GraphType } from './GraphType/GraphType';
import { FieldDefinitions, FieldTypeName } from './fields/_fieldDefinitions';
import { FieldDefinition } from './fields/_parseFields';
import { types } from './fields/fieldTypes';

export type __Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;

export type CreateType<
Name extends FieldTypeName,
Definition extends FieldDefinitions[Name]
> = [Extract<Definition, undefined>] extends [never]
? <Def extends Definition>(
...params: [name: string, definition: Def] | [definition: Def]
) => GraphType<__Cast<{ [N in Name]: Def }, FieldDefinition>>
: //
//
//
<Def extends Definition>(
...params: [name?: string, definition?: Def] | [definition?: Def]
) => GraphType<__Cast<{ [N in Name]: Def }, FieldDefinition>>;

export type _Creators<Name extends FieldTypeName> =
FieldDefinitions[Name] extends unknown
? CreateType<Name, FieldDefinitions[Name]>
: never;

export type Creators = {
[Name in FieldTypeName]: Name extends unknown ? _Creators<Name> : never;
};

export const t = keys(types).reduce((acc, tname) => {
function fn(...args: any[]) {
if (typeof args[0] === 'string') {
// @ts-ignore
return createType(args[0], { [tname]: args[1] });
}
// @ts-ignore
return createType({ [tname]: args[1] });
}

Object.defineProperty(fn, 'name', { value: `${tname}Type` });

return { ...acc, [tname]: fn };
}, {} as any) as unknown as Creators;

const {
boolean: booleanType,
string: stringType,
ID: idType,
any: anyType,
float: floatType,
object: objectType,
undefined: undefinedType,
cursor: cursorType,
int: intType,
array: arrayType,
date: dateType,
unknown: unknownType,
email: emailType,
literal: literalType,
enum: enumType,
null: nullType,
meta: metaType,
record: recordType,
ulid: ulidType,
union: unionType,
phone: phoneType,
alias: aliasType,
} = t;

export {
booleanType,
stringType,
idType,
anyType,
floatType,
objectType,
undefinedType,
cursorType,
intType,
arrayType,
dateType,
unknownType,
emailType,
literalType,
enumType,
nullType,
metaType,
recordType,
ulidType,
unionType,
phoneType,
aliasType,
};
13 changes: 13 additions & 0 deletions packages/schema/src/__tests__/types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert, IsExact } from 'conditional-type-checks';
import { booleanType, objectType, unknownType } from '../__alias__';

import { Infer } from '../Infer';
import { createObjectType, ObjectType } from '../ObjectType';
Expand All @@ -24,6 +25,18 @@ describe('typings', () => {
>(true);
});

test('alias', () => {
const sut = [
unknownType('foo'),
booleanType(),
objectType('ga', { name: 'string' }),
]
.map((el) => el.optionalId)
.join('');

expect(sut).toEqual('fooga');
});

test('TypeFromObjectDefinition', () => {
const otherObject = new ObjectType({
name: 'string',
Expand Down
1 change: 1 addition & 0 deletions packages/schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ import * as Internal from './internal';
export { Internal };

export * from './internal';
export * from './__alias__';
Loading

0 comments on commit ff1465c

Please sign in to comment.